0

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.

2
  • You will always get the same IP address if the lease has not expired. What exactly are you trying to do here?! Commented Jul 16, 2021 at 13:52
  • 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.
    – Doug
    Commented Oct 3, 2021 at 4:03

1 Answer 1

3

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .