Stop Using Hosts
This article show the configuration of dnsmasq using macports. So all your .test domains are resolved locally
Inspired by the work of Steven Rombauts
Steve did a great job creating this guide but he uses brew, so I just decided to create the same guide but for macports.
Install dnsmasq with macports
Edit dnsmasq.conf
On /opt/local/etc we should edit the dnsmasq.conf file and add the following line at the very end of the document
This line will load all the files that end on .conf extension from the /opt/local/etc/dnsmasq.d directory
Create dnsmasq.d directory
Inside the folder /opt/local/etc/ execute the following command:
Inside the dnsmasq.d folder create the development.conf file
Inside the development.conf file add the following line
This will make that every domain that ends on .test will resolve to the local IP address 127.0.0.1
Only send .test queries to dnsmasq
To make this we need to create a folder on the /etc/ directory
Inside the resolver directory execute the following command:
Now inside the test file add the following content:
This will create a resolver for the .test tld.
Activate dnsmasq
And that it’s all, you should be able to resolve any domains that ends on .test to your local machine.
Notes
As Steven stated in the original document:
“Sometimes it can take a little while before the new configuration is applied. We can check that our new resolvers are registered with the
scutil --dnscommand.”
If all goes well you should see something like this:
You can also test to see if everything is still well as Steven says:
mysite.test results should be like this
PING mysite.test (127.0.0.1): 56 data bytes
64 bytes from 127.0.0.1: icmp_seq=0 ttl=64 time=0.040 ms
That is all