Traditionally, we use
dhclient to release and renew DHCP lease on Linux. It probably still work with modern Linux distros nowadays. However, most distros come with NetworkManager which provides
nmcli command line interface to manage networking. Here’s how to renew DHCP lease using
nmcli performing on my machine. Your output when running these commands could be different.
First, let’s list the connections managed by NetworkManager.
# nmcli con NAME UUID TYPE DEVICE virbr0 2c2c7c4f-15e9-439b-be1d-e1d0131fb41c bridge virbr0 Wired connection 1 5c9000c5-2635-4b09-90d7-71c3783c6626 802-3-ethernet enp0s25 enp0s25 70ee0b94-8341-46ec-953d-f2c3ca34285a 802-3-ethernet -- virbr0-nic aafaa95e-6ced-4ea9-bd4f-7c8d10fb51b6 generic virbr0-nic
Next, we can find out the current IP associated with enp0s25 by running command:
# ip a show enp0s25 | grep 'inet ' inet 192.168.1.187/24 brd 192.168.1.255 scope global dynamic enp0s25
To renew IP for enp0s25, run these commands by supplying the connection’s name. In my case, it’s “Wired connection 1”:
# nmcli con down id 'Wired connection 1' # nmcli con up id 'Wired connection 1'
Let’s verify the new IP address:
# ip a show enp0s25 | grep 'inet ' inet 192.168.1.114/24 brd 192.168.1.255 scope global dynamic enp0s25
Well, if you still see the same IP address, it could just mean that your DHCP server keeps offering the same IP address for your machine.