Saturday, January 05, 2013

How to Get IP Address from MAC

One way to get the IP address of a remote host in the same subnet given a MAC address is by using the "arp -an" command. However, this will only work if the we have previously connected to the remote host.

With the help of nmap, we can find out the IP address. For example, the command below will scan the 10.1.1.0/24 subnet with nmap. After the scan we search through the output of arp. If the remote host that we are searching for is up, its MAC address will be displayed together with its IP address.

$ nmap -sP 192.168.0.0/24 > /dev/null
$ arp -an | grep -i "12:34:56:78:90:ab"
? (192.168.0.105) at 12:34:56:78:90:ab [ether] on wlan0

No comments: