home tools books contact

Using FreeNAS as a DNS Server for your VMware vSphere Virtual Lab

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 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.

FreeNAS Create Dnsmasq Jail Step 1

Click ADD.

FreeNAS Create Dnsmasq Jail Step 2

Type dnsmasq for the name, select Basejail for the type, select 11.3-RELEASE then click NEXT.

FreeNAS Create Dnsmasq Jail Step 3

Enable 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.

FreeNAS Create Dnsmasq Jail Step 4

Click SUBMIT and wait a few minutes for the Jail to be created.

FreeNAS Create Dnsmasq Jail Step 5

Click the arrow on the right.

FreeNAS Create Dnsmasq Jail Step 6

Click START to power the Jail on.

FreeNAS Create Dnsmasq Jail Step 7


Step 2: Install Dnsmasq

Click on the SHELL button to login to the Jail.

FreeNAS Create Dnsmasq Jail Step 8

Run the following command to install Dnsmasq.

pkg install dnsmasq vim

Wait a few minutes for the packages to be installed.

FreeNAS Create Dnsmasq Jail Step 9


Step 3: Configure Dnsmasq

At the shell run the following command to open the dnsmasq.conf file for editing.

vim /usr/local/etc/dnsmasq.conf

Add the following config to the start of the file.

# Global settings

# Upstream nameservers

# domain name


Run the following command to start Dnsmasq when the Jail starts.

sysrc dnsmasq_enable="YES"

Start Dnsmasq

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.   esxi01.vpshere.lab esxi01   esxi02.vsphere.lab esxi02  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.

FreeNAS Create Dnsmasq Jail Step 10

And here we can see the DNS lookup has worked by testing a ping to esxi02.vpshere.lab.

FreeNAS Create Dnsmasq Jail Step 11



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.

Written by: Tony Mackay

ESXi Fusion FreeNAS

* GraspingTech participates in various affiliate marketing programs, which means we may earn a small commission at no additional cost to you, should you click on a link to a product and make a purchase.