How do I run a script when ip-address changes (most likely using a dhclient hook) on a (Ubuntu) Linux machine?

I have a script which contacts a few sources and tell them "the IP-address XXX.XXX.XXX.XXX is my current one". My test web server has a dynamic IP-address through DHCP and amongst other things it needs to update a DDNS entry when its IP-address changes. However it's not the only thing it does, so I will need to run my own custom script.

I suspect that this is possible by a attaching the script to be run for a given dhclient hook. However I still need to know which hook I should use, and how.


I would recommend to put the script into dhclient-exit-hooks.d. Because you should just change the DDNS entry, if the address change has been finished. However, I am not sure if dhclient-exit-hooks are called, if assigning an address fails.

Edit: The man pages (man dhclient-script) says, that the exit-hooks script will get the exit code in a shell variable (exit_status). So you could check it.

Need Your Help

IO Operation is blocking my UI Thread and also another Background Thread

c# multithreading

I am a novice in Threads, but I want to know how to order thread execution in my scenario, and is the following :

time complexity for the given recursive equation

performance recursion big-o time-complexity

Hi can i know what would be the Big Oh time complexity for the given recursive equation