ifconfig C module
mal at lemburg.com
Fri Aug 13 11:55:32 CEST 1999
> I got permission to publish the results of my 'ifconfig' module.
> Since it's rather small, I thought I would post the whole thing here.
> I realize it's not perfect, but it does what I need. I'll accept
> patches to make it better. I'm sure the license could be changed to
> the Python one if there is interest in including it in the main
I'd suggest adding this to either the socketmodule.c or the
fcntlmodule.c in the standard Python distribution.
FYI, I've spiced up the file a bit and turned it into a package
which is available here for easier install:
I changed the names a little in the above archive:
Package name: ifconfig
>From David's code:
The command ifconfig.ifconfig(interface_name), where
interface_name is the name of the interface, such as 'eth0' or 'lo'
returns a dictionary with the following keys:
hwaddr: hardware address
addr: ip address
brdaddr: broadcast address
Great work, David ! I never thought it would be that easy to get
at the hardware MAC address. Now the only question remaining is:
how portable is this code ? E.g. does it compile on Windows ?
Y2000: 140 days left
Python Pages: http://www.lemburg.com/python/
More information about the Python-list