ubuntu 16.04.6-安装dnsmasq

1.程序安装:

apt-get install dnsmasq

不到半分钟就可以完成安装。

2.修改配置文件/etc/dnsmasq.conf最后一行:

conf-dir=/etc/dnsmasq.d/,*.conf
# Include all files in a directory which end in .conf

3.编写配置文件,/etc/dnsmasq.d/中任意文件名,后缀conf。

配置参数:

监听地址:

 listen-address=127.0.0.1,172.16.1.101

本地域名:

 server=/d.zhaoxugeng.cn/127.0.0.1  #d.zhaoxugeng.cn已设置ns记录到本服务器

本地域名数据保存地址:

 addn-hosts=/etc/banner_add_hosts

4.新建/etc/banner_add_hosts文件并写入数据:

 172.21.1.101 pc.d.zhaoxugeng.cn

5.启动Dnsmasq:

 service dnsmasq start

查看53端口:

 netstat -tunlp |grep 53

每次修改banner_add_hosts文件或者配置文件后需要重启服务:

 service dnsmasq restart

6.测试一下效果:

C:\Users\Administrator>nslookup
默认服务器: UnKnown
Address: 192.168.42.129

> pc.d.zhaoxugeng.cn
服务器: UnKnown
Address: 192.168.42.129

非权威应答:
名称: pc.d.zhaoxugeng.cn
Address: 172.21.1.101

> pc.d.zhaoxugeng.cn 106.13.77.136
服务器: [106.13.77.136]
Address: 106.13.77.136

非权威应答:
名称: pc.d.zhaoxugeng.cn
Address: 172.21.1.101

> pc.d.zhaoxugeng.cn 1.2.4.8
服务器: [1.2.4.8]
Address: 1.2.4.8

非权威应答:
名称: pc.d.zhaoxugeng.cn
Address: 172.21.1.101

>