rc.conf defaultrouter="x.x.x.x" is overwritten by dhcp

Hello, in my rc.conf file I have configuration items of:

ifconfig_re0="inet X.X.X.X netmask media 100baseTX mediaopt full-duplex"

I had "thought" that similar to trying to add a default route at the command line, if the route already existed (by our setting it in the config file using defaultrotuer) and DHCP tried to set it, it would fail.

But DHCP must actually delete the default route and re-add the one it "wants". On the other hand, it isn't working to add the defaultrouter line after the dhcp pull, presumably because the default router already exists at that point, and, just like by hand, it fails to overwrite it.

Anyone know how to prevent DHCP from either over-writing the first route, or, how to do a 'route delete default' in the rc.conf file on the dhcp added default route?



Staff member
Create a script called /etc/dhclient-enter-hooks:
add_new_routes() {
   return 0

delete_old_routes () {
    return 0

That will prevent dhclient from deleting and adding routes. Have a look at /sbin/dhclient-script. You can redefine all the functions in dhclient-enter-hooks.
Thank you sir. Before I read this, I actually did the thing I should have done in the first place:

1. I removed the IP address for this machine from DHCP
2. Added a static route on the card