Custom Script when reloading WAN DHCP

Started by grind, May 24, 2025, 12:12:42 AM

Previous topic - Next topic
Hi,

when I want to aquire a different WAN IP, my ISP requires a DHCPRELEASE packet. If there is none, I always get the same IP address.
Unfortunately, FreeBSD's early fork of openbsd's dhclient implementation doesn't have the '-r' option for that. So I installed isc-dhclient via FreeBSD package. I just need it to send that packet. Now I made the following shell script:

killall -9 dhclient
/usr/local/sbin/dhclient -4 -d -r vtnet3 -lf /var/db/dhclient.leases.vtnet3 -cf /var/etc/dhclient_wan.conf -sf /usr/local/sbin/dhclient-script
rm -f /var/db/dhclient.leases.vtnet3


After that, I click on "reload" at the opnsense Interfaces:Overview page.
My question is if it's possible to execute a custom script when clicking on the "reload" button. If that's not possible: How can I trigger the WAN DHCP "reload" from the CLI? Then I would just add that to my shell script.


The best would IMHO be to have this directly implemented in opnsense. After searching for it, I've seen that there was a PR already for that, but got never implemented: https://github.com/opnsense/core/pull/3275
So I guess this is not wanted.

Quote from: grind on May 24, 2025, 12:12:42 AMHow can I trigger the WAN DHCP "reload" from the CLI?
configctl interface reconfigure wan does the trick.