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
3 # get pid of udhcpc
4 PID=`pidof udhcpc`
5 # renew dhcp lease
6 /bin/kill -SIGUSR1 $PID

1 Response to “Howto renew a DHCP lease”

  1. 1 whammofriz March 25, 2015 at 5:55 pm

    Thank you. This may have saved my company a lot of trouble.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: