Difference between revisions of "Dnsmasq"

From UVOO Tech Wiki
Jump to navigation Jump to search
Line 16: Line 16:
 
sudo systemctl stop systemd-resolved
 
sudo systemctl stop systemd-resolved
 
sudo apt-get update && sudo apt-get install -y dnsmasq
 
sudo apt-get update && sudo apt-get install -y dnsmasq
echo "10.0.0.1  prod.example.com. >> /etc/dnsmasq.hosts"
+
# echo "10.0.0.1  prod.example.com. >> /etc/dnsmasq.hosts"
echo "10.0.0.2  dev.example.com. >> /etc/dnsmasq.hosts"
+
# echo "10.0.0.2  dev.example.com. >> /etc/dnsmasq.hosts"
 
# sudo systemctl unmask systemd-resolved
 
# sudo systemctl unmask systemd-resolved
 
# sudo systemctl enable systemd-resolved
 
# sudo systemctl enable systemd-resolved
 +
```
 +
 +
/etc/dnsmasq.hosts
 +
```
 +
10.0.0.1  prod.example.com.
 +
10.0.0.2  dev.example.com.
 
```
 
```
  
 
/etc/dnsmasq.conf
 
/etc/dnsmasq.conf
 
```
 
```
no-resolv
+
no-resolv # Don't read /etc/resolv.conf. Get upstream servers only from the command line or the dnsmasq  configuration file.
  
 
# Google's nameservers, for example
 
# Google's nameservers, for example
 
server=8.8.8.8
 
server=8.8.8.8
 
server=8.8.4.4
 
server=8.8.4.4
 +
addn-hosts=/etc/dnsmasq.hosts
 +
# ...
 +
```
  
addn-hosts=/etc/dnsmasq.hosts
+
```
...
+
systemctl restart dnsmasq
 
```
 
```

Revision as of 00:15, 22 August 2020

Related commands

  • sudo systemd-resolve --flush-caches

Files of Interest

/var/lib/misc/dnsmasq.leases

Stub Resolver

Install

sudo systemctl disable systemd-resolved
sudo systemctl mask systemd-resolved
sudo systemctl stop systemd-resolved
sudo apt-get update && sudo apt-get install -y dnsmasq
# echo "10.0.0.1  prod.example.com. >> /etc/dnsmasq.hosts"
# echo "10.0.0.2  dev.example.com. >> /etc/dnsmasq.hosts"
# sudo systemctl unmask systemd-resolved
# sudo systemctl enable systemd-resolved

/etc/dnsmasq.hosts

10.0.0.1  prod.example.com.
10.0.0.2  dev.example.com.

/etc/dnsmasq.conf

no-resolv  # Don't read /etc/resolv.conf. Get upstream servers only from the command line or the dnsmasq  configuration file.

# Google's nameservers, for example
server=8.8.8.8
server=8.8.4.4
addn-hosts=/etc/dnsmasq.hosts
# ...
systemctl restart dnsmasq