OPNsense Forum

Archive => 17.7 Legacy Series => Topic started by: john9527 on February 15, 2018, 12:43:16 am

Title: Sequential DHCP addresses
Post by: john9527 on February 15, 2018, 12:43:16 am
All the current documentation says that the DHCP server assigns addresses based on a hash of the MAC address, yet OPNsense assigns them sequentially.   Is there a setting to force the hashed address assignments?
Title: Re: Sequential DHCP addresses
Post by: marjohn56 on February 15, 2018, 08:23:57 am
Where does it say that?

IPv6 is sort of does it that way, but v4?
Title: Re: Sequential DHCP addresses
Post by: john9527 on February 15, 2018, 10:31:50 am
dhcpd(8) - Linux man page
https://linux.die.net/man/8/dhcpd

The DHCP server generates the list of available IP addresses from a hash table. This means that the addresses are not sorted in any particular order, and so it is not possible to predict the order in which the DHCP server will allocate IP addresses. Users of previous versions of the ISC DHCP server may have become accustomed to the DHCP server allocating IP addresses in ascending order, but this is no longer possible, and there is no way to configure this behavior with version 3 of the ISC DHCP server.

I've become accustomed to this behavior since this is the way most consumer routers work using dnsmasq as the dhcp server.  With dnsmasq the hash is based on the mac, so you end up with a virtually-static ip.

Maybe I'm mistaken as to the server used in opnsense.
Title: Re: Sequential DHCP addresses
Post by: marjohn56 on February 15, 2018, 06:17:43 pm
I think your crossing your man docs. The reference you make in paragraph one comes from ISC dhcp server, not dhcpd as used in opnsense.  :)

Title: Re: Sequential DHCP addresses
Post by: john9527 on February 15, 2018, 06:34:14 pm
The same paragraph is in the FreeeBSD man page
https://www.freebsd.org/cgi/man.cgi?query=dhcpd.conf&sektion=5&apropos=0&manpath=FreeBSD+11.1-RELEASE+and+Ports
Title: Re: Sequential DHCP addresses
Post by: marjohn56 on February 15, 2018, 06:36:14 pm
That also refers to ISC dhcp server, not dhcpd.

Hold horses, I may be thinking of something else... brain is tired, you appear to be correct. I'll go check it out.

.........

You are correct, I AM thinking of something else.

I'll go re-read the manual and do some tests.

Title: Re: Sequential DHCP addresses
Post by: marjohn56 on February 15, 2018, 06:51:55 pm
My reading of that doc does not indicate that the addresses will be based upon the mac address of the client, just  an internally generated hash table of addresses, that may or may not get given out in sequence.

If the client sends a release when it goes offline, then that address will be returned to the pool for re-use. If I want something to always get the same address I create a static entry for it, otherwise there would be little point in having that option.
Title: Re: Sequential DHCP addresses
Post by: john9527 on February 15, 2018, 08:07:26 pm
My reading of that doc does not indicate that the addresses will be based upon the mac address of the client, just  an internally generated hash table of addresses, that may or may not get given out in sequence.
Agreed it doesn't say mac hashing, I just used the design of dnsmasq as an example.   But I would have expected some randomness...it does appear to still be sequential.

Quote
If the client sends a release when it goes offline, then that address will be returned to the pool for re-use. If I want something to always get the same address I create a static entry for it, otherwise there would be little point in having that option.
Actually, in re-reading the FreeBSD man page, it would seem there is a 'sticky' nature to the assigned IPs, even if the lease expires and the client is disconnected (most clients don't actually send a release, I'm only aware of an option for windows not set by default).   I'll have to test this out a bit more.