Freebsd-8 dhclient script

SirDice

Administrator
Staff member
Administrator
Moderator
With a bit of coercing I managed to upgrade my firewall from 7.2-stable to 8. I have only one problem though. On 7.2-stable I used a /etc/dhclient-enter-hooks script to add two special routes after the lease was acquired. Unfortunately the 8 dhclient doesn't seem to support this anymore.

After looking through the dhclient and dhclient.conf man pages I did see an option "script" I might be able to use.

script "script-name";
The script statement is used to specify the pathname of the DHCP client configuration script. This script is used by the DHCP client to set each interface's initial configuration prior to requesting an address, to test the address once it has been offered, and to set the interface's final configuration once a lease has been acquired. If no lease is acquired, the script is used to test predefined leases, if any, and also called once if no valid lease can be identified. For more information, see dhclient.leases(5).

However, I can't find any info on how to actually use this. I need to set something after the lease has been obtained.

For reference, here's my old 7-stable dhclient-enter-hooks:
Code:
add_new_resolv_conf() {
        # We don't want /etc/resolv.conf changed
        # So this is an empty function
        return 0
}

add_new_routes() {
        route add -net 10.0.0.138 -iface $new_ip_address -cloning
        route add default 10.0.0.138
}

Anybody have any info on how to do this with the version of dhclient from freebsd-8?
 
Have you tried dhclient from ports? It may still support what you want. As an aside, is there no way to use dhclient.conf for what you want to do?

BTW, the manuals differ between the base system and the ports version, so maybe some combined insight might help ;)

dhclient-script(8)
dhclient-script(8)

The one from ports still has a HOOKS section.
 
Ah.. Brilliant. It looks like I can use the builtin dhclient. I just couldn't find any info. There's no mention of the dhclient-script man page in dhclient and/or dhclient.conf, just a reference to dhclient.leases.

Looks like I need to write something that checks $reason and based on that I should be able to set those route commands.
 
Yep, I had to scan my system for the existence of those manuals. They are in apropos output. I guess it just scans /usr/share/man.
 
I think the last line of the explanation of the "script" option in the dhclient.conf man page needs to refer to dhclient-script, not dhclient.leases.

On a related note (man page wise), the man page of route still mentions -cloning. The command itself however doesn't accept it. Thankfully my 'problem' works even without the -cloning option :e

Should I file PRs for those man pages?
 
Sure, I've had some good results with docs PRs (takes a while though ...)
 
Ha! BOOYA!

No need to write my own dhclient-script. As I read the man page it suddenly dawned on me, I read this before :stud

It already exists, duh! It's in /sbin/dhclient-script and it will get called by /sbin/dhclient. From there /etc/dhclient-enter-hooks gets called. And the reason mine didn't work was because of the route -cloning option that's not supported anymore x(

:beergrin
 
Back
Top