Skip to content

Instantly share code, notes, and snippets.

@hanvari
Created December 6, 2020 05:07
Show Gist options
  • Save hanvari/5d72871bd7dd10c1b5e1a8bdab12d6db to your computer and use it in GitHub Desktop.
Save hanvari/5d72871bd7dd10c1b5e1a8bdab12d6db to your computer and use it in GitHub Desktop.
DNS Service in macOS

Configuring DNS Service (dnsmasq) for macOS

1. Installing dnsmasq

$ brew update && brew upgrade
$ brew install dnsmasq
# defaults to: /usr/local/etc
$ mkdir -pv $(brew --prefix)/etc/
$ sudo mkdir -v /etc/resolver
 

2. Configuration Files

(Assuming we are managing '.test' TLD)

/usr/local/etc/dnsmasq.conf

# Add a new ‘address’ line for each TLD you want to add.
# IP address at the end, shows the node which hosts the TLD, or has DNS service.
address=/.test/127.0.0.1
port=53

/etc/resolver/test

# always 127.0.0.1, referring to the local dnsmasq service
nameserver 127.0.0.1

3. Running DNS Service

Starting service now and at login from now on:

$ sudo brew services start dnsmasq

4. Testing

$ ping -c 1 myproject.test

References:

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