Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 4 Jul 2000 22:57:40 -0400 (EDT)
From:      Brian Dean <bsd@bsdhome.com>
To:        Doug Barton <DougB@gorean.org>
Cc:        Greg Lehey <grog@lemis.com>, Samuel Tardieu <sam@inf.enst.fr>, current@FreeBSD.ORG
Subject:   Re: DHCP does not honor default router?
Message-ID:  <Pine.BSF.4.21.0007042240200.274-100000@vger.bsdhome.com>
In-Reply-To: <3962845C.F195E50D@gorean.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Tue, 4 Jul 2000, Doug Barton wrote:

> 	I updated my dhclient script to handle this case, since it
> happens on the roadrunner network as well. I can send you the patch
> if you want, but I have a lot of other hacks in my script so it
> might be confusing.  Starting right around line 106 of the default
> script, I have:

A hook is already provided for this kind of thing.  You can create a
separate program called /etc/dhclient-exit-hooks, which get run at
various times by dhclient-script.  Since /etc/dhclient-exit-hooks is
sourced by /sbin/dhclient-script, you have access to all of its
internal variables, such as '$reason', '$old_ip_address',
'$new_ip_address', etc.

Thus, you don't have to maintain a separate /sbin/dhclient-script like
you do now.

Also, if you run a firewall, you should re-instantiate your rules with
the new IP address here as well.  Mine (which is still evolving) looks
something like this:

------------------------------------------------------------
#!/bin/sh
# 
# File: /etc/dhclient-exit-hooks
#

# redirect to syslog
logger="/usr/bin/logger -t dhclient-exit-hooks -i"

checkit ( ) {
  /bin/echo "REASON=$reason  OLDIP=$old_ip_address  NEWIP=$new_ip_address"
  if [ -z "$old_ip_address" ] || [ -z "$new_ip_address" ]; then
    /bin/echo "old and/or new is empty"
  elif [ "$old_ip_address" != "$new_ip_address" ]; then
    /bin/echo "flushing ARP tables"
    /usr/sbin/arp -d -a
    /bin/echo "re-establishing firewall rules"
    . /etc/rc.firewall.local
  fi
}

checkit | $logger
------------------------------------------------------------

I notice you also flush the routing table.  Is that necessary - it
appears that dhclient-script does this when it's needed?

I found this exit hook feature by looking at the source for
dhclient-script, but, oddly enough, it is even documented in the man
page.

-Brian



To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-current" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.4.21.0007042240200.274-100000>