Redirecting all .dev to 127.0.0.1
Mar 4, 2025 #dns#dev
I took a habit to use the exact same url of my production websites on my local dev machine but adding .lcl to it and add all urls manually to /etc/hosts
If you’re like me and want to automaticaly redirect one or multiple tlds to one IP we can use dnsmasq
Setting up dnsmasq
First let’s install it
sudo apt install dnsmasq Then we’ell tell it to redirect all .lcl to localhost. For that let’s edit /etc/dnsmasq.conf
sudo vi /etc/dnsmasq.conf
and add the following lines at the end of the file
# local dev tld
address=/.lcl/127.0.0.1
# default DNS for other domains
server=8.8.8.8
server=8.8.4.4 Next we’ll stop and disable the systemd-resolved which might cause a conflict
sudo systemctl disable --now systemd-resolved sudo vi /etc/NetworkManager/NetworkManager.conf and add the following line to the [main] section
dns=dnsmasq then restart the everything
sudo systemctl restart NetworkManager
sudo systemctl restart dnsmasq