From owner-freebsd-current Tue Jul 4 19:58: 1 2000 Delivered-To: freebsd-current@freebsd.org Received: from bsdhome.dyndns.org (rdu162-228-096.nc.rr.com [24.162.228.96]) by hub.freebsd.org (Postfix) with ESMTP id 1AAC237BB69 for ; Tue, 4 Jul 2000 19:57:49 -0700 (PDT) (envelope-from bsd@bsdhome.com) Received: from vger.bsdhome.com (vger [192.168.220.2]) by bsdhome.dyndns.org (8.9.3/8.9.3) with ESMTP id WAA46699; Tue, 4 Jul 2000 22:57:41 -0400 (EDT) (envelope-from bsd@bsdhome.com) Received: from localhost (bsd@localhost) by vger.bsdhome.com (8.9.3/8.9.3) with ESMTP id WAA00321; Tue, 4 Jul 2000 22:57:40 -0400 (EDT) (envelope-from bsd@vger.bsdhome.com) Date: Tue, 4 Jul 2000 22:57:40 -0400 (EDT) From: Brian Dean To: Doug Barton Cc: Greg Lehey , Samuel Tardieu , current@FreeBSD.ORG Subject: Re: DHCP does not honor default router? In-Reply-To: <3962845C.F195E50D@gorean.org> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG 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