DHCP + DNS

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

DHCP + DNS

TomK
Hello,

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 tried
to configure the following in /etc/dhcp/dhclient.conf file and set the
PATH_DHCLIENT_CONF=/etc/dhcp/dhclient.conf; in the current shell in an
attempt to

supersede dhcp-lease-time 5;
supersede dhcp-rebinding-time 5;
supersede dhcp-renewal-time 5;

Or for that matter, change settings on a DHCPD servers to ensure
everytime the same client VM requests an IP, it will be given a
different IP vs the previous one assigned?


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.

Currently the DHCPD server servers the same IP or one of two IP's
regardless of how many times dhclient -v is called.

--
Cheers,
Tom K.
-------------------------------------------------------------------------------------

Living on earth is expensive, but it includes a free trip around the sun.

_______________________________________________
dhcp-users mailing list
[hidden email]
https://lists.isc.org/mailman/listinfo/dhcp-users
Reply | Threaded
Open this post in threaded view
|

Re: DHCP + DNS

TomK
On 3/3/2019 10:37 PM, TomK wrote:

> Hello,
>
> 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 tried
> to configure the following in /etc/dhcp/dhclient.conf file and set the
> PATH_DHCLIENT_CONF=/etc/dhcp/dhclient.conf; in the current shell in an
> attempt to induce assignment of unique IP's from the DHCP server:
>
> supersede dhcp-lease-time 5;
> supersede dhcp-rebinding-time 5;
> supersede dhcp-renewal-time 5;
>
 > but this had only mixed results, returning unique IP's only some of
 > the time.
 >
 >

> Or for that matter, change settings on a DHCPD servers to ensure
> everytime the same client VM requests an IP, it will be given a
> different IP vs the previous one assigned?
>
>
> 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.
>
> Currently the DHCPD server servers the same IP or one of two IP's
> regardless of how many times dhclient -v is called.
>

Pressed send too soon.  Adjusted the first paragraph.

--
Cheers,
Tom K.
-------------------------------------------------------------------------------------

Living on earth is expensive, but it includes a free trip around the sun.

_______________________________________________
dhcp-users mailing list
[hidden email]
https://lists.isc.org/mailman/listinfo/dhcp-users
Reply | Threaded
Open this post in threaded view
|

Re: DHCP + DNS

Sten Carlsen


On 04/03/2019 04.42, TomK wrote:
On 3/3/2019 10:37 PM, TomK wrote:
Hello,

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 tried to configure the following in /etc/dhcp/dhclient.conf file and set the PATH_DHCLIENT_CONF=/etc/dhcp/dhclient.conf; in the current shell in an attempt to induce assignment of unique IP's from the DHCP server:
One way I can think of is this:
for each call to dhclient -v change the host-id before each call, in this way the dhcp server will see the client as a different device and assign a so far not used IP.

supersede dhcp-lease-time 5;
supersede dhcp-rebinding-time 5;
supersede dhcp-renewal-time 5;

> but this had only mixed results, returning unique IP's only some of
> the time.
>
>
Or for that matter, change settings on a DHCPD servers to ensure everytime the same client VM requests an IP, it will be given a different IP vs the previous one assigned?


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.

Currently the DHCPD server servers the same IP or one of two IP's regardless of how many times dhclient -v is called.


Pressed send too soon.  Adjusted the first paragraph.



_______________________________________________
dhcp-users mailing list
[hidden email]
https://lists.isc.org/mailman/listinfo/dhcp-users
Reply | Threaded
Open this post in threaded view
|

Re: DHCP + DNS

Simon Hobson
In reply to this post by TomK
TomK <[hidden email]> 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" !

_______________________________________________
dhcp-users mailing list
[hidden email]
https://lists.isc.org/mailman/listinfo/dhcp-users
Reply | Threaded
Open this post in threaded view
|

Re: DHCP + DNS

TomK
On 3/4/2019 9:34 AM, Simon Hobson wrote:

> TomK <[hidden email]> 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" !
>
> _______________________________________________
> dhcp-users mailing list
> [hidden email]
> https://lists.isc.org/mailman/listinfo/dhcp-users
>

Hehe!

Thanks Simon and Sten.  This was a great reply.  I'll dig into changing
the client-id.

As an aside, should mention that I did end up writing a script that
defaults to using nmap if dhcpd fails to provide an IP.  Subsequently I
do DNS lookups using the IP's retrieved to ensure none of the IP's
belong to hosts that could just be offline.

So far it works amazingly at always assigning a unique IP from ranges
but couldn't help wondering if there isn't a community solution or even
a better way using dhcpd.

--
Cheers,
Tom K.
-------------------------------------------------------------------------------------

Living on earth is expensive, but it includes a free trip around the sun.

_______________________________________________
dhcp-users mailing list
[hidden email]
https://lists.isc.org/mailman/listinfo/dhcp-users
Reply | Threaded
Open this post in threaded view
|

Re: DHCP + DNS

TomK
On 3/5/2019 1:05 AM, TomK wrote:

> On 3/4/2019 9:34 AM, Simon Hobson wrote:
>> TomK <[hidden email]> 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" !
>>
>> _______________________________________________
>> dhcp-users mailing list
>> [hidden email]
>> https://lists.isc.org/mailman/listinfo/dhcp-users
>>
>
> Hehe!
>
> Thanks Simon and Sten.  This was a great reply.  I'll dig into changing
> the client-id.
>
> As an aside, should mention that I did end up writing a script that
> defaults to using nmap if dhcpd fails to provide an IP.  Subsequently I
> do DNS lookups using the IP's retrieved to ensure none of the IP's
> belong to hosts that could just be offline.
>
> So far it works amazingly at always assigning a unique IP from ranges
> but couldn't help wondering if there isn't a community solution or even
> a better way using dhcpd.
>

Just for clarification, I believe you mean this option?

        -I <dhcp-client-identifier>
               Specify the dhcp-client-identifier option to send to the
DHCP server.


--
Cheers,
Tom K.
-------------------------------------------------------------------------------------

Living on earth is expensive, but it includes a free trip around the sun.

_______________________________________________
dhcp-users mailing list
[hidden email]
https://lists.isc.org/mailman/listinfo/dhcp-users