Skip to content

Instantly share code, notes, and snippets.

@ankurk91
Last active October 8, 2024 06:43
Show Gist options
  • Save ankurk91/2663db015712689126f38fc7bc5d4a8f to your computer and use it in GitHub Desktop.
Save ankurk91/2663db015712689126f38fc7bc5d4a8f to your computer and use it in GitHub Desktop.
DNSmasq on Ubuntu 18/20

DNSmasq wildcard on Ubuntu 18/20

  • Install dnsmasq
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

Sources

@ankurk91
Copy link
Author

reserved comment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment