Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Accessing NIC configuration via Python

0 views
Skip to first unread message

Micheal Kelly

unread,
Jul 31, 2000, 3:00:00 AM7/31/00
to
Hoping someone can help:

Earlier I posted a message asking how to access low-level Linux network
information in Python - Shae Erisson was kind enough to point out gnetstat
(http://www.linuxcare.com.au/projects/gnetstat) to me...

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.

Help! :)

- Mike K.


Jürgen Hermann

unread,
Jul 31, 2000, 3:00:00 AM7/31/00
to

"Micheal Kelly" <mich...@newlix.com> schrieb im Newsbeitrag
news:8Rfh5.23380$07.9...@news1.rdc1.on.wave.home.com...

> 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.

SIOCGIFADDR via ioctl() on a socket() (which does not have to be connected).
Was mentioned in several news articles in the last two weeks.

Bye, Jürgen

Shae Erisson

unread,
Jul 31, 2000, 3:00:00 AM7/31/00
to
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

0 new messages