Alex Rivera | Logout

Get notified about network interface change on Linux

Asked 2010-02-14T16:22:17.667
24

I need a way to notify my user space app when a network interface is enabled or disabled. I'm hoping to do this without resorting to polling. Does the kernel offer some sort of hook for triggering callback functions when network-related events occur?

Edit
Report

1 Answer

12

Options:

  • ifplugd will run the script of your choice when a cable is plugged into or unplugged from your network interface.

  • If you are using Debian you can add a script to the subdirectories of /etc/network, where there are scripts that are run every time an interface goes up or down.

  • If neither of the above are suitable for your needs, look into D-Bus. I've never had much luck using it successfully, but this is the sort of thing it was designed for.

answered 2010-02-14T16:27:58.703

Your Answer