[Dnsmasq-discuss] DHCP Address - Lease in numerical order

Simon Kelley simon at thekelleys.org.uk
Fri Dec 21 16:08:41 GMT 2007


Paul Fox wrote:
>  > On Thu, 20 Dec 2007, Simon Kelley wrote:
>  > > It's not random:  the address is derived from the start and
>  > > end addresses of the address pool and a hash of the MAC
>  > > address.  This means that a given host will (nearly) always
>  > > be offered the same address, without dnsmasq having to keep
>  > > track of the addresses allocated in the past to hosts which
>  > > don't have a lease right now.
>  > >
>  > > The alternatives are it to keep a much bigger database which
>  > > has historical information about all leases offered to all
>  > > hosts for all time (ISC), or not to attempt to give hosts
>  > > stable addresses at all (udhcpd).  I thought the
>  > > hash-function trick was a particularly neat alternative.
> 
> i wouldn't have thought that offering the same address was important
> enough to do it "for all time".  i would have thought "if still
> available" would be good enough.  after all, if it's been in use by
> someone else, then any sessions/caches/whatever the client might have
> had are now invalid in any case.
> 
> so why isn't it sufficient to keep a record of which client last had
> any address in the offered ranges?  this is no bigger than the records
> one has to keep if all addresses are in use, right?
> 
> (which isn't to say your solution isn't clever.  :-)
> 

I followed the spec: from RFC2131

   When a server receives a DHCPDISCOVER message from a client, the
   server chooses a network address for the requesting client.  If no
   address is available, the server may choose to report the problem to
   the system administrator. If an address is available, the new address
   SHOULD be chosen as follows:

      o The client's current address as recorded in the client's current
        binding, ELSE

      o The client's previous address as recorded in the client's (now
        expired or released) binding, if that address is in the server's
        pool of available addresses and not already allocated, ELSE

      o The address requested in the 'Requested IP Address' option, if that
        address is valid and not already allocated, ELSE

      o A new address allocated from the server's pool of available
        addresses; the address is selected based on the subnet from which
        the message was received (if 'giaddr' is 0) or on the address of
        the relay agent that forwarded the message ('giaddr' when not 0).

The hash mechanism is my low-resource way of implementing the second bullet.

Cheers,

Simon.




More information about the Dnsmasq-discuss mailing list