Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Setup dnsmasq on OS X

Never touch your local /etc/hosts file in OS X again

To setup your computer to work with *.test domains, e.g. project.test, awesome.test and so on, without having to add to your hosts file each time.



brew install dnsmasq


Create config directory

mkdir -pv $(brew --prefix)/etc/

Setup *.test

echo 'address=/.test/' >> $(brew --prefix)/etc/dnsmasq.conf

Change port for High Sierra

echo 'port=53' >> $(brew --prefix)/etc/dnsmasq.conf

Autostart - now and after reboot

sudo brew services start dnsmasq

Add to resolvers

Create resolver directory

sudo mkdir -v /etc/resolver

Add your nameserver to resolvers

sudo bash -c 'echo "nameserver" > /etc/resolver/test'


That's it! You can run scutil --dns to show all of your current resolvers, and you should see that all requests for a domain ending in .test will go to the DNS server at

N.B. never use .dev as a TLD for local dev work. .test is fine though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment