Using dnsmasq with VMware Workstation

Having changed the internal DNS server of my home network recently, I started having DNS issues on VMWare Workstation guests that are using NAT network connections. Somehow, guests could not get routes to Internet hostnames. The problem persisted after reinstalling VMware. QEMU and VirtualBox guests using similar configuration and running on the same host were behaving just fine. So, I struggled for a few days to try and figure where the issue was coming from in order to fix it. In the end, I couldn't find how why NAT was broken and finally gave up.

And then, I stumbled across this blog post by Nelson Elhage. The workaround he suggested was simple enough to implement so I figured I would give it a try.

This is what my dnsmasq configuration looks like (/etc/dnsmasq.conf):

##### VMWare custom DNS config #####
# Web ref: https://blog.nelhage.com/2010/10/dnsmasq-and-vmware/
listen-address=172.16.140.1
listen-address=127.0.0.1
no-dhcp-interface=lo

# Location of the actual DNS
server=192.168.1.1
local=/vmware/

# Only resolve hosts within the domain
no-hosts
no-resolv
domain=vmware
dhcp-fqdn

# Only use the 10 - 200 range
dhcp-range=172.16.140.10,172.16.140.200,36h
dhcp-authoritative

# VMware gateway route is on .2
dhcp-option=option:router,172.16.140.2

Once everything was configured to my likings, I simply unchecked the internal VMware DHCP server in the Virtual Network Editor, restarted the host networking services (systemctl restart networking) and booted my VMware guests.