[Dnsmasq-discuss] Problems with custom dhcp-script and leasefile-ro

Simon Kelley simon at thekelleys.org.uk
Wed Oct 14 09:07:34 BST 2009


Tommy Brander wrote:
> Hi All
> 
> I'm using dnsmasq version 2.47 on Ubuntu Server Jaunty with a custom 
> dhcp-script and the option leasefile-ro. The script is a PHP file which 
> stores the lease database together with available DHCP options (vendorid 
> and so on) in a PostgreSQL database.
> After a restart of dnsmasq, when the script is called with init, i read 
> the active leases and print them with the following statement:
> 
> fputs(STDOUT, "$lease");
> 
> where $lease = '1255470657 00:1f:29:b4:84:82 192.168.0.194 pisces *'. 
> Observe that this is without any added \n.
> 
> I also log this to a log file, that after init contains the following:
> 
> 2009-10-13 23:23:18 - init: 1255470657 00:1f:29:b4:84:82 192.168.0.194 
> pisces *
> 2009-10-13 23:23:18 - init: 1255470430 00:01:38:99:52:80 192.168.0.182 
> betelgeuse 01:00:01:38:99:52:80
> 2009-10-13 23:23:18 - init: 1255470317 00:21:00:d2:25:4e 192.168.0.113 
> Delphinus 01:00:21:00:d2:25:4e
> 2009-10-13 23:23:18 - init: 1255470271 08:00:27:23:dd:64 192.168.0.104 
> caelum 01:08:00:27:23:dd:64
> 2009-10-13 23:23:18 - init: 1255470066 00:02:61:0f:c2:ec 192.168.0.123 * 
> 01:00:02:61:0f:c2:ec
> 
> In the syslog, the following rows has appeared:
> 
> Oct 13 23:23:17 aurora dnsmasq[5420]: exiting on receipt of SIGTERM
> Oct 13 23:23:18 aurora dnsmasq[5611]: started, version 2.47 cachesize 150
> Oct 13 23:23:18 aurora dnsmasq[5611]: compile time options: IPv6 
> GNU-getopt DBus I18N TFTP
> Oct 13 23:23:18 aurora dnsmasq[5611]: DHCP, IP range 192.168.0.101 -- 
> 192.168.0.199, lease time 30m
> Oct 13 23:23:18 aurora dnsmasq[5611]: reading /etc/resolv.conf
> Oct 13 23:23:18 aurora dnsmasq[5611]: using nameserver 195.54.122.200#53
> Oct 13 23:23:18 aurora dnsmasq[5611]: using nameserver 195.54.122.198#53
> Oct 13 23:23:18 aurora dnsmasq[5611]: read /etc/hosts - 21 addresses
> 
> The problem I'm having with this setup is that when the host pisces, 
> which is a Ubuntu Karmic host, request it's next IP, the event generated 
> is not an 'Old' but an 'Add'. This is the row that appears in my dhcp 
> log file:
> 
> 2009-10-13 23:23:45 - add: 00:1f:29:b4:84:82 192.168.0.194 pisces  eth1 
> 1800  brander.local
> 
> Is that correct? The client first does two DHCPREQUEST, which dnsmasq 
> host responds with DHCPNAK. Then the client does a DHCPDISCOVER and gets 
> an IP - some times the same IP, some times a different IP. Is this a 
> feature or a bug?
> 
> Since dnsmasq read the lease file during init, it should give out the 
> same address and generate an 'Old' event. Or am I just stupid?
> 
> Can anyone help me?
> 

I guess the first step is to find out exactly what leases dnsmasq has in 
its database after the "init" event. The easiest way to do this is to 
run dnsmasq with the --no-daemon --log-queries flags, and then send it a 
USR1 signal. That will dump the DNS cache to the stdout. DNS entries 
which arise from DHCP leases will have a "D" in the flags field. You 
should see one for each of your DHCP leases which have a name.

My guess, without looking in detail, is that you have already found the 
problem - the lack of newline characters.

HTH

Simon.



More information about the Dnsmasq-discuss mailing list