Reputation: 8017
How would I find the ip address if I know the mac address of a machine?
Upvotes: 0
Views: 2944
Reputation: 8017
I needed to be able to do this, so I wrote a python script that can do it:
import scapy
from multiprocessing import Process, Pool
def _arp_request(ip_addr):
answer, _ = srp(Ether(dst="ff:ff:ff:ff:ff:ff")/ARP(pdst=ip_addr), verbose=0, timeout=.5)
if answer:
return (answer[0][1].src, answer[0][0].pdst)
pool = Pool(50)
mac_addrs = [ad for ad in pool.map(_arp_request, addrs) if ad]
addrs is a list of possible ip addresses to try.
It makes rapid arp requests and maps out the network.
Or you could use the module that I wrote (which keeps a cache to minimize the arp requests):
>>> from ethip import ethip
>>> print ethip.getip('00:1E:C9:56:3C:8E', '10.5.42.255')
10.5.42.3
Upvotes: 1