I was playing with Satellite and re-provisioning client registered to it. This is awkward when you do it remotely and on real hardware - for me it is difficult to setup (if you want DNS and DHCP) and when client fails during re-provisioning, you either have to have physical access to it, or client have to have some kind of remote management console. Using libvirt is, on the other hand, very straightforward and you can get DNS and DHCP for free.
# virsh net-edit --network default <network> <name>default</name> <uuid>970b7e2e-88d1-4100-8a2a-8db36c911d4c</uuid> <forward mode='nat'/> <bridge name='virbr0' stp='on' delay='0'/> <mac address='52:54:00:f1:e9:9a'/> <dns> <host ip='192.168.122.46'> <hostname>sat-emb.example.com</hostname> </host> <host ip='192.168.122.170'> <hostname>proxy.example.com</hostname> </host> <host ip='192.168.122.25'> <hostname>client.example.com</hostname> </host> </dns> <ip address='192.168.122.1' netmask='255.255.255.0'> <dhcp> <range start='192.168.122.2' end='192.168.122.254'/> <bootp file='/pxelinux.0' server='192.168.122.46'/> </dhcp> </ip> </network>
<network><dns> configures hostname and their IPs form domain name resolution.
<network><ip><dhcp><bootp> allows me to set server which serves as PXE network boot server and file it clients should request. In my case, 192.168.122.46 is a Satellite with tftp running and configured.
NOTE: I have noticed that guests can not translate outer world hostnames to IPs - it looked like dnsmasq on the virtualization host is not forwarding requests it can not resolve to DNS servers from /etc/resolv.conf. Adding
"<dns><forwarder addr="ip.of.another.nameserver" domain="internal.network.com"/>..." and restarting the network did not helped. At the end I have discovered there is forgotten
no-resolv option in
/var/lib/libvirt/dnsmasq/default.conf. When I have removed it and restarted network to regenerate config, it worked. I have probably forgotten it there in some previous adventures. From dnsmasq manual page:
-R, --no-resolv Don't read /etc/resolv.conf. Get upstream servers only from the command line or the dnsmasq configuration file.