dnsmasq not working on Mac OS Sierra

Solution 1:

Your dnsmasq daemon isn't properly configured.

Your external resolver is working: all queries to non-dev hosts/domains are forwarded to 3rd-party DNS servers with the resolv-file=/usr/local/etc/resolv-dnsmasq.conf line - in your case the configured file contains two public Google DNS servers.

Your internal resolver doesn't resolve internal names though.

The line address=/.dev/127.0.0.1 or better address=/dev/127.0.0.1 will redirect any *.dev query to the host 127.0.0.1. An internal resolver is not needed then and the internal name server defined in /etc/resolver/dev is useless.

Compare this with the example in the dnsmasq.conf file:

# Add domains which you want to force to an IP address here.
# The example below send any host in double-click.net to a local
# web-server.
#address=/double-click.net/127.0.0.1

Any query for *.double-click.net will be redirected to 127.0.0.1 and to an arbitrary website served at localhost.

I strongly recommend to define a hosts.config file and enter/define all necessary hosts there:

Add a line addn-hosts=/usr/local/etc/hosts/hosts.conf in dnsmasq.conf. Then add a folder with sudo mkdir /usr/local/etc/hosts and create a file hosts.conf

sudo nano /usr/local/etc/hosts/hosts.conf

with the following content:

127.0.0.1   localhost
127.0.0.1   test.dev
127.0.0.1   test2.dev
...

After saving the file reload your dnsmasq daemon.

If you want to use different IPs for your host names e.g.:

127.0.0.1   localhost
127.0.0.2   test.dev
127.0.0.3   test2.dev
...

you'd have to add additional IPs with:

sudo ifconfig lo0 alias 127.0.0.2 up
sudo ifconfig lo0 alias 127.0.0.3 up
...

Solution 2:

The .dev TLD is no longer usable by developers as a private TLD. I ran into this, and had to change things to use ".priv" or something else instead. The ".dev" TLD is no longer a private thing, as it now belongs to Google, and is treated in a special way by Chrome and other browsers.

Following is a clip from the following article: https://www.tomshardware.com/news/google-enforces-https-tld-hsts,35564.html

"Google announced that 45 of the top-level domains (TLDs) it recently purchased, including .dev, .app, .eat, and so on, will enforce HTTPS security, guaranteeing that all connections to sites using those TLDs will be over encrypted channels."