相比于Bind提供的DNS解析服务,Dnsmasq无论是使用或是配置上都更加快捷和简单,尤其是一些测试场景和SOHO办公方面,都可以用做DNS Server来使用。
Ubuntu 18.04
apt-get install dnsmasq
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
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
dig [www.sina.cn](http://www.sina.cn) A @10.100.33.50 | grep Query
;; Query time: 62 msec
dig [www.sina.cn](http://www.sina.cn) A @10.100.33.50 | grep Query
;; Query time: 3 msec
原文:https://blog.51cto.com/talk1985/2404936