Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 11 Oct 2001 21:59:07 -0500
From:      Doug Poland <dpoland@omniresources.com>
To:        steve fox <steve.fox@webhelp.com>
Cc:        questions@freebsd.org
Subject:   Re: DHCP posting on freebsd.org
Message-ID:  <20011011215907.C2454@omniresources.com>
In-Reply-To: <200110112301.f9BN1Kx02612@mail.webhelp.com>
References:  <200110112301.f9BN1Kx02612@mail.webhelp.com>

next in thread | previous in thread | raw e-mail | index | archive | help
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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20011011215907.C2454>