The may work, if the DHCP server honours it and clears the lease server side.
The problem is that you did it manually and lost the connection and control of the session.
You had to do it in a script, where you released it and asked immediately for a new one.
For extra security, you would run it in the background, though I am usually do it just running a script and it works.
Something as simple as this would be enough actually.
Not getting the static IP after having an active DHCP lease is a common problem in DHCP servers, or at least in ISC-DHCPD. Unfortunately, the ISC DHCPD code gives priority to leases over static addresses.
So while the lease is not released, does not expire, or is not manually deleted in the DHCP server, you won't get the (new) static IP address, and will get instead the same address in the lease over and over.
Apparently the rationale is to keep the new DHCP requests coherent with the old IP addresses that were given to the machine, according to the following link.
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 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
The flag explicitly releases the current lease, and once the lease has been released, the client exits. For example, open terminal and type the command:
Now obtain fresh IP:
How can I renew or release an IP in Linux for eth0?
To renew or release an IP address for the eth0 interface, enter:
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
The 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:
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 is a command-line tool for controlling NetworkManager and getting its status. To renew IP address using nmcli for connection named ‘nixcraft_5G’ (use ‘‘ 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'
- Man pages: nmcli(1),dhclient(8)
Posted by: Vivek Gite
The author is the creator of nixCraft 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.