Determine the IP address of an eth interface

Tim Golden tim.golden at viacom-outdoor.co.uk
Thu Jan 19 04:43:43 EST 2006


[billie]

| Hi all. I'm searching for a module that permits me to
| low-level interact
| with ethernet interfaces of my system.
| I would like to determine at least the first of the followings
values:
|
| 1 - IP address assigned to the interface
| 2 - subnet mask
| 3 - default gateway
| 4 - primary and secondary dns
| 5 - default wins server
| 6 - mac address
| 7 - broadcast address

Not a cross-platform solution (I doubt if there is one, strictly)
but you can use WMI on win32 to get most of what you want. I'm
not sure about the broadcast address, but some Googling around
might help to solve that:

(wmi module from http://timgolden.me.uk/python/wmi.html)

<code>
import wmi
c = wmi.WMI ()
for eth in c.Win32_NetworkAdapterConfiguration (IPEnabled=True):
  print eth

</code>

TJG




More information about the Python-list mailing list