[RndTbl] dhclient-exit-hooks

Trevor Cordes trevor at tecnopolis.ca
Fri Jan 3 03:30:41 CST 2014


On 2014-01-02 Adam Thompson wrote:
> RTFM:  dhclient-script(8).

Been there, done that.  :-)  I tried to simplify my list posting a bit
by not getting too in depth.

> The exit hooks are supposed to get called at every step of the DHCP 
> process, and you should examine - at least - ${OPERATION} to
> determine what stage you're at before assuming that the new IP has
> already been assigned and bound to the interface.

I'm checking $reason, but only loosely as I originally could not guess
which of the 12 state changes I really cared about, so my scripts
re-evaluate the whole situation on nearly every state change.  Missing
ip address changes is *very bad* in my situation.

> In other words, what you're seeing is the expected (i.e. correct)
> behaviour.

I wish that were true.  It's very strange as my scripts indicated in
the logs that only one call to dhclient-exit-hooks was made when this
change happened (happened to be on a reboot).  Even if I was acting on
an interim state change, it should have triggered again on the final (I
guess BOUND?) state change, and so properly caught the IP change.  I do
not log the $reason, but I will start now.

I did find one new thing RTFMing again, since I wrote these scripts
they seem to have added /etc/dhcp/dhclient-up-hooks which may be a
better choice (can't think of why I would not have used that before).
That explicitly says it runs "after dhclient brings an interface UP
with a new IP address, subnet mask, and routes". That's exactly what I
want. If it captures all possible ways an IP can change, it may be
better than exit-hooks.

> ...or just put a DHCP server of your own in front of the system
> you're testing.  Changing the MAC address will cause the cable modem
> (usually) to stop forwarding packets after the 2nd change, at least
> until you reboot the cable modem.

Good idea, though a bit of a pain in my situation.  It would have to be
a router I control the DHCP server on (to delete entries), like a full
*nix box.  Not sure even custom router f/w lets you do that?
Definitely easier than the Shaw-fooling route.  PS I find Shaw modems
need a reboot on any NIC/MAC change, not just the 2nd.


More information about the Roundtable mailing list