Linux Force DHCP Client (dhclient) to Renew IP Address

last updated in Categories , , , , ,

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

Sample outputs:

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

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

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

Linux Force DHCP Client to renew IP address

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 eth0 Find 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.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: 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.


40 comment

  1. Hi,

    This worked great, I was having a bit of problems thought worked them out in the end, thought I would share.

    I unplugged the network cable, then plugged back in a couple minutes later. Couldn’t access network, tried dhclient -r command and didn’t work. Found that dhcpcd was still running, so done a killall -9 dhcpcd then executed dhclient…worked!

  2. Works for me on Ubuntu 9.04. It seems to me, that the network-manager does not notice the change. After sudo dhclient -r the command ifconfig eth0 shows no ip address at the interface. After sudo dhclient the command ifconfig eth0 shows an ip address again.

    Thank you

    1. Sure it has, depending on your dhcp server configuration. You can define how long one IP will be served to the same MAC address. Since you did not “change” your MAC address, the dhcp server might give you the same ip.

  3. I set up static DHCP assignments and then needed to switch my server over to DHCP. To do this remotely I simply put the two commands on a single line:

    dhclient -r; dhclient

    If you’ve set up the static DHCP to use the IP address that you’ve already given it then you shouldn’t become disconnected from your SSH session :)

  4. Well, it releases them, but when I renew it, it gives me the same ip back. I wanted a new IP. Is there way to force a NEW one?

    1. You need to tell the dhcp server to issue a different one, typically I dhcp server will if it can issue the same address.

      You may be able to tell it to forget what it last issued, or you can usually make a mapping between the mac address of your nic and the ip you want, but generally unless you do something on the server it wil reissue the same address.

      1. Usually a DHCP server maintains a list of the leases by assigned IP and the MAC (unique identifier) of the device who has the lease.

        If you don’t have access to the DHCP server in question, then the simplest way to get a new IP would be to change your device’s MAC somehow, as a DHCP server will usually give you your IP back since its still leased to you.

        If you have access to the server than you can simply delete the entry, however, if its the first IP unassiged on the list, you’ll get it again unless another device takes it or if you exlude the IP address.

        Hope this helps.

        1. With some wireless routers and network modems it is possible to assign a “soft” MAC address that is different from the actual hardware MAC address. This information is usually stored in nonvolatile Flash memory, so it will survive a power-down and restart of the device. The pool of MAC addresses is finite, and there’s a slim chance if you just make one up, you could duplicate another one somewhere on the network. The best way to avoid it is rummage through your junk pile for an old network interface card (NIC) or cast-off computer with built-in NIC and “borrow” its MAC address. Blocks of MAC addresses are assigned by manufacturer and a given manufacturer normally won’t use the same MAC address twice. (However, I ran across a post within the last year by a network administrator who discovered to his horror that ALL the cheap NICs his organization had bought, made by some nameless ChiCom manufacturer, used the same identical MAC address, so confusion reigned on his organization’s intranet and nothing worked! All the NICs had to be scrapped and replaced.)

  5. If you’re having problems getting your Linux distro to get a new IP the easiest thing to do is to just reboot your router (assuming you can do that). If that doesn’t work you can add the old address as a statically assigned DHCP address to a bogus MAC address. This will lock the Linux box out of it’s old address and force it to get the new address.

  6. More detail, about this not working on Ubuntu:
    sudo dhclient -r -pf /var/run/ -lf /var/lib/dhcp3/ eth1

    This kill the running dhcp daemon which is noticed by Network Manager which then immediately downs the interface, so the dhclient can not send the DHCPRELEASE packet.

    The solution is to disable NM (right clik on its icon and uncheck the first option “Enable Netwroking” – this is so on Ubuntu 10.10, other version might look a bit different), kill existing dhclient processes, then establish the connection manually, run dhclient eth0 , then run the above dhclient command to release the IP.

    For connection to WPA protected WLAN networks follow the description on

    (In windows this is justa matter of running “ipconfig /release wirelless*” :P )

  7. Oh, webmaster please fix the typos in my previous post… :-)
    (for network device names, use the same one of course, above I used ince eth0, then eth1)

  8. I have Ubuntu 12.04 and dhclient did not work. I simply used ‘sudo ifconfig eth0 down’ then ‘sudo ifconfig eth0 up’. Worked for me.

    [Good old ‘ifconfig’, didn’t think I would still be using it but there you go. CLI rules]

  9. It should be noted that the methods discussed in this post may enable one to get a new IP address lease for one’s computer or workstation, but if the computer is connected to a wide-area network (WAN) through a DSL modem or cable modem with its own built-in DHCP server, this will not necessarily result in a new IP address as seen by the outside world. Unless one has a way to remotely take control of the modem and cause it to issue a request to the Internet service provider’s DHCP server for a new IP address, one will still have the same address until the IP lease expires or until one physically disconnects the modem from the WAN, waits a while, then reconnects in the hope that the ISP’s DHCP sees it as a “new” connection.

  10. WARNING: On Ubuntu 12.04 and on my most recent Raspbian the command
    sudo dhclient
    does NOT renew the IP-Address! You must specify the interface!

    If you want to get a new IP-Address for eth0, then type
    sudo dhclient eth0
    It is not necessary to run “sudo dhclient -r” in advance. If you are using an SSH-connection and run “sudo dhclient -r”, you will lose the connection to your server and you will not be able to reconnect.
    @NIXCRAFT: please add this information to your post!

  11. I have a habit of resetting my router before I go to sleep. Occasionally this means that I reset while the VPN is on, then turn off my computer. The result is that the connection no longer works without the VPN.

    In the past, I’ve fixed it by fiddling around with restarting my computer, resetting my router, and variations of that with the VPN on, or off, or on for part of the process, etc.

    This is a much easier way to fix it.

  12. VERY HELPFULL , thanks for the inputs ,
    my vm was not taking the IP i just have to run two commands shared above
    sudo dhclient -r
    $ sudo dhclient

    thank you

Leave a Comment