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.

Answers


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

Using typescript for create a node module, and import it as a dependency: Duplicate identifier (TS2300)

node.js typescript node-modules tsd

I've created a project (named data_model) with some classes useful in my other projects.

In the .NET framework, why are there PointF (float) and no "PointD" (double)?

.net graphics floating-point double system.drawing

Can anyone explain why, in the .NET framework, there are PointF structures (using the single-precision float type) and no "PointD" (using the double-precision double type)?