Playing with dhclient


Sometimes one is faced with a difficult task - a backup link that requires DHCP to configure the interface. In itself, the task does not seem hard. The devil, however, is in the detail. The backup link default route(s) should not be inserted into the default routing table, but rather into a separate table.

The goal is to modify dhclient to do what we want while still being able to upgrade the package with security updates without extra work.


Upon every event dhclient runs /sbin/dhclient-script. This script is responsible for configuring the interface and adding routes according to the obtained lease. On release, it does the opposite.

Before dhclient-script does anything, it sources /etc/dhcp3/dhclient-enter-hooks and runs scripts in /etc/dhcp3/dhclient-enter-hooks.d


This is where we hijack the process. On Debian, only the dhclient-enter-hooks.d directory exists, the script dhclient-enter-hooks is not present. We copy /sbin/dhclient-script, and throw out much of the useless stuff (or add more, if that's your thing, but in that case there is probably no need to suppress the default processing, just use a normal hook :)


Unfortunately, the script requires sipcalc to calculate the prefix length of the connected segment from numeric netmask which is received from dhclient. I would be more than happy to replace it if someone came up with a simple solution in shell :)

linux/isc_dhcp_client_customizing.txt · Last modified: 2010/01/08 02:42 by b
CC Attribution-Share Alike 4.0 International
Driven by DokuWiki Recent changes RSS feed Valid CSS Valid XHTML 1.0 ipv6 ready