From owner-freebsd-questions Thu Oct 11 19:58:21 2001 Delivered-To: freebsd-questions@freebsd.org Received: from gbdev.omniresources.com (gbdev.omniresource.com [207.170.33.100]) by hub.freebsd.org (Postfix) with ESMTP id 09A8E37B408 for ; Thu, 11 Oct 2001 19:58:18 -0700 (PDT) Received: from canaan.omniresources.com ([207.170.33.110]) by gbdev.omniresources.com with Microsoft SMTPSVC(5.5.1877.197.19); Thu, 11 Oct 2001 21:54:00 -0500 Received: (from dpoland@localhost) by canaan.omniresources.com (8.11.6/8.11.4) id f9C2x7b02680; Thu, 11 Oct 2001 21:59:07 -0500 (CDT) (envelope-from dpoland) Date: Thu, 11 Oct 2001 21:59:07 -0500 From: Doug Poland To: steve fox Cc: questions@freebsd.org Subject: Re: DHCP posting on freebsd.org Message-ID: <20011011215907.C2454@omniresources.com> References: <200110112301.f9BN1Kx02612@mail.webhelp.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200110112301.f9BN1Kx02612@mail.webhelp.com> User-Agent: Mutt/1.3.20i Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Thu, Oct 11, 2001 at 06:01:30PM -0500, steve fox wrote: > Hello, > > I came across your post (dated: 4 Jan 2001) today concerning cable modem use > and dhclient behavior. > > I, too, lose all connectivity after a short period of time. I would be > interested to see the script you created so as to maintain uninterrupted > service. > > Here's the link of the posting: > > http://www.FreeBSD.org/cgi/getmsg.cgi?fetch=1671150+1673635+/usr/local/www/db/text/2001/freebsd-questions/20010107.freebsd-questions > > Thanks so much, Steve, I was launching this from cron. Hope it helps... #! /bin/csh set dhcp-if = ed0 set dns = `grep nameserver /etc/resolv.conf | head -1 | awk '{print $2}' -` set alive = `ping -c1 $dns | grep "64 bytes from"` # set alive = `ping -c1 10.20.1.55 | grep "64 bytes from"` if ( $#alive > 0 ) then logger connectivity established with $dns else logger -t DHCLIENT attempting to re-establish inet connectivity with $dns set leasefile = /var/db/dhclient.leases @ lease = `grep -n ^lease /var/db/dhclient.leases | tail -1 | awk -F: '{print $1}' - ` @ len = `wc $leasefile | awk '{print $1}' - ` @ tail = $len - $lease tail -$tail $leasefile > /tmp/lease logger -t ...dhclient -f /tmp/lease ifconfig $dhcp-if down && killall dhclient && dhclient $dhcp-if && ifconfig $dhcp-if up set dns = `grep nameserver /etc/resolv.conf | head -1 | awk '{print $2}' -` set alive = `ping -c1 $dns | grep "64 bytes from"` if ( $#alive > 0 ) then logger -t DHCLIENT connectivity re-established with $dns else logger -t DHCLIENT could not re-establish connectivity, exiting endif endif -- Regards, Doug To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message