Flash Sale! to get a free eCookbook with our top 25 recipes.

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

Sample outputs:
Fig.01: Renew DHCP address example

Fig.01: Renew DHCP address exampleThe -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

OR
### 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'

Sample outputs:
Fig.02: nmcli command in action

Fig.02: nmcli command in action

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

Linux Force DHCP Client to renew IP address

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

Run:
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

CommandCommand to release/renew a DHCP IP address in Linux
ip aGet ip address and interface information on Linux
ip a s eth0Find the current ip address for the eth0 interface in Linux
Method #1
dhclient -v -r eth0Force Linux to renew IP address using a DHCP for eth0 interface
Method #2
systemctl restart network.serviceRestart networking service and obtain a new IP address via DHCP on Ubuntu/Debian Linux
systemctl restart networking.serviceRestart networking service and obtain a new IP address via DHCP on a CentOS/RHEL/Fedora Linux
Method #3
nmcli conUse 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)