How to Release and Renew IP Address from DHCP Server in Linux

This post will guide you how to renew or release a dynamic IP address from DHCP server for your current Linux Operating system. How do I force a Linux DHCP client to get a different IP address from DHCP server using dhclient command in the CentOS or RHEL or Ubuntu Linux system.

renew ip address linux1

Dhclient Command


The Internet Systems Consortium DHCP Client, dhclient, 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.

The syntax of the dhclient command is as followss:

dhclient [ -4 | -6 ] [ -S ] [ -N [ -N... ] ] [ -T [ -T... ] ] [ -P [ -P... ] ] -R ] [ -i ] [ -I ] [ -4o6
port ] [ -D LL|LLT ] [ -p port-number ] [ -d ] [ -df duid-lease-file ] [ -e VAR=value ] [ -q ] [ -1 ] [ -r | -x
] [ -lf lease-file ] [ -pf pid-file ] [ --no-pid ] [ -cf config-file ] [ -sf script-file ] [ -s server-addr ] [
-g relay ] [ -n ] [ -nw ] [ -w ] [ -nc ] [ -B ] [ -C dhcp-client-identifier ] [ -H host-name ] [ -F fqdn.fqdn ]
[ -V vendor-class-identifier ] [ --request-options request-option-list ] [ --timeout timeout ] [ --dad-wait-
time seconds ] [ -v ] [ --version ] [ if0 [ ...ifN ] ]

Option:

-r Release the current lease and stop the running DHCP client as previously recorded in the PID file. When
shutdown via this method dhclient-script will be executed with the specific reason for calling the
script set. The client normally doesn't release the current lease as this is not required by the DHCP
protocol but some cable ISPs require their clients to notify the server if they wish to release an
assigned IP address.

-v     Enable verbose log messages.

Renew IP Address


If you want to renew an IP address for all network interfaces in your Linux system, and you just need to pass the “-r” option to the dhclient command, type:

$ sudo dhclient  -v -r

Outputs:

root@localhost devops]# dhclient -v -r
Internet Systems Consortium DHCP Client 4.2.5
Copyright 2004-2013 Internet Systems Consortium.
All rights reserved.
For info, please visit https://www.isc.org/software/dhcp/

Listening on LPF/virbr0-nic/52:54:00:fa:ee:e9
Sending on LPF/virbr0-nic/52:54:00:fa:ee:e9
Listening on LPF/virbr0/52:54:00:fa:ee:e9
Sending on LPF/virbr0/52:54:00:fa:ee:e9
Listening on LPF/enp0s3/08:00:27:4e:b2:00
Sending on LPF/enp0s3/08:00:27:4e:b2:00
Sending on Socket/fallback
DHCPRELEASE on enp0s3 to 192.168.3.43 port 67

If you only want to renew an IP address for a specified network interfaces (enp0s3), just type:

$ sudo dhclient -r -v  enp0s3

You can also restart network service to renew an IP Address for network interfaces in Linux system.

For CentOS/RHEL Linux:

$ sudo systemctl restart network.service

For Ubuntu Linux:

$ sudo systemctl restart networking

Conclusion


You should know that how to release and renew IP address from DHCP using dhclient command or restartinng network service in CentOS or RHEL or Ubuntu Linux systems.

You might also like:

Sidebar



back to top