This guide will show you how to install Dnsmasq on FreeNAS and configure it so that your Virtual Lab can resolve hostnames to IP addresses.
In my last post, I wrote a tutorial on
how to install FreeNAS on VMware Fusion for use in a VMware vSphere Virtual Lab. Another service that you may need when building a vSphere lab is a DNS server so that vCenter can resolve its FQDN and the domain names of your ESXi hosts.
You can either create a separate VM and install Dnsmasq or since you’re likely to be configuring centralized storage to test out VMotion and HA, you can use FreeNAS. This guide will show you how.
Before we begin, you should have created a
VMware Fusion* VM and installed FreeNAS. If you followed the steps in the last tutorial, you will have a VM that’s connected to a custom VMware Fusion network with a management IP of
10.1.1.201 and a gateway of
Okay, let’s do this.
Step 1: Create a Jail
Login to the FreeNAS web interface, click on
Jails, select a pool and click CHOOSE.
dnsmasq for the name, select Basejail for the type, select 11.3-RELEASE then click NEXT.
VNET, select vnet0 for the interface, type an IP address that is on the same subnet as the management IP, enter the gateway IP in the defaut router field then click NEXT.
SUBMIT and wait a few minutes for the Jail to be created.
Click the arrow on the right.
START to power the Jail on. Step 2: Install Dnsmasq
Click on the
SHELL button to login to the Jail.
Run the following command to install Dnsmasq.
pkg install dnsmasq vim
Wait a few minutes for the packages to be installed.
Step 3: Configure Dnsmasq
At the shell run the following command to open the
dnsmasq.conf file for editing.
Add the following config to the start of the file.
# Global settings
# Upstream nameservers
# domain name
The listening address should be the same as the one specified when creating the Jail. You may also want to change the upstream servers.
Run the following command to start Dnsmasq when the Jail starts.
service dnsmasq start
Step 4: Add Some Hosts
Adding hosts to lookup is easy with Dnsmasq. It’s done exactly the same way as you would edit your local hosts file. Open
/etc/hosts and add the following entries.
10.1.1.11 esxi01.vpshere.lab esxi01
10.1.1.12 esxi02.vsphere.lab esxi02
10.1.1.100 vc01.vsphere.lab vc01
Restart Dnsmasq to apply the changes.
service dnsmasq restart
Step 5: Test DNS Lookups
Now if you change the DNS server of vCenter or your ESXi host to the IP address of the
dnsmasq Jail, you should be able to lookup the hostnames we just specified above.
The following screen shot shows an ESXi hosts DNS Server being changed to the dnsmasq server IP.
And here we can see the DNS lookup has worked by testing a ping to esxi02.vpshere.lab.
That’s it. You now have a combined iSCSI and DNS Server in your lab without having to build an extra VM dedicated to DNS.