]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
network: add domain to unqualified names defined with <host>
authorLaine Stump <laine@laine.org>
Sat, 25 Jun 2011 05:14:38 +0000 (01:14 -0400)
committerLaine Stump <laine@laine.org>
Tue, 28 Jun 2011 16:57:14 +0000 (12:57 -0400)
If a domain name is defined for a network, add the --expand-hosts
option to the dnsmasq commandline. This results in the domain being
added to any hostname that is defined in a dns <host> element and
contains no '.' characters (i.e. it is an "unqualified"
hostname). Since PTR records are automatically created for any name
defined in <host>, the result of a PTR request will change from the
unqualified name to the qualified name.

This also has the same effect on any hostnames that dnsmasq reads
from the host's /etc/hosts file.

(In the case of guest hostnames that were learned by dnsmasq via DHCP
requests, they were already getting the domain name added on, even
without --expand-hosts).

src/network/bridge_driver.c
tests/networkxml2argvdata/nat-network-dns-hosts.argv
tests/networkxml2argvdata/nat-network-dns-hosts.xml
tests/networkxml2argvdata/netboot-network.argv
tests/networkxml2argvdata/netboot-proxy-network.argv

index aa170d60acc0d4fde0c0b309ed8df6db891d8831..5d5282c48229185ca0bd40cd9e27ff36f1983ccf 100644 (file)
@@ -617,6 +617,10 @@ networkBuildDnsmasqArgv(virNetworkObjPtr network,
         if (ipdef->nranges || ipdef->nhosts)
             virCommandAddArg(cmd, "--dhcp-no-override");
 
+        /* add domain to any non-qualified hostnames in /etc/hosts or addn-hosts */
+        if (network->def->domain)
+           virCommandAddArg(cmd, "--expand-hosts");
+
         if ((dctx = networkSaveDnsmasqHostsfile(ipdef, network->def->dns, network->def->name, false))) {
             if (dctx->hostsfile->nhosts)
                 virCommandAddArgPair(cmd, "--dhcp-hostsfile",
index dce075b1a25ec6c898c4ec0c8e744263e527299b..2158df8702413112ea9ff51c488e0f7588479d1d 100644 (file)
@@ -1,3 +1,3 @@
-/usr/sbin/dnsmasq --strict-order --bind-interfaces --conf-file= \
---except-interface lo --listen-address 192.168.122.1 \
---addn-hosts=/var/lib/libvirt/dnsmasq/default.addnhosts\
+/usr/sbin/dnsmasq --strict-order --bind-interfaces --domain example.com \
+--conf-file= --except-interface lo --listen-address 192.168.122.1 \
+--expand-hosts --addn-hosts=/var/lib/libvirt/dnsmasq/default.addnhosts\
index 9a83fed17f41c53334a4b5ab8b4d4cdc21ae346a..2180a5ddcdfd3d11092e166c9e78b136df9001f9 100644 (file)
@@ -3,6 +3,7 @@
   <uuid>81ff0d90-c91e-6742-64da-4a736edb9a9c</uuid>
   <forward dev='eth0' mode='nat'/>
   <bridge name='virbr0' stp='on' delay='0' />
+  <domain name="example.com"/>
   <dns>
     <host ip='192.168.122.1'>
       <hostname>host</hostname>
index 27ffaa1b06ff138af7ee439d9f4977a649c4ae2f..78e873c951e8b1c2d1c8ad05fd728d80048189d5 100644 (file)
@@ -2,5 +2,5 @@
 --conf-file= --except-interface lo --listen-address 192.168.122.1 \
 --dhcp-range 192.168.122.2,192.168.122.254 \
 --dhcp-leasefile=/var/lib/libvirt/dnsmasq/netboot.leases \
---dhcp-lease-max=253 --dhcp-no-override --enable-tftp \
+--dhcp-lease-max=253 --dhcp-no-override --expand-hosts --enable-tftp \
 --tftp-root /var/lib/tftproot --dhcp-boot pxeboot.img\
index 3e0c5a5fa159a5d1795d5ac5ca65dd2b3fdfa94c..5fe1b8ef1bae3ff4e660d3e08aab33110aebd77d 100644 (file)
@@ -2,4 +2,5 @@
 --conf-file= --except-interface lo --listen-address 192.168.122.1 \
 --dhcp-range 192.168.122.2,192.168.122.254 \
 --dhcp-leasefile=/var/lib/libvirt/dnsmasq/netboot.leases \
---dhcp-lease-max=253 --dhcp-no-override --dhcp-boot pxeboot.img,,10.20.30.40\
+--dhcp-lease-max=253 --dhcp-no-override --expand-hosts \
+--dhcp-boot pxeboot.img,,10.20.30.40\