How to setup hotplug to do dynamic DNS

After looking at the docs for hotplug ( and the forum I am still not sure how to do this.

My public IPv4 is dynamic and my WAN interface is set to DHCP client. What I want to do is when the DHCP lease is renewed then a script is executed with a hit on my DNS server's API with the new IPv4 that has been assigned.

From what I understand it's a matter of adding a shell script in the corresponding folder in /etc/hotplug.d. But my first question is what is the corresponding folder for the DHCP client, which I believe is udhcpc? And how can I know what that folder should be?

Then I understand I need to match an action that would trigger a command. So in this case I guess the action would be renew but I'm not sure and again, I don't know how I can find this information.
And last, the command that I want to execute needs the new IPv4 address that has been assigned. I guess this is something I can find in the environment variables that are passed to the script but what is this variable called?

Thanks a lot for any help!

1 Like

Are you aware of ddns package?


More specifically, the update_script configuration option for ddns-scripts.

Here is a sample script:

1 Like

Thanks for the suggestions.
I am aware of the ddns package. But I'm really interested in the hotplug framework, I only lack a tiny bit of information to get it to work.

I could spot some reference to hotplug in the link but it is not very clear how it is used.

I'll keep looking.

So, if you want to script this from the ground up, why not just drop a script into /etc/hotplug.d/iface/ with content like this:

/usr/bin/env > /tmp/envs_${INTERFACE}_${DEVICE}_${ACTION}.log

Then you see, which variables you get, and can write a script to react accordingly

that's interesting! thanks.

So the right folder to catch the dhcp client actions should be iface?

I'll try and see what I can get from it. I'll also try to artificially trigger a dhcp renew without triggering other actions.