Skip to content

Instantly share code, notes, and snippets.

@dre1080
Forked from marek-saji/dev-tld.md
Last active April 18, 2020 10:52
Show Gist options
  • Save dre1080/02c82a7485872063d646a6945e5ada09 to your computer and use it in GitHub Desktop.
Save dre1080/02c82a7485872063d646a6945e5ada09 to your computer and use it in GitHub Desktop.
Configure local DNS server to serve *.localhost domains

Configure local wildcard DNS server

  1. Install Dnsmasq: sudo apt-get install dnsmasq

  2. Since Ubuntu's NetworkManager uses dnsmasq, and since that messes things up a little for us, open up /etc/NetworkManager/NetworkManager.conf and comment out (#) the line that reads dns=dnsmasq. Restart NetworkManager afterwards: sudo systemctl restart NetworkManager.

  3. Make sure Dnsmasq listens to local DNS queries by editing /etc/dnsmasq.conf, and adding the line listen-address=127.0.0.1.

  4. Create a new file in /etc/dnsmasq.d (eg. /etc/dnsmasq.d/localhost), and add the line address=/localhost/127.0.0.1 to have dnsmasq resolve requests for *.localhost domains.

  5. Restart Dnsmasq: sudo systemctl restart dnsmasq.

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