Drop Down MenusCSS Drop Down MenuPure CSS Dropdown Menu

How to Configure DNS (Dnsmasq )

Dnsmasq is a simple way to set up a DNS server for a small network, rather than going to the trouble of configuring BIND.


The Dnsmasq service is installed from a Yum repository using the following command.
# yum install dnsmasq
Turn on the Dnsmasq server and make sure it starts automatically on reboot.
# service dnsmasq start
# chkconfig dnsmasq on
Dnsmasq is configured by altering the contents of the "/etc/dnsmasq.conf" file and the contents of the "/etc/hosts" file.
The service can be stopped, started and restarted using the following commands.
# service dnsmasq stop
# service dnsmasq start
# service dnsmasq restart


If you are using the Linux firewall, you need to open port 53 specifically.
For the iptables firewall, use the following commands.
# iptables -I INPUT -p tcp --dport 53 -j ACCEPT
# iptables -I INPUT -p udp --dport 53 -j ACCEPT
# service iptables save
For the firewalld firewall, use the following commands to open the port for the current runtime and permanently to persist through reboots.
# firewall-cmd --zone=public --add-port=53/tcp
# firewall-cmd --zone=public --add-port=53/udp

# firewall-cmd --permanent --zone=public --add-port=53/tcp
# firewall-cmd --permanent --zone=public --add-port=53/udp


You don't need to do any specific DNS configuration as Dnsmasq will use the contents of the "/etc/hosts" to resolve any name requests. Anything it can't find there will be forwarded to the nameservers listed in the "/etc/resolv.conf" file.
For example, adding the following entries to the "/etc/hosts" file on the server running Dnsmasq, will allow it to act as a DNS, resolving those names.
# Oracle Linux 6 - RAC Installation   ol6-112-rac1.localdomain            ol6-112-rac1   ol6-112-rac2.localdomain            ol6-112-rac2   ol6-112-rac1-priv.localdomain       ol6-112-rac1-priv   ol6-112-rac2-priv.localdomain       ol6-112-rac2-priv   ol6-112-rac1-vip.localdomain        ol6-112-rac1-vip   ol6-112-rac2-vip.localdomain        ol6-112-rac2-vip   ol6-112-scan.localdomain            ol6-112-scan   ol6-112-scan.localdomain            ol6-112-scan   ol6-112-scan.localdomain            ol6-112-scan
Any machines in the network that need to use this DNS server for name resolution need their "/etc/resolv.conf" file amended so the "nameserver" entry points at this server.
search localdomain
Edit the "/etc/dnsmasq.conf" file to prevent local network queries being forwarded. My internal domain is called "localdomain", so I add the following setting, then restart Dnsmasq.



Popular posts from this blog

How to find the server is whether standby (slave) or primary(master) in Postgresql replication ?

How to Get Table Size, Database Size, Indexes Size, schema Size, Tablespace Size, column Size in PostgreSQL Database

7 Steps to configure BDR replication in postgresql

Postgres Streaming Replication Configuration

vacuumlo - removing large objects orphans from a database PostgreSQL