Remote MAC Address In Python

Eddie Corns eddie at holyrood.ed.ac.uk
Wed Mar 26 07:24:14 EST 2003


g.papamarkos at dcs.bbk.ac.uk (George Papamarkos) writes:

>Hi guys,
>       Does anyone know if there is a way in Python to grab the MAC
>Address of a computer in a network knowing only its IP Address from a
>Linux machine ? Solutions using "arp" command etc. do not work
>properly. I'd like something more generic pls.

If the machine is up and running and on your LAN then ARP is the proper way to
get the MAC address.  I notice you say arp "command" rather than "protocol" so
you may be relying on the existing ARP table which will time out after a
while.  If you ping the address first then it will make sure that an entry is
in the ARP table when you come to check it.  If the remote machine is not on
your LAN you need to probe routers using SNMP or such like.

Eddie




More information about the Python-list mailing list