Systems:
Linux Mint 18.2 Cinnamon 64-bit (desktop mode, hands-on)
GNU/Linux Debian 9.2 Cinnamon 64-bit (headless mode, SSH)
Question:
How to release and renew IP address from the DHCP server (router) on these Linux systems?
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.
Sign up to join this communityI have found there is the following program listening on the network on both of them:
dhclient
Quoting the man page:
-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.
So, the solution for all interfaces would be:
sudo dhclient -r
sudo dhclient
Or, conveniently, for a specific interface, say eth0
:
sudo dhclient -r eth0
sudo dhclient eth0
Of course, when SSH'ing into a server, you need to run both commands oneliner or write a script as per this answer.
systemd
. So if you start meddling manually, the part calling dhclient may get confused.
on ubuntu:
release:
sudo dhclient -r
renew:
sudo dhclient -1
dhclient -1
better than just plain dhclient
? Please do not respond in comments; edit your answer to make it clearer and more complete.
Jul 6, 2019 at 21:20
dhclient -v eth0
- replaceeth0
with whatever your device is actually named