Changing dnsmasq configuration to use a custom DNS server

Tobias Etzold • June 26, 2026

linux laravel

I've recently run into a special scenario on my Ubuntu based Linux PC. For PHP development I'm using Laravel Valet. Under the hood Valet for Linux is using dnsmasq. But I've configured a custom DNS server which is running in my local network. It is serving custom domains just for my local network. But after installing Valet I couldn't reach any of these domains.

The reason why this is happening lies in dnsmasq and how Valet configures it. Under /opt/valet-linux are several files. Two of them are important for us. In dns-servers are all addresses like they are configured for your network interface. If you use DHCP this could be empty. If this case occurs, your system is unable to reach any domain except the ones Valet knows. For this case, there is a second file custom-nameservers. In this file are all nameservers you want to add to this list. As a default 1.1.1.1 is set, which belongs to Cloudflare. This default gets added on top of your dns-servers file. As a result your custom dns server can't be reached as all requests will be sent to 1.1.1.1. If you delete this IP from your custom-nameserver file it will be readded after you restart your system.

The solution to this problem is really simple. Just edit your /opt/valet-linux/custom-nameservers file and remove the dns which is configured there. So even after a reboot you can reach your custom DNS.