$ brew install dnsmasq
$ echo 'address=/.test/127.0.0.1' >> /opt/homebrew/etc/dnsmasq.conf
$ echo 'listen-address=127.0.0.1,192.168.1.2' >> /opt/homebrew/etc/dnsmasq.conf
note:
- as dnsmasq configuration recommendation is to include 127.0.0.1
- 192.168.1.2 is ip of macos
- Change address above to macos IP 'address=/.test/192.168.1.2'
- For Macos WiFi sharing add more IP 'listen-address=127.0.0.1,192.168.1.2,192.168.2.1' the IP 192.168.2.1 is the gateway IP WiFi sharing
$ sudo brew services start dnsmasq
$ Error: Failure while executing; /bin/launchctl bootstrap system /Library/LaunchDaemons/homebrew.mxcl.dnsmasq.plist exited with 37.
$ sudo brew services restart dnsmasq
$ Successfully started dnsmasq (label: homebrew.mxcl.dnsmasq)
$ sudo mkdir /etc/resolver
$ sudo bash -c 'echo "nameserver 127.0.0.1" > /etc/resolver/test'
$ ping abcd.ef.test
If you are running into issue why
digornslookupstill doesn't work with your domain. It turns out they don't use the official system resolver on Mac OS (ref: https://stackoverflow.com/questions/50914268/os-x-etc-resolver-dev-isnt-working-why-not )Therefore, to test a domain . Use this