Accessing NIC configuration via Python

Shae Erisson shapr at uab.edu
Mon Jul 31 10:51:04 EDT 2000


Micheal Kelly wrote:

> Unfortunately, this wasn't quite what I was after.  What I'd really like
> to get is low-level NIC configuration information, such as the device
> names of all configured ethernet cards (eth0, eth1... ethx), their IP
> addresses, netmasks, etc.
> 
> I could do this by parsing the output of ifconfig, but for various reasons
> don't want to do that.  Is there any sort of low-level interface that I
> can access via Python to get this information?  I've looked through /proc
> to see if there was something I could read, but nothing that seems to
> contain the information I'm after.

I'd suggest browsing around in /proc/net/
My /proc/net/arp looked like it had most of the information you wanted,
I wasn't sure if the netmask there is the real netmask though.
/proc/sys/net/ also appears to contain useful information.

-- 
Shae Matijs Erisson - http://www.webwitches.com/~shae/
VirtualPairProgramming Wanted - Linux/Emacs/Python/Speak Freely
.fi: rakastan ohjelmointia - python kengittää aasia



More information about the Python-list mailing list