Step 5. Install and Configure Dnsmasq - xuan103/class-2020-07 GitHub Wiki
Step 1: Installing Dnsmasq on Ubuntu 18.04
Run the following commands to disable the resolved service:
$ sudo systemctl disable systemd-resolved
$ sudo systemctl stop systemd-resolved
Also, remove the symlinked resolv.conf file
$ ls -lh /etc/resolv.conf
lrwxrwxrwx 1 root root 39 Aug 8 15:52 /etc/resolv.conf -> ../run/systemd/resolve/stub-resolv.conf
$ sudo rm /etc/resolv.conf
Then create new resolv.conf file.
$ sudo nano /etc/resolv.conf
nameserver 8.8.8.8
$ sudo apt-get install dnsmasq
$ sudo nano /etc/dnsmasq.conf
If you want to enable DNSSEC validation and caching, uncomment
#dnssec
Make any other changes you see relevant and restart dnsmasq when done:
$ sudo systemctl restart dnsmasq
Step 2: Adding DNS records to Dnsmasq
$ sudo vim /etc/hosts
10.1.3.4 server1.mypridomain.com
10.1.4.4 erp.mypridomain.com
192.168.10.2 checkout.mypridomain.com
192.168.4.3 hello.world
$ sudo systemctl restart dnsmasq
Step 3: Testing Dnsmasq DNS functionality
$ sudo vim /etc/resolv.conf
nameserver 127.0.0.1
nameserver 8.8.8.8
#Configure Dnsmasq as DHCP Server
- Default gateway IP address
- DNS server IP address (Probably Dnsmasq or different DNS server)
- Network Subnet mask
- DHCP Addresses range
- NTP server
See below example
dhcp-range=192.168.40.130,192.168.40.230,24h
dhcp-option=option:router,192.168.40.254
dhcp-option=option:dns-server,192.168.40.254
dhcp-option=option:netmask,255.255.255.0
Restart dnsmasq and configure clients to obtain an IP address from this server.
$ sudo systemctl restart dnsmasq