views:

480

answers:

2

Hi,

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.

A: 

Why not just run a cron job at the desired resolution (down to one minute) or have a job run continuously that tests the current IP address against a stored one and, if it changes, run your script and store the new one?

paxdiablo
It's certainly a working solution and something to fall back on to, if I can't get my prefered way to work. In my opinion reacting to the event is a more elegant solution.
DeletedAccount
+3  A: 

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.

ManuelFuenfrocken