Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pandaskii/13744293770e18d454de46cad88127ce to your computer and use it in GitHub Desktop.
Save pandaskii/13744293770e18d454de46cad88127ce to your computer and use it in GitHub Desktop.
Install dnsmasq on macos m1

Install dnsmasq with brew:

$ brew install dnsmasq

Setup *.test hosts with:

$ echo 'address=/.test/127.0.0.1' >> /opt/homebrew/etc/dnsmasq.conf

If want to use other device to resolv nameserver ( default only 127.0.0.1 )

$ 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

Start service:

$ sudo brew services start dnsmasq

If found Error like this:

$ Error: Failure while executing; /bin/launchctl bootstrap system /Library/LaunchDaemons/homebrew.mxcl.dnsmasq.plist exited with 37.

Try to restart services:

$ sudo brew services restart dnsmasq

Should see:

$ Successfully started dnsmasq (label: homebrew.mxcl.dnsmasq)

Add resolver:

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

Test:

$ ping abcd.ef.test

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