Where interface is the device you want to get a new address for.
dhclient -r eth0
The -r flag forces dhclient to first release any leases you have, you can then use this command to request a new lease:
dhclient eth0
From man dhclient:
-r Tell dhclient to release the current lease it has from the
server. This is not required by the DHCP protocol, but some
ISPs require their clients to notify the server if they wish
to release an assigned IP address.
I wouldn't recommend running either over an SSH connection, although you'll probably get away with the first one if it doesn't come back with a new ip address.
If the MAC address of the interface isn't changed, the DHCP server may assign it the same address when renewing. Therefore, a simple release and renew with dhclient may not acquire a new address. Change the MAC address and acquire a new IP address with the following commands. Don't forget to write the original down if you need to revert back to it at a later time.
ifconfig <interface> down
ifconfig <interface> hw ether <MAC address>
ifconfig <interface> up
You can also use this command:
Where
interface
is the device you want to get a new address for.The
-r
flag forcesdhclient
to first release any leases you have, you can then use this command to request a new lease:From
man dhclient
:Either of the following should get it to renew.
or
I wouldn't recommend running either over an SSH connection, although you'll probably get away with the first one if it doesn't come back with a new ip address.
Would comment p.campbell, but I have only 1 reputation and therefore cannot, first I review installed interfaces:
release IP from selected interface (e.g. eth0, eth1, enp1s0, sit0, wlan0,...):
request new IP from DHCP server (alert on error):
check IP:
Ubuntu 16.04 LTS confirmed
If you're using the
dhcpcd
tool then:The first says to release and deconfigure the interface, and the second says to reload configuration and rebind the interface again.
If the MAC address of the interface isn't changed, the DHCP server may assign it the same address when renewing. Therefore, a simple release and renew with dhclient may not acquire a new address. Change the MAC address and acquire a new IP address with the following commands. Don't forget to write the original down if you need to revert back to it at a later time.
In systems where NetworkManager is on, running...
...gets you a connection list, and running...
takes the connection down and back up