搭建DNS服务器

发布于 2021-02-22  677 次阅读


首先安装dnsmasq

sudo apt-get install dnsmasq

修改dnsmasq.conf配置文件

sudo nano -K /etc/dnsmasq.conf

listen-address=127.0.0.1,192.168.1.240,0.0.0.0
cache-size=10000
resolv-file=/etc/resolv.dnsmasq.conf
strict-order

设置IGNORE_RESOLVCONF

sudo nano -K /etc/default/dnsmasq
IGNORE_RESOLVCONF=yes

修改resolv.conf,添加上游DNS服务器

sudo nano -K /etc/resolv.dnsmasq.conf

nameserver 192.168.1.1
nameserver 223.5.5.5
nameserver 223.6.6.6
nameserver 8.8.8.8
nameserver 8.8.4.4
nameserver 114.114.114.114
nameserver 114.114.114.115
nameserver 101.6.6.6

开启dnsmasq服务

sudo systemctl restart dnsmasq
sudo systemctl enable dnsmasq

测试dnsmasq服务

sudo apt-get install  dnsutils

dig www.sina.cn A @127.0.0.1 | grep Query

dig www.sina.cn A @127.0.0.1 | grep Query

可以看到第二次请求的时间极大地缩短了


医学生