On 02/25/2015 05:51 PM, Carlos Miranda Molina (Mstaaravin) wrote:
Hello guys...
I'm using libvirt in my local laboratory and I have a question/problem
about DNS settings over dnsmasq (by libvirt)
I have a NAT network separately from my real network, i need simulated
some DNS hosts to NAT network like
ftp.debian.org
<
http://ftp.debian.org> (for testing purposes, etc)
This is for example a dumpxml (yes, i'm using PXE boot for testing and
is working fine)
<network>
<name>net0</name>
<uuid>5a014735-f658-7a87-c7d4-e6b0f488c332</uuid>
<forward mode='nat'/>
<bridge name='net0' stp='on' delay='0'/>
<mac address='52:54:00:b5:24:7b'/>
<dns>
<host ip='192.168.122.1'>
<
hostname>mirrors.kernel.org
<
http://mirrors.kernel.org></hostname>
<hostname>mirrors.dcarsat.com.ar
<
http://mirrors.dcarsat.com.ar></hostname>
<
hostname>ftp.debian.org <
http://ftp.debian.org></hostname>
</host>
</dns>
<ip address='192.168.122.1' netmask='255.255.255.0'>
<tftp root='/home/tftp'/>
<dhcp>
<range start='192.168.122.2' end='192.168.122.99'/>
<bootp file='pxelinux.0'/>
</dhcp>
</ip>
</network>
Look <dns> & <hostname> section, that works correctly but only if I
add hostnames on net0 when was offline.
<dns>
<host ip='192.168.122.1'>
<
hostname>mirrors.kernel.org
<
http://mirrors.kernel.org></hostname>
<hostname>mirrors.dcarsat.com.ar
<
http://mirrors.dcarsat.com.ar></hostname>
<
hostname>ftp.debian.org <
http://ftp.debian.org></hostname>
</host>
</dns>
How i can add more hostnames with my network (net0) are still online...?
virsh net-update default add-last dns-host (for example, doesn't work)
It looks like support for that was added in libvirt 1.0.1. Can you
provide the entire commandline you use? In what way does it not work?
Note that in order to have it take effect immediately and be saved in
the persistent config for the network, you must specify "--live
--config" on the commandline. Also, you can only add and remove entire
<host> records, you can't add a <hostname> into an existing <host>.
For example, I just tried this command and it worked for me (note that
the outer single quotes around the xml, and use of double quotes within):
virsh net-update default add dns-host \
'<host ip="192.168.122.145">
<hostname>blah.laine.org</hostname>
<hostname>blorg.laine.org</hostname>
</host>' \
--live --config
When you enter this command, libvirt will rewrite the the file
/var/lib/libvirt/dnsmasq/default.addnhosts and send a SIGHUP to dnsmasq
(this is one of the few cases where dnsmasq is actually willing/able to
reread a config file without needing to quit and restart the dnsmasq
process).
and the official documentation @
http://libvirt.org/formatnetwork.html#elementsAddress
doesn't say more.
I test with <forwarder > but doesn't work
(192.168.10.100 is a dnsmasq outside libvirt control)
<forwarder> was added in libvirt version 1.1.3. What version are you
using? If it is high enough, have you looked at the DNS server used by
the guest to see if it has gotten it right and/or tried doing a tcpdump
of the DHCP exchange to see if the different forwarder is sent in the
response?
<network>
<name>net0</name>
<uuid>5a014735-f658-7a87-c7d4-e6b0f488c332</uuid>
<forward mode='nat'/>
<bridge name='net0' stp='on' delay='0'/>
<mac address='52:54:00:b5:24:7b'/>
<dns>
<forwarder addr="192.168.10.100"/>
</dns>
<ip address='192.168.122.1' netmask='255.255.255.0'>
<tftp root='/home/tftp'/>
<dhcp>
<range start='192.168.122.2' end='192.168.122.99'/>
<bootp file='pxelinux.0'/>
</dhcp>
</ip>
</network>
Anyone can help me...?