Dnsmasq simple application

Compared to offer Bind DNS resolution service, Dnsmasq whether used or the configuration is faster and simpler, especially some of the test scenarios and SOHO office terms, can be used as a DNS Server to use.

1. System Environment

Ubuntu 18.04

2. Install

apt-get install dnsmasq

3. Configuration

vim /etc/dnsmasq.conf

#监听本机ip地址
listen-address=10.100.33.50

#用于非本地主机解析记录解析的dns列表
resolv-file= /etc/dnsmasq.d/resolv.dnsmasq.conf 

#实际解析按照resolv-file中从上到下dns server的顺序进行指派解析
strict-order 

#本地主机解析记录
addn-hosts=/etc/hosts 
vim /etc/dnsmasq.d/resolv.dnsmasq.conf
server = 114.114.114.114
server = 233.5.5.5
vim /etc/hosts
#解析记录
10.10.33.22 office.zabbix.you.cn
10.10.33.21 office.grafana.you.cn
vim /etc/resolv.conf 
#本机的dns配置
nameserver 114.114.114.114

4. Test

By local network dns 10.100.33.50 test domain name

dig office.zabbix.you.cn @10.100.33.50 +short
10.10.33.22
dig office.grafana.you.cn @10.100.33.50 +short
10.10.33.21

5. Test the DNS cache

First analysis sina domain name, and have not visited due before the domain name, query time of 62 msec

dig [www.sina.cn](http://www.sina.cn) A @10.100.33.50 | grep Query
;; Query time: 62 msec

The second time sina resolve domain name, query time has been reduced to 3 msec

dig [www.sina.cn](http://www.sina.cn) A @10.100.33.50 | grep Query
;; Query time: 3 msec

Guess you like

Origin blog.51cto.com/talk1985/2404936