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.
- Homebrew
- Mountain Lion -> High Sierra
brew install dnsmasq
mkdir -pv $(brew --prefix)/etc/
echo 'address=/.test/127.0.0.1' >> $(brew --prefix)/etc/dnsmasq.conf
echo 'port=53' >> $(brew --prefix)/etc/dnsmasq.conf
sudo brew services start dnsmasq
sudo mkdir -v /etc/resolver
sudo bash -c 'echo "nameserver 127.0.0.1" > /etc/resolver/test'
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
Whats the significance of the resolver?
Has anyone used dnsmasq to setup a pre-production testing scenario?
For example:
mylivesite.com is on server 1.2.3.4
mylivesite.com is also migrated to a different server with updates on server 2.2.2.2
I can do this in /etc/hosts file easily enough, however I need to make sure subdomains are working, ideally it would be nice to use dnsmasq's wildcard feature that /etc/hosts can't utilize
echo 'address=/.mylivesite.com/2.2.2.2' >> $(brew --prefix)/etc/dnsmasq.conf
Right now, I can't figure out how to do this with dnsmasq, it's routing to the old server (ie 1.2.3.4)