Howto renew a DHCP lease

A feature that most Windows users are missing on linux is ipconfig /renew to renew the DHCP lease.

There is a similar command ifconfig on linux that is used to configure the network interfaces. It has no renew option because ifconfig has nothing to do with DHCP.

There are different DHCP client implementations available. I’m using udhcpc (Micro DHCP Client) in conjunction with ifplug daemon which starts automatically the DHCP client software when a cable is plugged in and stops it when it’s unplugged. So renewing can be done by unplugging and plugging again.

But there is also a much simpler possibility. Udhcpc can be forced to renew the lease by receiving the SIGUSR1 signal. This can be done by kill -SIGUSR1 <PID>. To automate the process you can use this script.

1 #!/bin/sh
2 
3 # get pid of udhcpc
4 PID=`pidof udhcpc`
5 # renew dhcp lease
6 /bin/kill -SIGUSR1 $PID

~ by gergap on August 13, 2008.

Leave a Reply