[Tutor] Retrieving arp of gateway
Adam Shand
adam@personaltelco.net
Sun Jun 8 12:55:03 2003
Hi.
I'm playing around with writing my first Python network program and am
trying to figure out a platform neutral way to get the MAC of my
gateway. It's fairly easy to do this with popen's to shell code but you
end up having to look for what OS is running and then run slightly
different commands for each OS.
Eg. on Linux
netstat = os.popen('netstat -rn | grep ^0.0.0.0').readlines()
arp = os.popen('arp %s' % netstat[0].split()[1]).readlines()
address = arp[1].split()[2]
Is there a python native way to query a computers arp table? I haven't
been able to find much on network programming with either on python.org
or via google.
Thanks,
Adam.