Skip to content

Instantly share code, notes, and snippets.

@brablc
Forked from ogrrd/dnsmasq OS X.md
Last active September 24, 2021 10:24
Show Gist options
  • Star 21 You must be signed in to star a gist
  • Fork 8 You must be signed in to fork a gist
  • Save brablc/f48fef6336765212360ed3de66034b90 to your computer and use it in GitHub Desktop.
Save brablc/f48fef6336765212360ed3de66034b90 to your computer and use it in GitHub Desktop.
Setup dnsmasq on OS X

Never touch your local /etc/hosts file in OS X again

To setup your computer to work with *.test domains, e.g. project.test, awesome.test and so on, without having to add to your hosts file each time.

Requirements

Install

brew install dnsmasq

Setup

Create config directory

mkdir -pv $(brew --prefix)/etc/

Setup *.test

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

Change port for High Sierra

echo 'port=53' >> $(brew --prefix)/etc/dnsmasq.conf

Autostart - now and after reboot

sudo brew services start dnsmasq

Add to resolvers

Create resolver directory

sudo mkdir -v /etc/resolver

Add your nameserver to resolvers

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

Finished

That's it! You can run scutil --dns to show all of your current resolvers, and you should see that all requests for a domain ending in .test will go to the DNS server at 127.0.0.1

@EugenMayer
Copy link

why you are still suggesting people to use .dev .. after what google did in Jan 2018. odd.

@nguyenvanduocit
Copy link

Use .local or .loc instead

@rhuiser
Copy link

rhuiser commented Nov 4, 2018

Great article. Clear written and works.

@brablc
Copy link
Author

brablc commented Dec 6, 2019

why you are still suggesting people to use .dev .. after what google did in Jan 2018. odd.

Somehow comments from this Gist do not reach my mailbox. Sorry for the late change. Yes we have changed to .test two years ago.

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