Thursday, June 1, 2017

Setting up DNS resolution for KVM/libvirt guests locally

I decide write this post after realize a few labs in my notebook for poc's purposes, this very useful in case what you don't need setup a complex DNS server (bind), So, Bellow there all steps what I've done to take advantage from 'dnsmasq' which already running over the RHEL7 host with libvirt/kvm to configure a DNS Server using /etc/hosts to register all of my guests hosts.

In this example I'm using "" as fictitious domain name locally for kvm environment.

From the hypervisor/host(perspective), steps:

# virsh net-dumpxml default
<network connections='1'>
  <forward mode='nat'>
      <port start='1024' end='65535'/>
  <bridge name='virbr0' stp='on' delay='0'/>
  <mac address='51:53:00:bc:17:5b'/>
  <domain name='' localOnly='yes'/> 
  <ip address='' netmask=''>
      <range start='' end=''/>

Still in hypervisor KVM, adding names to the instances in the "/etc/hosts" file, all these names will be used for the vms:
# vi /etc/hosts   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6   vm3   vm4   vm5   vm6
# vi /etc/NetworkManager/conf.d/localdns.conf 
# vi /etc/NetworkManager/dnsmasq.d/libvirt_dnsmasq.conf 
* Restart all relative services like, NetworkManager, dnsmasq, libvirtd.
After deploy/provisioning instances in the KVM(virt-mananger/virsh), just point out 
resolv.conf to the IP of the hypervisor host server(KVM) in my case ( 

No comments:

Post a Comment