[Dnsmasq-discuss] Query regarding --leasefile-ro
Simon Kelley
simon at thekelleys.org.uk
Tue Jul 1 17:05:22 UTC 2014
On 01/07/14 13:33, Nehal J Wani wrote:
>> That looks sensible. I guess from these questions that you're thinking
>> about storing the lease database just in the custom format, and using
>> --leasefile-ro
>
> Right now, libvirt stores all leases for each interface in separate
> files. That is, one lease database per dnsmasq instance, it does so,
> on the basis of the environment variable DNSMASQ_INTERFACE (I know
> that it is not set in case of del events everytime). The trouble is,
> when it gets the argument 'init', how will my helper program know
> which database it has to read and print to stdout? Suppose if we have
> only one lease database for all dnsmasq instances, how will the leases
> helper program distinguish between different interfaces (that is, for
> which interface should I print info, if I get 'init' as argument)? How
> does it happen by default, when none of --dhcp-script and
> --leasefile-ro are provided?
>
The default method has only one instance of dnsmasq handling multiple
instances, and the interface associated with a lease isn't really
important information, that's handled by looking at subnets and such.
I think libvirt spins up a dnsmasq instance for each virtual interface.
Is that correct? If so you need to keep the lease databases for each
instance separate.
The most obvious nasty hack to make this work would be to have a set of
filesystem links to the real lease-change script, each with a different
name, and configure each dnsmasq to call a unique link. The script then
checks argv[0] to find the name it was called by and then transforms
that into the name of the corresponding database file.
So we have something like
scripts/interface1 is a link to /lib/libvirt/lease-change-script
scripts/interface2 is a link to /lib/libvirt/lease-change-script
and start dnsmasq with
dnsmasq --interface=interface1 --dhcp-script=scripts/interface1
and the script finds the basename of argv[0[:
scripts/interface1 -> interface1
and prepends the directory where the lease files are
interface1 ->leasefiles/interface1
That works in the absence on the DNSMASQ_INTERFACE variable.
Cheers,
Simon.
More information about the Dnsmasq-discuss
mailing list