Computer man
Configure Dnsmasq

Install Dnsmasq which is the lightweight DNS forwarder and DHCP Server Software.

Install Dnsmasq:-

[root@server ~]# yum -y install dnsmasq

Configure Dnsmasq:-

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

[root@server ~]# systemctl start dnsmasq

[root@server ~]# systemctl enable dnsmasq

For DNS records, add them in /etc/hosts. Then, Dnsmasq will answer to queries from clients.


[root@server ~]# vi /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
# add records
10.0.0.30 server.example.com

[root@server ~]# systemctl restart dnsmasq

If Firewalld is running, allow DNS service.

[root@server ~]# firewall-cmd --add-service=dns --permanent
success
[root@server ~]# firewall-cmd --reload
success

Verify to resolve Name or IP address from a client in internal network.

[root@client ~]# yum -y install bind-utils
# change DNS setting to Dnsmasq Server (replace "ens3" to your own environment)

[root@client ~]# nmcli c modify ens3 ipv4.dns 10.0.0.30
[root@client ~]# nmcli c down ens3; nmcli c up ens3

[root@client ~]# dig server.example.com.
[root@client ~]# dig -x 10.0.0.30
Please email me if you face any issue.

Name:

Email:

Comments:

views
PHP Hits Count