Introduction

Dnsmasq is a lightweight DNS forwarder and DHCP server. This tutorial will guide you through the process of installing and configuring Dnsmasq as a local DNS resolver on Rocky Linux.

Prerequisites

Before you begin, ensure you have:

  1. A Rocky Linux system
  2. Root or sudo privileges

Step 1: Install Dnsmasq

Install Dnsmasq using the following command:

sudo dnf install -y dnsmasq

Step 2: Configure Dnsmasq

Edit the Dnsmasq configuration file:

sudo nano /etc/dnsmasq.conf

Add the following configuration to the file:

listen-address=127.0.0.1
bind-interfaces
domain-needed
bogus-priv
no-resolv
server=8.8.8.8
server=8.8.4.4

Save and close the file.

Step 3: Restart Dnsmasq

Restart the Dnsmasq service to apply the changes:

sudo systemctl restart dnsmasq

Step 4: Test DNS Resolution

Test DNS resolution using the nslookup command:

nslookup example.com

Step 5: Configure Network Settings

Update the network settings on your system to use the local DNS resolver. Edit the network configuration file:

sudo nano /etc/sysconfig/network-scripts/ifcfg-eth0

Add the following line to the file:

DNS1=127.0.0.1

Save and close the file. Restart the network service:

sudo systemctl restart NetworkManager

Conclusion

Congratulations! You have successfully installed a local DNS resolver with Dnsmasq on Rocky Linux. Your system is now configured to use Dnsmasq for DNS resolution.

Was this answer helpful? 0 Users Found This Useful (0 Votes)