Keywords: Install dnsmasq, Ubuntu 18.04, DNS, DHCP
Follow the steps mentioned in this post to install dnsmasq in Ubuntu 18.04 LTS.
Step 1. Free port 53 to use with dnsmasq
Ubuntu 18.04 uses systemd-resolve service that is bind with port 53.
Execute following commands to disable and stop this service.
1 2 |
$ sudo systemctl disable systemd-resolved $ sudo systemctl stop systemd-resolved |
Remove the symlinked file and remove old /etc/resolv.conf file.
Before removing old file, make a backup copy in case something goes wrong.
1 2 3 |
$ ls -lh /etc/resolv.conf $ sudo cp /etc/resolv.conf /etc/resolv.bkp.conf $ sudo rm -f /etc/resolv.conf |
Step 2. Create a new “resolv.conf” file
Execute following command to create the file with required content in it.
1 |
$ echo "nameserver 8.8.8.8" | sudo tee /etc/resolv.conf |
Step 3. Install “dnsmasq” using apt repository
1 |
$ sudo apt-get install dnsmasq |
Step 4. Check version after Installation
1 |
$ dnsmasq -v |
Step 5. Add DNS records to dnsmasq
Open /etc/hosts file and add the records. I have added test.techawarey.com with IP 192.168.10.19
1 2 3 |
$ sudo gedit /etc/hosts 192.168.10.19 test.techawarey.com |
After adding required DNS records restart dnsmasq service to take effect.
1 |
$ sudo systemctl restart dnsmasq |
Step 6. Check dnsmaq Functionality using ‘dig’
Execute following command
1 |
$ dig test.techawarey.com |
You will see the output like below screenshot. You can see the IP it returned is 192.168.10.19 (we added it in DNS records)
Please like and share Techawarey. Find and Like Techawarey on Facebook.😊