Hi folks, here’s another “pre” post. What I mean by that is that in the process of creating a demo and the surrounding article, I found I needed to create a sidebar article in order to show how configure an important component. In this case, the requirement to fulfill forward and reverse name server resolution in RHV has lead me to create a basic DNS server. In this case, “dnsmasq” is a perfect solution…

Let me be clear here: I am NOT recommending dnsmasq for production DNS. For production I would recommend deploying BIND, Red Hat IdM, or something else. I’m using dnsmasq because I need something for my home lab and I think you might benefit from the configuration I’m using in your home or test lab. I don’t have that many systems, and a lightweight service like dnsmasq will work nicely.


The RHV 4 documentation is very clear about the requirement for FQDN and fully functional DNS. Simply relying on “/etc/hosts” isn’t going to cut it anymore. Dnsmasq will provide a great and simple solution for small labs. For the uninitiated, dnsmasq provides DHCP, TFTP, DNS, and DNS forwarding. We’ll really only be concerned with the DNS and DNS forwarding features in this particular tutorial

Server Side

On my RHEL 7 server, dnsmasq was already installed, so it was just a matter of configuring a few lines, restarting the service, and then poking a hole through the firewall.

After making a copy of the configuration file (/etc/dnsmasq.conf), I created a new one:

# Configuration file for dnsmasq.
#block incomplete requests
#prevent non-routable addresseses from being forwarded
#my private mini "almost" cloud
#add "fog.com" to short hostnames
#ensure local queries are answered only be dnsmasq
#enable reverse lookups!!
#listen on the loopback
#listen on this IP
#listen only to the "listen addresses"
#upstream DNS servers

Restart dnsmasq:

# systemctl restart dnsmasq
# systemctl enable dnsmasq

Allow DNS requests from your clients to get to the service:

# firewall-cmd --permanent --add-port=53/tcp
# firewall-cmd --permanent --add-port=53/udp
# firewall-cmd --reload
# firewall-cmd --list-all

Client side

On the hosts in my lab, it’s just a matter of pointing them at the server running dnsmasq. So either:




Line in /etc/sysconfig/network-scripts/ifcfg-ethX file:


And then simply use the “dig” or “host” command to test:

[root@rhvi network-scripts]# dig rhvh01

; <<>> DiG 9.9.4-RedHat-9.9.4-29.el7 <<>> rhvh01
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 50507
;; flags: qr aa rd ra ad; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0

;rhvh01.                IN    A

rhvh01.            0    IN    A

;; Query time: 0 msec
;; WHEN: Thu Nov 03 12:53:59 EDT 2016
;; MSG SIZE  rcvd: 40

[root@rhvi ~]# dig -x

; <<>> DiG 9.9.4-RedHat-9.9.4-29.el7 <<>> -x
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 20587
;; flags: qr aa rd ra ad; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0

;    IN    PTR

;; ANSWER SECTION: 0    IN    PTR    rhvi.fog.com.

;; Query time: 0 msec
;; WHEN: Thu Nov 03 12:54:32 EDT 2016
;; MSG SIZE  rcvd: 70

In the “answer section” above, we see that we got resolution and the reply came from the local server. We follow that up with a reverse lookup (with the “-x” option).

In the example below, we’re in a remote host pointed at the DNS (dnsmasq) server, inquiring about the RHV-M server that we’re about to deploy in hosted engine configuration (hint-hint)..

[root@rhvh01 ~]# host rhvm
rhvm.fog.com has address
[root@rhvh01 ~]# host domain name pointer rhvm.fog.com.
[root@rhvh01 ~]#

That’s it, really… easy to set up on the server and client side…

Many thanks

The following blogs/links were incredibly helpful in getting me up and running!!

  • https://www.linux.com/learn/dnsmasq-easy-lan-name-services
  • http://stackoverflow.com/questions/32852975/reverse-dns-lookup-with-consul-and-dnsmasq

Hope this helps,

Captain KVM



5 thoughts on “RHV and DNS”

  1. Instead of replacing dnsmasq.conf you can drop your config file in ./etc/dnsmasq.d and not have to worry about your config file getting clobbered during a patch run.

  2. Can the DNS reside in the RHV host itself instead of on the other machine? What if doing a HA setup, do we need to install DNS service on each host and define the FQDN?

    1. Hi there,

      Thanks for stopping by. I wouldn’t put the DNS server on the same VM as RHV-M. The RHV-M application needs DNS, so DNS needs to be already up and running before RHV-M even exists. You don’t need to have a DNS service on each host – just point each host at the DNS service/server (/etc/resolv.conf).

      hope this helps,

      Captain KVM

Agree? Disagree? Something to add to the conversation?