Wednesday, May 8, 2013

running a script when the network connection status changes

There a number of things I'd like to do when my network status changes: for instance use a specific .ssh/config, or a specific synergy profile. Thanks to this post, I learned that NetworkManager made that easy. The trick is to place scripts in /etc/NetworkManager/dispatcher.d/ and use a switch case approach to detect what interface (eth0, wlan0, etc.) has changed and what's the new status (up, down, etc.). This is documented in NetworkManager's man page.

Incidentally, I also learned about the logger command, which allows to write messages to the /var/log/syslog log file.

No comments:

Post a Comment