I have a few mount commands that I want to run on connecting to a specific network. So far I've tried using NetworkManager's dispatch functionality, inspecting the UUID:


if [ "${CONNECTION_UUID}" == "${uuid}" ]; then

That fails since the UUID of a connection seems to change on reboot. (I've verified that the script works if I modify the UUID to match the current one, then bring down the network, then bring it up again).

Is NetworkManager even the correct tool to use for this?


This question suggests exactly what you are doing, so it's interesting that the UUID seems to change on reboot.

However, one of the comments mentions another method. Put a script in /etc/network/if-up.d, and it should run every time you connect to a network. You can put in something like iwconfig | grep -q "some SSID" to test whether you are connected to a specific network (maybe you could use MAC address as well).

  • Yeah that is interesting, I think I'll have to dig deeper into this. The one obvious thing that differs is that the network I'm connecting to is wired. I don't know if that is what causes the UUID to change each time. – Magnus Apr 27 '14 at 7:37
  • 1
    One of the comments (askubuntu.com/questions/13963/…) hints at the answer: in order to not have the UUID change on each reboot I had to configure the wired connection rather than rely on the transient, automatically created config. – Magnus Apr 28 '14 at 7:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.