Score:0

Is it possible to force the DHCP server to assign a different IP address each time the address is renewed?

cn flag

I need to detect IP address renewals in my C++ Linux application and check if the new address is different from the old one. I have access to a router running OpenWrt. I can change the lease time, but I can't find a way to force an address change with each renewal process. Is this even possible? Maybe once assigned the IP address is never changed at renewal and the only way is to get the address after the lease time without renewal and hope my old address is assigned to another client?

Thank you in advance for any suggestions.

Michael Hampton avatar
cz flag
You will always get the same IP address if the lease has not expired. What exactly are you trying to do here?!
Doug avatar
in flag
Michael, while it is expected you will generally get the same address, this is not always true. Most commonly I see this with scope changes in which the admin wants to move machines off one block of IPs and onto another. That may be on the same subnet (we need more room for servers on .10-.50!), readdressing the segment to a new subnet. An uglier case is the server has been rebuilt and is handing new addresses out to everyone.
Score:3
in flag

By definition a renewal attempts to renew the existing lease of the same IP address.

If you want to force a new IP address from the client side you can change the MAC address of the network adapter. The DHCP server will see it as a new client and allocate a new address.

You may want to look at the macchanger package http://manpages.ubuntu.com/manpages/bionic/man1/macchanger.1.html as it has some nice to have features in this regard.

macchanger is a GNU/Linux utility for viewing/manipulating the MAC address for network interfaces."

If you want to force a new IP address from the server side you can change the configuration such that the current IP address is no longer available. This can be done by creating a reservation allocated to another (possibly fictitious) machine/mac address, modifying the scope so that the old address is no longer contained within the scope, disabling the scope or server entirely so that the server does not respond, or other methods that prevent the server from issuing the renewal.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.