UNB/ CS/ David Bremner/ tags/ networking

This feed contains pages with tag "networking".

Like several people out there, I wanted to have user (non-root) scripts run when NM changed state.

I decided to write a quick python script to snoop the dbus, and call a function when an interface is brought up or down. Maybe somebody else will find this useful.

Instead of a director of scripts, just place a file called .nmdispatchrc in the home directory, containing python code which defines functions ifup and ifdown. e.g.

:def ifup(interface,*args)

   print 'interface '+interface 'brought up'

:def ifdown(interface,*args)

   print 'interface '+interface+ ' brought down'

The actual daemon is only slightly longer than the MIT license it is distributed under. You are looking at the only known documentation. You will need dbus-python

Posted Thu 13 Dec 2007 07:27:00 AM Tags: /tags/networking