Date: Fri, 5 Jan 2001 08:38:53 -0600 From: GB/DEV - Doug Poland <doug.poland@omniresources.com> To: 'trini0' <trini0@optonline.net> Cc: FreeBSD Questions <questions@FreeBSD.ORG> Subject: RE: restarting or renewing dhclient Message-ID: <DF5018B3C986D11196FF0060089A903C32CCA7@gbdev.omniresource.com>
next in thread | raw e-mail | index | archive | help
trini0@optonline.net said...
>
> Ill be interested in what you have to offer.
> Yes please send it to me. Maybe its along
> the lines of what I had it mind.
> Thanks
>
> trini0@optonline.net
>
Here it is...
# crontab -l
# DO NOT EDIT THIS FILE - edit the master and reinstall.
# (/tmp/crontab.dmnXm19120 installed on Tue Dec 5 09:53:15 2000)
# (Cron version -- $FreeBSD: src/usr.sbin/cron/crontab/crontab.c,v 1.12
1999/08/28 01:15:52 peter Exp $)
#
*/2 * * * * /usr/local/bin/dhclient.refresh 2> /dev/null > /dev/null
------------ SNIP ---------------
#! /bin/csh
set ifname = 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.10.1.1 | grep "64 bytes from"` #non-existent
host for testing
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 $ifname down && killall dhclient && dhclient $ifname &&
ifconfig $ifname 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
------------ SNIP ---------------
--
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?DF5018B3C986D11196FF0060089A903C32CCA7>
