How to Install and Configure dnsmasq in Linux


Dnsmasq is a lightweight DNS forwarder and resource constrained routers and firewalls. It is widely used for tethering on smartphones and portable hotspots, and to support virtual networking in virtualisation frameworks. Dnsmasq is included in most Linux distributions like FreeBSD, OpenBSD and NetBSD.

Step 1: Install dnsmasq

First install dnsmasq package using yum command.

# yum -y install dnsmasq

Step 2: Configuration

Configure dnsmasq service as per following settings.

# vi /etc/dnsmasq.conf
# line 19: uncomment (never forward plain names)
# line 21: uncomment (never forward addresses in the non-routed address spaces)
# line 41: uncomment (query with each server strictly in the order in resolv.conf)
# line 55: add if you need
# query the specific domain name to the specific DNS server
# the example follows means query [] domain to the [] server
# line 123: uncomment (add domain name automatically)
# line 133: add (define domain name)

Step 3: Start Service

Run the DHCP service by using below command and start service.

# systemctl start dnsmasq
# systemctl enable dnsmasq

Step 4: Entry in hosts file

# vi /etc/hosts   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
# add records   dlp.tecdistro dlp 

Restart the dnsmasq service.

# systemctl restart dnsmasq

Step 5: Add service in firewall

# firewall-cmd --add-service=dns --permanent 
# firewall-cmd --reload 
0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *