Date: Fri, 05 Jan 2001 09:49:28 -0500 From: trini0 <trini0@optonline.net> To: GB/DEV - Doug Poland <doug.poland@omniresources.com>, FreeBSD Questions <questions@freebsd.org> Subject: Re: restarting or renewing dhclient Message-ID: <3A55DEF8.6ACACA28@optonline.net> References: <DF5018B3C986D11196FF0060089A903C32CCA7@gbdev.omniresource.com>
next in thread | previous in thread | raw e-mail | index | archive | help
Thanks, Ill give this a try.  Sure is more complicated than my
script.           :)
GB/DEV - Doug Poland wrote:
> 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
--
         _____________________________
         |          trini0           |
         |                           |
     / ) | Systems Administrator     |
    / /  | Network Engineer          |
   ( (   | email ==>                 |
 (((\ \> |/ )  trini0@optonline.net  |
 (\\\\ \_/ /_________________________|
  \       /
   \    _/
   /   /
  /   /
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?3A55DEF8.6ACACA28>
