Linux Force DHCP Client (dhclient) to Renew IP Address

I am using Ubuntu Linux. How to force Linux to reacquire a new IP address from the DHCP server? What is the command of Linux equivalent to Windows’s “ipconfig /renew” command?

You need to use Dynamic Host Configuration Protocol Client i.e., dhclient command. The client normally doesn’t release the current lease as it is not required by the DHCP protocol. Some cable ISPs require their clients to notify the server if they wish to release an assigned IP address. The dhclient command, provides a means for configuring one or more network interfaces using the Dynamic Host Configuration Protocol, BOOTP protocol, or if these protocols fail, by statically assigning an address.

Linux renew ip command using dhcp

The -r flag explicitly releases the current lease, and once the lease has been released, the client exits. For example, open terminal application and type the command:
$ sudo dhclient -r
Now obtain fresh IP address using DHCP on Linux:
$ sudo dhclient

How can I renew or release an IP in Linux for eth0?

To renew or release an IP address for the eth0 interface, enter:
$ sudo dhclient -r eth0
$ sudo dhclient eth0

In this example, I am renewing an IP address for my wireless interface:

sudo dhclient -v -r eth0
sudo dhclient -v eth0

sudo dhclient -v -r eth0
sudo dhclient -v eth0

Sample outputs:

Fig.01: Renew DHCP address example

The -v option shows information on screen about dhcp server and obtained lease.

Other options in Linux to renew dhcp

There is no need to restart network service. Above command should work with any Linux distro such as RHEL, Fedora, CentOS, Ubuntu and others. On a related note you can also try out the following commands:
# ifdown eth0
# ifup eth0
### RHEL/CentOS/Fedora specific command ###
# /etc/init.d/network restart

### Debian / Ubuntu Linux specific command ###
# /etc/init.d/networking restart

nmcli command (NetworkManager) to renew IP address in Linux

The NetworkManager daemon attempts to make networking configuration and operation as painless and automatic as possible by managing the primary network connection and other network interfaces, like Ethernet, WiFi, and Mobile Broadband devices command-line tool for controlling NetworkManager. The nmcli is a command-line tool for controlling NetworkManager and getting its status. To renew IP address using nmcli for connection named ‘nixcraft_5G’ (use ‘nmcli con‘ command to get list of all connections):

nmcli con
nmcli con down id 'nixcraft_5G'
nmcli con up id 'nixcraft_5G'

nmcli con
nmcli con down id ‘nixcraft_5G’
nmcli con up id ‘nixcraft_5G’

Sample outputs:

Fig.02: nmcli command in action

Linux Force dhclient to renew IP address on a CentOS 7/Ubuntu/Debian and other Linux-based server

Most modern Linux-based system uses the systemd as a init system and here is how to force Linux to renew IP address using DHCP. Use the ip command to find out the current IP address:
ip a
ip a s eth0

dhclient -v -r eth0
OR use the systemctl command to restart network service on a CentOS 7:
systemctl restart network.service
systemctl status network.service

Conclusion: Linux force DHCP client to release and renew an IP address
Command Command to release/renew a DHCP IP address in Linux
ip a Get ip address and interface information on Linux
ip a s eth0 Find the current ip address for the eth0 interface in Linux
Method #1
dhclient -v -r eth0 Force Linux to renew IP address using a DHCP for eth0 interface
Method #2
systemctl restart network.service Restart networking service and obtain a new IP address via DHCP on Ubuntu/Debian Linux
systemctl restart networking.service Restart networking service and obtain a new IP address via DHCP on a CentOS/RHEL/Fedora Linux
Method #3
nmcli con Use NetworkManager to obtain info about Linux IP address and interfaces
nmcli con down id 'enp6s0' Take down Linux interface enp6s0 and release IP address in Linux
nmcli con up id 'enp6s0' Obtian a new IP address for Linux interface enp6s0 and release IP address using DHCP
  • Man pages: dhclient(8)

Posted by: SXI ADMIN

The author is the creator of SXI LLC and a seasoned sysadmin, DevOps engineer, and a trainer for the Linux operating system/Unix shell scripting. Get the latest tutorials on SysAdmin, Linux/Unix and open source topics via RSS/XML feed or weekly email newsletter.

Leave a Reply

Your email address will not be published. Required fields are marked *

Previous Post

How to Make Website WCAG Compliant?

Next Post

Link download Kali Linux 2020.1 (ISO + Torrent)

Related Posts