views:

500

answers:

1

How can I do the following things in python:

  1. List all the IP interfaces on the current machine.
  2. Receive updates about changes in network interfaces (goes up, goes down, changes IP address).

Any python package available in Ubuntu Hardy will do.

+3  A: 

I think the best way to do this is via dbus-python.

The tutorial touches on network interfaces a little bit:

import dbus
bus = dbus.SystemBus()
proxy = bus.get_object('org.freedesktop.NetworkManager',
                       '/org/freedesktop/NetworkManager/Devices/eth0')
# proxy is a dbus.proxies.ProxyObject
Otto Allmendinger