Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 11 Jul 2002 23:43:52 -0600
From:      Andy <seahorse51@attbi.com>
To:        Mikel King <mikel@ocsinternet.com>, nascar24 <nascar24@home.nl>
Cc:        net@FreeBSD.ORG
Subject:   Re: DHCP lease renewal
Message-ID:  <5.1.0.14.0.20020711233932.0237f368@wsonline.net>
In-Reply-To: <3D2DD3BB.2010506@ocsinternet.com>
References:  <01c001c221dd$38127d20$0200a8c0@winxp>

next in thread | previous in thread | raw e-mail | index | archive | help
This is the script I use to accomplish this.  Just substitute the network 
card interface code with the one you wish to have renewed.

I run this every 24 hours, and have been able to keep the same IP address 
for going on 6 months now.  It also generates a handy Email to root when 
run from /etc/crontab, so that you can review the renewal information, 
verify your ifconfig settings for that network card, and your change in the 
IP lease.

#!/bin/sh
#
# Restart DHCLIENT and reconfigure ifconfig ...
#
SHELL=/bin/sh
PATH=/etc:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin
HOME=/var/log

echo " "
echo "************************************************************"
echo "Started DHCLIENT update:  `date \"+%Y-%m-%d %H:%M:%S\"`"
echo "************************************************************"
echo " "

kill -TERM `cat /var/run/dhclient.pid`
echo "DHCP Killed, restarting"
echo " "

/sbin/dhclient xl0
echo " "

sleep 10

ifconfig xl0
echo " "

more /var/db/dhclient.leases
echo " "

echo "************************************************************"
echo "Finished DHCLIENT update:  `date \"+%Y-%m-%d %H:%M:%S\"`"
echo "************************************************************"
echo " "



At 12:51 07/11/2002, Mikel King wrote:
>Not sure if you've found this already. One thing I used to do on an older 
>box was a simple cron job that ran a script which HUP'd the dhclient every 
>so often thus effectively renewing the lease...
>
>If memory serves me it went something like....
>
>    #!/bin/sh
>
>    kill -HUP `ps ax |awk '/dhclient/{print $1; exit}'`
>cheers,
>mikel
>
>nascar24 wrote:
>
>>Hallo,
>>
>>My FreeBSD 4.5-RELEASE machine is connected to the internet via a cable 
>>connection. And when booting (or running dhclient) I get an IP address. 
>>But when I have an IP address and my ISP wants to give me a new IP 
>>address I doesn't go the way it should. Because I don't get the new IP 
>>address, my machine continues to use the 'old' IP address. And when that 
>>happens I get an angry phone call from my ISP, and they shut me from 
>>internet for a day.
>>
>>So, how can I configure (dhclient.conf I guess) my machine so that it 
>>accepts this new IP address. I thought I would configure my machine so 
>>that it renews its lease every 10 hours. But I have read the man for 
>>dhclient.conf, dhcp-options and dhclient but I still am puzzled.
>>
>>Gr.
>>
>>Marcel.
>>
>
>Cheers,
>Mikel



To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-net" in the body of the message




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