Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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

This comment has been minimized.

Copy link

@EugenMayer EugenMayer commented Jun 15, 2018

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

@nguyenvanduocit

This comment has been minimized.

Copy link

@nguyenvanduocit nguyenvanduocit commented Jul 11, 2018

Use .local or .loc instead

@rhuiser

This comment has been minimized.

Copy link

@rhuiser rhuiser commented Nov 4, 2018

Great article. Clear written and works.

@brablc

This comment has been minimized.

Copy link
Owner Author

@brablc 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
You can’t perform that action at this time.