How to Force DHCP Lease Renewal on Ubuntu Server: A Sysadmin’s Guide


2 views

For most Ubuntu Server users, renewing a DHCP-assigned IP address is straightforward:

sudo dhclient -r [interface]
sudo dhclient [interface]

Replace [interface] with your actual network interface (e.g., eth0, ens33). The -r flag releases the current lease before requesting a new one.

DHCP leases have a specific lifecycle in Ubuntu:

  • Initial lease acquisition (DHCPDISCOVER, DHCPOFFER, DHCPREQUEST, DHCPACK)
  • Regular lease renewal (typically at 50% of lease time)
  • Rebinding (at 87.5% of lease time)
  • Expiration

For systemd-based Ubuntu installations (17.04 and later):

sudo networkctl renew [interface]

To completely flush all network configurations before renewal:

sudo ifdown [interface] && sudo ifup [interface]

Edit /etc/dhcp/dhclient.conf to customize renewal behavior. Example configuration:

# Request specific options from DHCP server
request subnet-mask, broadcast-address, routers, domain-name-servers;

# Set timeout values
timeout 60;
retry 60;
reboot 10;
select-timeout 5;
initial-interval 2;

Check current lease information:

cat /var/lib/dhcp/dhclient.leases

Monitor DHCP traffic for debugging:

sudo tcpdump -i [interface] port 67 or port 68 -vv

Create a cron job for regular renewal (not typically needed but useful in some cases):

# Add to crontab (crontab -e)
0 3 * * * /sbin/dhclient -r [interface] && /sbin/dhclient [interface]

In Ubuntu server environments, DHCP-assigned IP addresses come with a lease duration. When you need to immediately acquire a fresh IP configuration, manual renewal becomes necessary - particularly useful when network changes occur or when troubleshooting connectivity issues.

The most reliable way to force a DHCP renewal involves releasing the current lease before requesting a new one:

sudo dhclient -r [interface_name]  # Release current lease
sudo dhclient [interface_name]     # Request new lease

For example, to renew the IP on eth0:

sudo dhclient -r eth0 && sudo dhclient eth0

For systems using NetworkManager (less common on servers):

sudo nmcli con down "Connection Name" && sudo nmcli con up "Connection Name"

For systems with netplan:

sudo netplan apply

After renewal, confirm your new IP assignment:

ip addr show [interface_name]
# or
ifconfig [interface_name]

If renewal fails, check DHCP server availability:

ping [your_dhcp_server_ip]

Inspect DHCP client logs:

journalctl -u systemd-networkd | grep DHCP
# or
cat /var/log/syslog | grep dhclient

For regular lease refreshes (useful in dynamic environments):

# Add to crontab -e
0 */6 * * * /sbin/dhclient -r eth0 && /sbin/dhclient eth0