What I'm trying to achieve is to get cold-start, zero-state DHCP lease which means forcing dhclient
through the full discovery and configuration process (DHCPDISCOVER–DHCPOFFER–DHCPREQUEST–DHCPACK as opposed to the shortcutted DHCPREQUEST–DHCPACK cycle which uses a remembered address). I need this to debug a network configuration problem.
I have tried:
- flushing current lease with
dhclient -r
, disconnecting the current Network Manager connection; - killing any leftover
dhclient
anddnsmasq
processes; - cleaning
/var/lib/dhcp/
directory, which supposedly contains the client lease database; sudo restart network-manager
.
But even after these steps I see in the logs DHCPDISCOVER immediately followed by DHCPREQUEST of somehow still remembered address.
Clearly, the OS is storing the address somehow else, and I've run out of ideas. Any help from the community?
This did the trick for me(for eth0, run from
sudo su
):DHCP Client program writes the lease to a file. Just delete the file and restart networkmanager.
/var/lib/dhcp/dhclient.leases
This is where the leases are stored, in my computer.
What you are seeing is not your machine remembering the IP. In syslog you see DISCOVER REQUEST OFFER ACK however this is not in the order that it happened. It actually went DISCOVER OFFER REQUEST ACK to confirm this you can sniff the traffic between the PC and upstream DHCP server. You sent DISCOVER the server sent back OFFER and you got the IP from the OFFER for your REQUEST
You did everything right however, when you did "dhclient -r" dhclient will send a unicast RELEASE and some ISPs only accept multicast packets to their DHCP server, so the RELEASE never got there, as far as the server is concerned your lease is still valid, so it gave you back the same IP in the OFFER.
Normally,
dhclient -r
should do the trick; but if that doesn't work for you, I found a solution here:+ Renew an IP address one time :
Note: In this example we will be using the interface eth0. The interface must be configured for DHCP as up and running.
sudo su
to root.ifconfig
to show the current IP address that you received from DHCP.dhcpcd -k
to send the appropriate signals to dhcpcd (you might need to install dhcpcd by doingapt-get install dhcpcd
).ifup eth0
.ifconfig
to show the new IP address.There is also a section about renewing the IP address every-time, but the description was for RPM-based distros (in contrast to Debian-based distros like Ubuntu).
Hope it helps
:)