DNSmasq wildcard on Ubuntu 18/20
sudo apt install -y dnsmasq
sudo apt install -y resolvconf
💡 The dnsmasq service will fail to start, you can ignore those errors for time being
Disable the default systemd-resolved service
sudo systemctl disable systemd-resolved.service
sudo systemctl stop --full systemd-resolved
💡 You internet might not be working at this moment, we will make it work again in next steps.
Remove this file (we will regenerate it later)
sudo rm /etc/resolv.conf
Update /etc/NetworkManager/NetworkManager.conf
file like.
[main]
plugins=ifupdown,keyfile
dns=default
rc-manager=resolvconf
[ifupdown]
managed=false
[device]
wifi.scan-rand-mac-address=no
Create a new file /etc/dnsmasq.d/test-tld.conf
with this content
address=/test/127.0.0.1
Restart NetworkManager which will generate a new /etc/resolv.conf
file
sudo systemctl restart network-manager.service
Finally restart dnsmasq service
sudo systemctl restart dnsmasq.service
Test if it works with fake domains having test
tld
host bogus.test
reserved comment