Inspired and adjusted from this gist.
- Install
dnsmasq
brew install dnsmasq
- Setup
mkdir -pv $(brew --prefix)/etc/
echo 'port=53' >> $(brew --prefix)/etc/dnsmasq.conf
# setup *.localhost
echo 'address=/.localhost/127.0.0.1' >> $(brew --prefix)/etc/dnsmasq.conf
- Restart
dnsmasq
,
sudo brew services start dnsmasq
- Add to resolvers
sudo mkdir -v /etc/resolver
sudo bash -c 'echo "nameserver 127.0.0.1" > /etc/resolver/localhost'
- Verify
scutil --dns
You should see a resolver like this:
resolver #9
domain : localhost
nameserver[0] : 127.0.0.1
flags : Request A records, Request AAAA records
reach : 0x00030002 (Reachable,Local Address,Directly Reachable Address)