[Dnsmasq-discuss] Dsmasq tags, options, matches understanding (Re: Dnsmasq dhcp lease file)

Simon Kelley simon at thekelleys.org.uk
Tue Sep 22 15:52:04 BST 2015


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

On 04/09/15 02:20, Sivabalakrishnan M wrote:
> Hi Simon,
> 
> I would like to understand how tags (setting tags, matching tags
> for dhcp-range, dhcp-option, dhcp-match) work. Is there any
> documentation I can refer? Please let me know.
> 
> Or we have all the info here - 
> http://www.thekelleys.org.uk/dnsmasq/docs/dnsmasq-man.html

That pretty much covers it.
> 
> Also, what are the guidelines that dnsmasq follow in assigning the
> IP addresses if there are multiple configurations that matches a
> DHCP request (for e.g. both dhcp range and dhcp-host configurations
> match for the incoming DHCP request)? Please let me know.

In that case it's undefined. Any dhcp-range which matches the tags or
any dhcp-range which is not qualified with tags. The only condition
that it defined is that a dhcp-range which has tags will be used
before dhcp-range without tags. The tagless dhcp-range could still be
used if, for example, a tagged dhcp-range was full up, with all the
avail able addresses in use.


Cheers,

Simon.

> 
> Thanks, Siva
> 
> On Fri, Aug 21, 2015 at 12:57 PM, Sivabalakrishnan M < 
> sivabalakrishnan.m at gmail.com> wrote:
> 
>> Thanks much Simon. Yes, this helps. Got it.
>> 
>> Thanks, Siva
>> 
>> On Fri, Aug 21, 2015 at 12:50 PM, Simon Kelley
>> <simon at thekelleys.org.uk> wrote:
>> 
> The expiry time is passed to the script in an enviromment variable 
> called DNSMASQ_LEASE_EXPIRES. There are a hold heap of these 
> variables, documented in the man page.
> 
> As an aside, the reason it's done like this is because the first 
> version of the script was provided with only the information in
> the argv. When extra information was added, it was done via  the 
> environment to maintain backwards compatiblity.
> 
> Cheers,
> 
> Simon.
> 
> 
> On 21/08/15 07:12, Sivabalakrishnan M wrote:
>>>>> Hi,
>>>>> 
>>>>> We are using dnsmasq for dhcp and tftp server in our
>>>>> project. And for leases file, our requirement is to
>>>>> maintain the leases information in our database without
>>>>> using dnsmasq.leases file.
>>>>> 
>>>>> For this, we plan to use "--dhcp-script=" option to provide
>>>>> our script path that would be invoked by dnsmasq for
>>>>> updating leases (add, del, old arguments). Also, we will be
>>>>> using "--leasefile-ro" option so that dnsmasq doesn't use
>>>>> dnsmasq.leases file at all and during reboot or init time,
>>>>> dnsmasq will invoke our script with "init" argument so that
>>>>> our script will retrieve the information from our config
>>>>> database and print it to stdout.
>>>>> 
>>>>> While going through dnsmasq source code, it looks like for
>>>>> updating the leases (add, del, old), dnsmasq doesn't seem
>>>>> to provide the lease time expiry in epoch format (MAC
>>>>> address, IP address, host name, client id are given). So,
>>>>> we are not sure how we can maintain leases on our own.
>>>>> Could you please clarify on this?
>>>>> 
>>>>> The following is the code in helper.c file (function - 
>>>>> create_helper(), line number is 563) that am referring
>>>>> (version 2.75). As we see here, we are not passing lease
>>>>> expiry time while invoking the script. Please help on this
>>>>> or let me know if am missing anything on this.
>>>>> 
>>>>> if (err == 0) { execl(daemon->lease_change_command, p ? p+1
>>>>> : daemon->lease_change_command, action_str, is6 ?
>>>>> daemon->packet : daemon->dhcp_buff, daemon->addrbuff,
>>>>> hostname, (char*)NULL); err = errno; }
>>>>> 
>>>>> Thanks a lot for the help.
>>>>> 
>>>>> Thanks, Siva
>>>>> 
>>> 
>> 
>> 
> 

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.22 (GNU/Linux)

iQIcBAEBCAAGBQJWAWsUAAoJEBXN2mrhkTWik+4P/RUbME6OuoDpygO4nIGd+MpR
G8X+eVzcRVkhadyz4sbU6rcq5RDqkMp80/0KZK9NJKBTHsCssVMeIM1A/y5yYWiC
tiexUO+H/FzA0Ag20ph88lyWWvc4nWBYCBPbi0pA5QBv4t4pNrC/nU5itWkx+c+V
Hb0Qa1rFEK2tDaCval8I6uDURrurdLRgvLF9ezTuHhfIRWzEz2eaM8PAh5zA+6ma
hTyxBflXuvUafFUwM3zOzOZMKl0L+9bWtDkEA7AqAznpJAQ67evHYUuvjRa2fzQA
Gv4NBXI95oQIiUQED3bBIuqV93vLzMCGjNVT8GqUS99Oyb/O4h4IjMCTXy9gxG1d
tPxENEEBZFht87mXygqStTH/EfIakZ6ikTSzCLb12S/6y/NM6JJKkkl1mzs8J7nJ
MP7FYJoo8fj9+vP631/Ke9FQJQMhKacAsfgNwebdxjMbEt81vjJE+IrtA3nmxqtW
vgDgqvG96Qv4DIodk3BFcHIX2e9iWcBP9JXTzT93SWs7N/hGAPiQvTsAzjo4zU1z
qjI8r4Oa3NlQW38t112BO7XtgkHFRZ4xJ84X65tPOCvOgJ4IdwQojleUPyo1wsM/
ByqTHiktfcOvA88kNfWD91p1R6h3W2wO6mPuWaCRSwJUfBaFilIWQnQCtSsNeo/5
qQYoL+dqDmoi0+Dj6CzJ
=zLMb
-----END PGP SIGNATURE-----



More information about the Dnsmasq-discuss mailing list