1安装dnsmasq
yum install -y dnsmasq
2配置配置文件vim /etc/dnsmasq.conf
resolv-file=/etc/resolv.dnsmasq.conf
strict-order #dnsmasq会从resolv.dnsmasq.conf这个文件中找上游dns服务器。
listen-address=127.0.0.1 #让DNS只对本机有效,如果是自己所在的局域网,那就再加上自己的内网ip,比如listen-address=192.168.1.6,127.0.0.1
vim /etc/resolv.conf 设置成 nameserver 127.0.0.1
vim /etc/resolv.dnsmasq.conf nameserver 8.8.8.8 nameserver 115.115.115.115
vim /etc/dnsmasq.conf 增加addn-hosts=/etc/dnsmasq.hosts
cp /etc/hosts /etc/dnsmasq.hosts 把/etc/hosts拷贝过来
3,配置需要解析的域名
vim /etc/dnsmasq.hosts 添加 ip 域名
192.168.1.7 nexus.szhmxxkj.com
4.启动服务
service dnsmasq start
5测试本地能否解析域名
ping nexus.szhmxxkj.com
ping baidu.com
6关闭防火墙,或者开发53端口,设置其他电脑的d