Skip to content

Instantly share code, notes, and snippets.

@aymanalzarrad
Last active March 2, 2018 16:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aymanalzarrad/9a4c70b9f39bfa68480e78822a9cb9e3 to your computer and use it in GitHub Desktop.
Save aymanalzarrad/9a4c70b9f39bfa68480e78822a9cb9e3 to your computer and use it in GitHub Desktop.
Setting up dnsmasq on Ubuntu 17.4/17.10 and pointing a TLD to a local ip address

Install

sudo apt update
sudo apt install dnsmasq

Point a TLD to a local ip

Replace test with your domain and xxx.xxx.xxx.xxx with your local ip address

sudo echo "local=/test/" > /etc/dnsmasq.d/test
sudo echo "address=/test/xxx.xxx.xxx.xxx" >> /etc/dnsmasq.d/test

Restart dnsmasq

sudo systemctl restart dnsmasq

Point systemd-resolved to dnsmasq

sudo nano /etc/systemd/resolved.conf

Find:

#DNS=
#FallbackDNS=

Replace with:

DNS=127.0.1.1
FallbackDNS=127.0.1.1

Restart systemd-resolved

sudo systemctl restart systemd-resolved

Test

Running: nslookup test.test, should print:

Server:		127.0.0.53
Address:	127.0.0.53#53

Non-authoritative answer:
Name:	test.test
Address: xxx.xxx.xxx.xxx

Note the Address: xxx.xxx.xxx.xxx should be our ip.

Running: systemd-resolve --status, should print:

Global
         DNS Servers: 127.0.1.1
         ...

Note the DNS Servers: 127.0.1.1

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