Find IP address from device MAC address in Objective C - ios

I am developing an iOS application which require ip address of device for communication, I have MAC address of device from which I need to find IP address, there is available help for finding MAC address from IP address but not the same.
I have referred LAN-Scan library but it is pinging each devices in network and and will get list of connected devices and for each ip address I need to find MAC address and compare with available MAC address.
My question is, Is there any way that we can find directly find ip address for particular MAC address in the network using Objective C?.

This script should give you what you are looking for really quickly and requires to have nmap installed. The advantage is that if your host does not reply to ping probes, nmap would still find the host while other tools will not.
more info https://apple.stackexchange.com/questions/19783/how-do-i-know-the-ip-addresses-of-other-computers-in-my-network

Related

Can grpc communicate with mac address insted of ip

Currently my program use the IP of the other device in order to communicate over grpc.
Unfortunately the IP is changing all the time and I cannot continue the connection between the devices without updating it manually.
The connection between the devices is only on LAN and should blocked access from WAN.
Locking the IP of the device in the rowter settings is not an option this time.
Does grpc have a way to communicate over LAN (inside my network) using identification number or mac address that does not change over time?.
Related questions I found:
grpc: Identify clients from same IP address
Reason for both a MAC and an IP address
In order to locate a machine based on its MAC address, you are talking about implementing ARP. This is something that is not supported in dart nor am I sure it would be advisable to go this route anyway. If setting a DHCP reservation on your router is not an option, are you able to skip DHCP and set a static IP on the receiving machine?
You could look into dynamic DNS which your router may support, or you may need to set up separately, but that will also require a static IP (for your DDNS server). If your machines can connect to the internet there are many DDNS services you can sign up for, but it sounds like that is not the case.

How to get SIM ip address for ipad

I need to know the source IP for my iPad using my SIM network. Is there any way to get source IP address for SIM network
Go to a website like e.g. http://www.whatsmyip.org and there you can see your public IP address.

How to get a remote MAC address via IPv6 in iOS programmatically

I need to find a solution how to get the MAC address from the other device in the WiFi network. There is a good method how to do this for IPv4 (How does iOS app Fing get MAC Address?), but how to do this for IPv6? Since ARP was replaced by the NDP (Neighbour Discovery Protocol), the latter method doesn't work. I would greatly appreciate if anyone could help me.
Layer and Encapsulation
The network architecture is layered, the upper layer encapsulate the different implementations of lower layer and provide higher abstraction relative to lower layer.
The network layer which use IP encapsulate different link layers protocols, like Ethernet, WiFi, PPP (which may run on serial cable which not use MAC address) etc.
So, the first problem is what do you mean by remote?
If you mean other hosts in WAN, it is impossible unless both device implement a specific protocol: you send a request to those device, they reply with his mac address.
If you mean other host in the same LAN, you can use ARP protocol in IPv4 and NDP (which ) in IPv6.
Arp & NDP
ARP send broadcast in LAN when it knows the IP address of a host but not MAC address, then the hosts which find someone is calling for him reply its MAC address.
NDP provides two main part of functionality, the first is the same with ARP: mapping between network- and link-layer addresses. (The difference is NDP using a multicast address: prefix f02::1:f/104, combined with the low-order 24 bits of the solicited IPv6 address)
So what you need is to send ICMPv6 Neighbor Solicitation message.
Address Assignment in IPv6
Link-local IPv6 addresses (and some global IPv6 addresses) use interface identifiers (IIDs) as a basis for unicast IPv6 address assignment. ... IIDs are ordinarily 64 bits long and are formed either directly from the underlyinglink-layer MAC address of a network interface using a modified EUI-64 format. or by another
process that randomizes the value in hopes of providing some degree of privacy against address tracking.
So in the most common cases, you can get the MAC address of a device directly from their IPv6 link local address.
Conclusion:
implement your protocol in both devices
send NDP message to solicited node if it is in same LAN
extract MAC address from link local IPv6 address
Ref
Wikipedia
TCP/IP Illustrated, volume 1
I'm using MMLanScan for that purpose. It's very simple to get working to find IP/MAC addresses of devices on your LAN.
I use it some time ago but I think it's works with IPv6 also.

Is it possible to ping offline devices?

This may be a strange question but I really want to learn how "ping" command works. Today when I had my smartphone open and online, I pinged its external(public) IP from my terminal in Linux with "ping [ip address]" command and it worked of course.
When I turned off my smartphone and retried to ping its IP, it worked again! As far as I know ping is like sending a message and then getting a reply from the target.How is this possible since my phone is offline?
Any explanation is much appreciated! Thanks!
UPDATE:
Both my phone and PC use Wifi to connect to the internet and are in the same network.
Also there was not any other device that joined the network when I tried the above.
If you subscribe the service from an ISP, then you might share the use of one public IP address among your devices to connect to the Internet. Internally you'll use private IP addresses for your PC and phone. It seems to me that what you have pinged was the public IP address assigned on the gateway of your wifi router and not your phone.
If you are not sure, then try to access http://whatismyipaddress.com/ from both your devices and see if you have the same IP address or not.

View local development server on USB-connected iOS device

I have my OS X development laptop hooked up to the net via an iPhone 5 connected with USB (Personal Hotspot). With a web server running locally for my development work, can I load pages from this server on my iPhone and then inspect them with Safari's Web Inspector? I have tried 127.0.0.1 and my connected IP public address but no success.
It is possible to do this - it just required a bit of investigation as to how the networking is arranged when using an iPhone via USB with Personal Hotspot. There are two steps:
Firstly, using USB, the USB port is setup as a network interface. The precise (and technical) details can be seen with ifconfig however what you need to know is what IP address is used for the USB interface.
Go to Network Preferences and select the iPhone USB on the left hand side. You will see a message like iPhone USB is currently active and has the IP address 172.20.10.2. Note that this is not the publicly available IP address, it is the network interface on the Mac. This is the ip address you need to type into the browser on your iPhone to see your local development server.
Secondly, you need to make sure that your local development server is serving the USB interface. This will obviously vary depending on your server but typically there will be a HOST parameter that directs the server to bind to that IP address. Again, use the IP address you found above to instruct the web server to serve pages on that IP.

Resources