[Dnsmasq-discuss] Chaining instances?

TJ dnsmasq at iam.tj
Sun Feb 24 21:11:24 GMT 2013


On 24/02/13 19:19, Laine Stump wrote:
> On 02/24/2013 05:09 AM, TJ wrote:
>> I wondered if maybe configuring the libvirtd dnsmasq instances to be dhcp proxies for the LAN dnsmasq, and use multiple dhcp-range's with tags might do it?
>>
>> My brain is a bit fried right now having had to fix several bugs in vmbuilder and libvirt, plus add new functionality to libvirtd to allow its dnsmasq instance to read a conf-file and use a separate log-facility, 
> 
> What you're talking about doing sounds *very* useful to have supported
> directly in libvirt, but you may want to contact libvirt's upstream
> developers (at libvir-list at redhat.com, or on irc.oftc.net in #virt)
> prior to expending a lot of effort on libvirt code - in general a
> problem may already be solved in a different manner, or somebody else
> may already be working on it. Failing that, there may have already been
> considerable debate on a particular subject, and a path to a solution
> generally agreed on, but with nobody yet working on the code.

It turns out that what I need(ed) to do was completely *disable* libvirt's use of dnsmasq
and instead use Simon's related "dhcp-helper" program which acts as a full dhcp-relay using, f.e:

/usr/sbin/dhcp-helper -u libvirt-dnsmasq -i virbr1 -b eth0

This forwards all requests to the primary dnsmasq DHCP server on the LAN which matches against the
appropriate dhcp-range:

# physical network leases
dhcp-range=set:phys,10.254.251.50,10.254.251.199,255.255.255.0,1440m
# subnet for VMs on server1
dhcp-range=set:vmlan1,10.254.1.100,10.254.1.199,255.255.255.0,1440m
# default route (gateway)
dhcp-option=tag:phys,option:router,10.254.251.1
dhcp-option=tag:vmlan1,option:router,10.254.1.1
# DNS server
dhcp-option=6,10.254.251.1


To that end this evening I added two additional options to libvirt:

<dnsmasq enabled='true'/>
<dhcphelper enabled='false'/>

These are the default values when the options are *not* defined. They allow the admin to disable dnsmasq entirely:

<dnsmasq enabled='false'/>

and to enable dhcp-helper:

<dhcphelper enabled='true'/>

Using two new functions:

int networkBuildDhcphelperArgv(...)
int networkBuildDhcpHelperCommandLine(...)

the existing function:

int networkStartDhcpDaemon(...)

is able to launch either or both of dnsmasq and dhcp-helper with the correct options.

dhcp-helper's "-i" option is filled from network->def->bridge and its "-b" option is taken from
the first forward device declared in a <forward dev='?'/> or <interface dev='?'/>. If no forward
device is declared it throws a VIR_ERR_INVALID_INTERFACE error with appropriate explanatory text.





More information about the Dnsmasq-discuss mailing list