Lightweight DNS Server--DNSmasq


    Dnsmasq is a lightweight DNS server. It is also an open source project with simple and fast configuration. Dnsmasq provides DNS caching and DHCP services. As a domain name resolution server (DNS), dnsmasq can cache DNS requests to improve the connection speed of visited Web sites. As a DHCP server, dnsmasq can provide intranet ip address and routing for LAN computers. DNS and DHCP functions can be implemented simultaneously or separately. Dnsmasq is lightweight and easy to configure. In addition, it comes with a PXE server, support for mx records of mail servers, support for srv records of jabber, etc.

Deployment environment:

Centos 6.5 x86_64 Operating System

When dnsmasq is used, packages in the base source can be installed and deployed directly.

# yum list | grep dnsmasq
dnsmasq.x86_64                              2.48-17.el6                  @base 
dnsmasq-utils.x86_64                        2.48-17.el6                  base

Install the dnsmasq package:

#yum -y install dnsmasq

Backup before operation:

# cp /etc/dnsmasq.conf /etc/dnsmasq.conf.bak

# View the installation file path of dnsmasq:

# rpm -ql dnsmasq
/etc/dnsmasq.conf            #Master Profile

Point the local resolv parse file configuration to the local machine:

#echo 'nameserver' > /etc/resolv.conf

copy as an analytical configuration file for dnsmasq:

cp /etc/resolv.conf /etc/resolv.dnsmasq.conf
echo 'nameserver' > /etc/resolv.dnsmasq.conf

The configuration files used by dnsmasq are as follows:

# cat /etc/dnsmasq.conf  | grep -v '^#' | grep -v '^$'
addn-hosts=/etc/hosts    #Domain name mapping file

The contents of the other two profiles:

[root@sh-puppet-node2 etc]# cat /etc/resolv.conf

[root@sh-puppet-node2 etc]# cat /etc/resolv.dnsmasq.conf
nameserver        #Four 8 Google's dns servers may be slower

Add domain name mapping

# cat /etc/hosts   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6

Start the dnsmasq service:

# /etc/init.d/dnsmasq restart
Shutting down dnsmasq:                                     [  OK  ]
Starting dnsmasq:                                          [  OK  ]

Test the ip to view domain name resolution:

# dig

In order to prevent the local domain name from duplicating some domain names on the public network, it was changed to       

[root@sh-puppet-node2 ~]# cat /etc/resolv.conf
; generated by /sbin/dhclient-script
search shjygw com
[root@sh-puppet-node2 ~]# cat /etc/resolv.dnsmasq.conf

Baidu found that the test ping baidu is not ok, but does not affect intranet domain name resolution:

[root@sh-puppet-node2 ~]# ping

ping: unknown host

Explanation: If the picture is destroyed, it will not be displayed. If you have time to fill it up.

Tags: DNS yum DBus CentOS

Posted on Sun, 16 Jun 2019 10:57:19 -0700 by stebbi