Taken from: https://www.stevenrombauts.be/2018/01/use-dnsmasq-instead-of-etc-hosts/ just in case it ever goes away.
brew update
brew install dnsmasq
Auto start with brew
sudo brew services start dnsmasq
Modify /usr/local/etc/dnsmasq.conf
and set/add the line:
conf-dir=/usr/local/etc/dnsmasq.d,*.conf
This will instruct dnsmasq to include all files that end with .conf
in the /usr/local/etc/dnsmasq.d
directory as additional configuration files.
mkdir -p /usr/local/etc/dnsmasq.d
pico /usr/local/etc/dnsmasq.d/development.conf
To get *.test
and *.ukwm166
add to /usr/local/etc/dnsmasq.d/development.conf
:
address=/test/127.0.0.1
address=/ukwm166/127.0.0.1
sudo brew services restart dnsmasq
dig foobar.test @127.0.0.1
sudo mkdir /etc/resolver
Create the file /etc/resolver/test
for .test
domains, and /etc/resolver/ukwm166
for .ukwm166
domains, and add this line:
nameserver 127.0.0.1
Run this command to show your resolvers listed near the end:
scutil --dns
ping -c 1 google.com # Make sure you can still access the outside world!
ping -c 1 mysite.test
ping -c 1 stuff.things.ukwm166