Running scripts on network connection (if-up.d, if-down.d,if-pre-up.d,if-post-down.d)

On my previous post I described how to authenticate against web based logons after connecting to a particular SSID.  One of the problems I had was getting the script to actually run.  You should just be able to put a script in the /etc/network/if-up.d directory (on Debian based systems) and it should run when a network interface connects.  This wasn’t working for me and it seemed some other people were having issues too.

The solution to the problem turned out to be removing the file extension.  So the script that was named didn’t run, but the script named testscript did.  So if you are having similar problems you may want to try removing the file extension.

I am not sure if this is documented and expected behavior, or a bug.

One Response to “Running scripts on network connection (if-up.d, if-down.d,if-pre-up.d,if-post-down.d)”

  1. Khiya Says:

    Hello! I’m running Ubuntu 10.04 and this was exactly what I was trying to find out how to do. However, have you found any other reasons why a script would fail to run when saved in the if-up.d folder? I’ve saved my file, “testscript” in the right folder, I’ve included “!#/bin/sh” as the first line, I’ve not named it “”, and I’ve made sure to chmod +x it too. Nevertheless, when I switch wireless networks, my script doesn’t run (all it did was save a line of info from the command “ifconfig” into a text file in another folder.
    Do you happen to have any suggestions?


Leave a Reply