Idea for dynamic DNS (e.g. you have DHCP on your WAN at home): instead of polling every 5 minutes: what's my IP? has it changed?

What about scripting something with devd.conf(5) for ADDR_ADD / ADDR_DEL? i.e. catchthe event and launch a script to set DNS.

https://man.freebsd.org/cgi/man.cgi?query=devd.conf&sektion=5

devd.conf(5)

@dvl I've been using /etc/dhclient-exit-hooks for that at home.

[ ."$reason" = .BOUND ] and [ ."$reason" = .RENEW ] will pass the new IP to a shellscript that updates my records at bunny.net DNS via their REST API.

@sko That sounds familiar. I'm searching for documentation on dhclient hooks and failing. No mention of hook on dhclient or dhclient man pages.
@dvl True, the dhclient manpage is completely silent about those hooks and where to find them. The correct manpage is only mentioned in the "SEE ALSO" section: dhclient-script(8)
https://man.freebsd.org/cgi/man.cgi?dhclient-script
dhclient-script

@sko On #FreeBSD 14.2, I found /sbin/dhclient-script which seems rather complete. I could copy that, add to my world domination plans, ..., profit.

@dvl usually you don't (and shouldn't) touch /sbin/dhclient-script. That script is invoked by dhclient and it sources /etc/dhclient-enter-hooks and /etc/dhclient-exit-hooks - those are the files you want to use to add custom behavior and e.g. run your own scripts to which you can pass the variables set by dhclient (e.g. $new_ip_address).

e.g. I'm calling my ddns script from /etc/dhclient-exit-hooks as follows:

[ ."$reason" = .BOUND ] && /usr/home/sko/bunny_ddns.sh -n <recordID> -i $new_ip_address -k <APIkey> -z <zoneID>

that script then basically just mangles the input data into a curl POST request for the API.

I always wanted to look into using the "EXPIRE", "FAIL" and "TIMEOUT" reasons to switch over to a fallback uplink...

@sko Now I'm ready to write /etc/dhclient-exit-hooks
When my home DHCP address changes, I want stuff done – Dan Langille's Other Diary