From owner-freebsd-questions Fri Jan 5 6:39: 6 2001 From owner-freebsd-questions@FreeBSD.ORG Fri Jan 5 06:39:03 2001 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from webhost.omniresource.com (www.omniresource.com [207.170.23.21]) by hub.freebsd.org (Postfix) with ESMTP id 1BC6637B400 for ; Fri, 5 Jan 2001 06:39:03 -0800 (PST) Received: by WEBHϪϪOST with Internet Mail Service (5.5.2650.21) id ; Fri, 5 Jan 2001 08:37:26 -0600 Message-ID: From: GB/DEV - Doug Poland To: 'trini0' Cc: FreeBSD Questions Subject: RE: restarting or renewing dhclient Date: Fri, 5 Jan 2001 08:38:53 -0600 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2650.21) Content-Type: text/plain Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG 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