Local Development - Dot Test Localhost

Many serious developer had configured their local development to be served through Dot DEV TLD domains. Few months back chrome blocked its use. Currently it appears as though .test and .localhost are the to go domains. This is how you can configure your local machine to serve .test (or .localhost) for your projects. I will how ever not go to the extent to configuring a web server.


We will configure our networks to forward DNS queries to localhost. There we will intercept the queries and resolve .test TLDs to point back to localhost. Any other query should be forwarded to an actual DNS server. How ever we would be in conflict with systemd-resolved which we will disable. Then we will install and configure dnsmasq. There after we will configure NetworkManager to use dnsnasq. Finally we will configure nginx to use a locally served .test domain.

Disabling systemd-resolved

Lets first disable and stop what would be on our way. systemd-resolved will be occupying port 53 which will be used by dnsmasq.

#~ sudo systemctl disable systemd-resolved.service
#~ sudo service systemd-resolved stop

You can any time undo this simply by enable the service.

Installing and configuring dnsmasq

dnsmasq is a neat tool that can be used to forward DNS resolutions. Install it using…

#~ sudo apt install dnsmasq

Notice: If you get a warning at the end of the installation regarding socket already been used, it might be because you didn’t run the previous step.

Then we will configure dnsmasq. We will do 3 things here. First we will make dnsmasq to listen to localhost. Then we will say which DNS sever it could use to resolve domains. For this you will need to add 2 lines to the /etc/dnsmasq.conf file. I use VIM so it will be like…

#~ sudo vim /etc/dnsmasq.conf

There add the lines…


Then we will tell dnsmasq to point .test domains to localhost. Create a config file for the new TLD and add the following line.

#~ sudo vim /etc/dnsmasq.d/test

Content… you may need to make the following test to localhost or what ever you want.


Configuring Network Manager

You will first configure your network connection (ex: WiFi) to use` (localhost) for the DNS.

Then we will edit /etc/NetworkManager/NetworkManager.conf. Add dns=dnsmasq.

#~ cat /etc/NetworkManager/NetworkManager.conf 



Then sudo service network-manager restart.

You should be good to go… Next would be to configure Nginx or your favorite web server and host your projects locally.