Skip to content

Instantly share code, notes, and snippets.

@rmsj
Last active September 27, 2021 02:51
Show Gist options
  • Save rmsj/1c6bec74b22010030c70ac256fc8ec9a to your computer and use it in GitHub Desktop.
Save rmsj/1c6bec74b22010030c70ac256fc8ec9a to your computer and use it in GitHub Desktop.
Install and uninstall dnsmasq #Dnsmasq #TipsTricks

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.

Install

brew install dnsmasq

Setup

Create config directory if not created

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

Setup *.test

echo 'address=/.test/127.0.0.1' >> $(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'

Uninstall

To remove run the folowing commands in ths sequence.

sudo brew services stop dnsmasq
rm -f /usr/local/etc/dnsmasq.conf
sudo rm -rf /etc/resolver
brew uninstall --force dnsmasq

N.B. never use .dev as a TLD for local dev work. .test is fine though.

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