DHCP + DNS
dhcp1 at thehobsons.co.uk
Mon Mar 4 14:34:28 UTC 2019
TomK <tomkcpr at mdevsys.com> wrote:
> Is there a way to force remote DHCPD servers to assign a different IP to a client with the same MAC everytime dhclient -v is called?
> I've a unique scenario where I would like to also check the local DNS to determine if any offline hosts are already assigned to an IP and need to cycle through a few to determine that.
What you are seeing is correct behaviour and is required by the RFCs covering DHCP.
It is explicitly required that the server should try and lease the same IP to a client - even if it's been off the network for a while. So unless the address has been reused in the meantime, your device could come back even years later and get the same address.
As Sten says, you can use a different client-id each time and then the device will be considered a different one each time.
This because the MAC address (hardware-address) is only used as the database key if there is no client-id provided by the client (the default on Linux clients). If there is a client-id then this will be used as the database key. So setting this and changing the value on each invocation will achieve what you want.
> Currently the DHCPD server servers the same IP or one of two IP's regardless of how many times dhclient -v is called.
As an aside, it's good that you provided this explanation. The question has been asked a few times over the years, and usually it's some variation of "manglement tell me that we must change customers' IPs regularly to stop then running servers at home". The usual response is along the lines of "look for another job now before your customers are peed off and leave, and your employer goes bust" !
More information about the dhcp-users