#TIL : Setup wildcard domains .test for development in MacOS

Apr 24, 2018 4 mins read 8d4302659

Setup wildcard domains .test for development in MacOS

Too tired of setting your local domain each time you create new virtual development domain, etc helloworld.test, unit.test point to

There is a better way to achieve that by using dnsmasq, then set up a wildcard domains for development. In this case I use .test because .dev has been owned by Google and they strictly use HTTPS in mainly browsers.

Install dnsmasq

$ brew install dnsmasq

Adding .test wildcard to config file

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

Setup dnsmasq as a startup service

$ sudo brew services start dnsmasq

Then add (dnsmasq IP) as first DNS resolver

System Preferences > Network > Wi-Fi > Advanced... > DNS > add > move it to top of the list.

Checking everything is worked by listing all resolvers

$ scutil --dns

Try it out

$ nslookup -type=a something.test
$ ping helloworld.test
comments powered by Disqus