[Dnsmasq-discuss] Remembering DHCP Assignments

Simon Kelley simon at thekelleys.org.uk
Thu Jul 14 09:24:18 BST 2011

Freddie Witherden wrote:
> Hello,
> Currently my set-up consists of the ISC DHCP server and dnsmasq.  I am
> in the process of trying to switch entirely to dnsmasq.  One of the nice
> features of the ISC server is that it attempts to give repeat customers
> the same IP address each time.
> This is convenient as it allows me to connect a device to my network,
> see its IP and then, if it is a permanent fixture, add an entry in
> /etc/hosts for dnsmasq to pick up on.
> I am wondering how I can obtain similar behavior with dnsmasq.  Manually
> adding MAC<=>IP associations is somewhat tedious to do and I would like
> to avoid having to use static assignments on clients.
> Can anyone suggest solutions to this?

Dnsmasq attempts to do that same thing, but the implementation is a bit
different. Instead of keeping records of all clients almost forever, it
allocates IP addresses using a hash of the client's MAC address, so
normally the same client should always get the same address. To make
this work well, the size of the DHCP address range should ideally be
much larger than the number of clients. If you have ten IP addresses and
nine clients, then hash collisions will mean that the IP address
allocations are essentially random. If you have 250 IP addresses and
nine clients, then there will probably be no collisions, and a client
will always get the same IP address.

Another option to consider is to make DHCP lease times infinite, that
will give the same address every time, but might risk running out of
addresses long-term is the set of clients changes over time.

Finally, if the only reason you care about long-term stable addresses is
for naming in /etc/hosts, then consider moving that information to the
dnsmasq configuration and mapping names to MAC addresses instead.


that way stable IP addresses are not required. (See also --read-ethers),
you can keep this mapping in /etc/ethers rather than the dnsmasq
configuration file if that suits.)



More information about the Dnsmasq-discuss mailing list