[Dnsmasq-discuss] dnsmasq leases file format specification

Nicolas Cavallari nicolas.cavallari at green-communications.fr
Thu Jun 9 18:42:00 BST 2016


On 08/06/2016 21:56, Sergey Nechaev wrote:
> Hello, Simon  
> 
> Could you (or anyone) please provide description of leases file format?
> I’ve searched through this mail list, but failed to find full description.

The code that writes it is in lease_update_file() in src/lease.c.
The code that reads it is in lease_init().

A DHCPv4 lease entry consists of these fields separated by spaces:

- The expiration time (seconds since unix epoch) or duration
  (if dnsmasq is compiled with HAVE_BROKEN_RTC) of the lease.
  0 means infinite.

- The link address, in format XX-YY:YY:YY[...], where XX is the ARP
  hardware type.  "XX-" may be omitted for Ethernet.

- The IPv4 address

- The hostname (sent by the client or assigned by dnsmasq)
  or '*' for none.

- The client identifier (colon-separated hex bytes)
  or '*' for none.

A DHCPv6 lease entry has these fields:

- The expiration time or duration

- The IAID as a Big Endian decimal number, prefixed by T for
  IA_TAs (temporary addresses).

- The IPv6 address

- The hostname or '*'

- The client DUID (colon-separated hex bytes) or '*' if unknown.[1]

For DHCPv6, there must also be exactly one special entry indicating
the DUID of the server.  This line contains two fields:

- The string "duid".

- The DUID of the server.


[1] This field seems to be written but is never read back. A bug maybe ?

> We are preparing improvement to Openstack Neutron network subsystem,
> which enables releasing
> of unneeded DHCPv6 leases and description of leases file format is
> necessary for code review. 

Just pointing out that since dnsmasq 2.73, if you use dbus, you can
dynamically remove leases with just a D-Bus call:

dbus-send --system --print-reply \
  --dest=uk.org.thekelleys.dnsmasq \
  /uk/org/thekelleys/dnsmasq \
  uk.org.thekelleys.dnsmasq.DeleteDhcpLease \
  string:"$IPV4_OR_IPV6_ADDRESS"



More information about the Dnsmasq-discuss mailing list