What's new
  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

Execute script after DHCPv6 lease renewal?

i0ntempest

Regular Contributor
Is there a simple way to execute a script after odhcp6c client renews its lease? Reason I ask this is because I have a ULA range setup in my network and every time odhcp6c renews its lease my ULA prefix on br0 gets cleared. This renew does not appear to trigger any user scripts.
I know that odhcp6c executes /tmp/dhcp6c (a symlink to rc) for status updates, but the arguments passed to odhcp6c seems to be hardcoded into the rc binary so there’s no simple way to change it.
I have a BE88U running latest Merlin firmware (3006).
Thanks in advance.
 
I’m not running 3006.103, but you should be able to use /jffs/scripts/dhcpc-event to capture the event (updated, bound, ra-updated, etc.) and the IP protocol (4 or 6).
Code:
Feb  9 19:09:50 custom_script: Running /jffs/scripts/dhcpc-event (args: updated 6)
Feb 10 06:30:01 custom_script: Running /jffs/scripts/dhcpc-event (args: renew 4)
Feb 11 19:09:52 custom_script: Running /jffs/scripts/dhcpc-event (args: updated 6)
Feb 12 06:30:01 custom_script: Running /jffs/scripts/dhcpc-event (args: renew 4)
Feb 13 19:09:54 custom_script: Running /jffs/scripts/dhcpc-event (args: updated 6)
Feb 14 06:30:01 custom_script: Running /jffs/scripts/dhcpc-event (args: renew 4)
Feb 15 19:09:56 custom_script: Running /jffs/scripts/dhcpc-event (args: updated 6)
Feb 16 06:30:01 custom_script: Running /jffs/scripts/dhcpc-event (args: renew 4)
Feb 17 19:09:57 custom_script: Running /jffs/scripts/dhcpc-event (args: updated 6)
Feb 18 06:30:01 custom_script: Running /jffs/scripts/dhcpc-event (args: renew 4)
Feb 19 19:10:01 custom_script: Running /jffs/scripts/dhcpc-event (args: updated 6)
Feb 20 06:30:02 custom_script: Running /jffs/scripts/dhcpc-event (args: renew 4)
Feb 21 19:10:03 custom_script: Running /jffs/scripts/dhcpc-event (args: updated 6)
Feb 22 06:30:02 custom_script: Running /jffs/scripts/dhcpc-event (args: renew 4)
 
I’m not running 3006.103, but you should be able to use /jffs/scripts/dhcpc-event to capture the event (updated, bound, ra-updated, etc.) and the IP protocol (4 or 6).
I didn’t try but the official documentation says this works only with udhcpc, no mention of odhcp6c. You sure it’s going to work with DHCPv6?
 
I didn’t try but the official documentation says this works only with udhcpc, no mention of odhcp6c. You sure it’s going to work with DHCPv6?
Here’s the code behind /tmp/dhcp6c

I also updated my earlier post to show logs of it being invoked when my DHCPv6 lease is updated.
 
Here’s the code behind /tmp/dhcp6c

I also updated my earlier post to show logs of it being invoked when my DHCPv6 lease is updated.
Thank you. Based on your reply I have created dhcpc-event script with content:
Bash:
#!/bin/sh
if ([ "$1" = "bound" ] || [ "$1" = "updated" ] || [ "$1" = "rebound" ]) && [ "$2" = "6" ]; then
    ip -6 addr add dev br0 fd00:d:e:f::1/64
fi
But this does not seem to work, the prefix still gets cleared. In the syslog this is what happens when v6 gets renewed:
Code:
Feb 24 15:35:04 odhcp6c[5183]: Server returned message status 0 
Feb 24 15:35:04 custom_script: Running /jffs/scripts/dhcpc-event (args: updated 6)
Feb 24 15:35:04 custom_script: Running /jffs/scripts/dhcpc-event (args: renew 4)
If `/tmp/dhcp6c updated` is the only thing that was executed when v6 lease renews, then looking at the code, there should be no `ip -6 addr flush` command issued, but there clearly is. That aside, the script seems to be executed too early so that the flush happens after the script. I guess adding a 5s delay to the `ip -6 addr add` would work, but is there a better way?
 

Similar threads

Latest threads

Support SNBForums w/ Amazon

If you'd like to support SNBForums, just use this link and buy anything on Amazon. Thanks!

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Back
Top