admin管理员组文章数量:1530085
我们在浏览网页时,首先要通过DNS服务器来解析网站的地址,解析的时间虽然比较短,但如果DNS服务器的响应速度比较慢,或者DNS请求量过大,都会导致上网时等待时间过长,我们这里通过自己建立轻量级缓存DNS服务器来加快上网速度。同时,自建DNS服务器还可以避免DNS投毒,通过服务器来加快上网速度,提升上网体验。
首先安装dnsmasq这款软件,它可以将访问过的地址存储在本地,这样当给你再次访问这个网址时,就不用请求上级DNS服务器,极大的提高解析速度。
安装dnsmasq:
sudo apt-getinstall -y dnsmasq
接下来需要配置dnsmasq,打开dnsmasq的配置文件,路径一般是/etc/dnsmasq.conf,配置示例如下:
# Dnsmasq.conf
# /etc/dnsmasq.conf
#http://www.thekelleys.uk/dnsmasq/docs/dnsmasq.conf.example
# Set up your local domain here
domain=lxx1
resolv-file=/etc/resolv.dnsmasq
min-port=4096
server=8.8.8.8
server=8.8.4.4
# Max cache size dnsmasq can give us, and we want all of it!
cache-size=10000
# Below are settings for dhcp. Comment them out if you dont want
# dnsmasq to serve up dhcpd requests.
# dhcp-range=192.168.0.100,192.168.0.149,255.255.255.0,1440m
# dhcp-option=3,192.168.0.1
# dhcp-authoritative
如果你改动过设置,请重启服务:
sudo service dnsmasq restart
好的,DNS已经配置完毕。你可以使用dig lxx1 来测试,可以发现,第一次解析需要较长时间,而第二次解析的时间基本为0了。
可以使用 dig 命令来测试解析时间:
~$ dig lxx1
; <<>> DiG 9.9.5-3ubuntu0.2-Ubuntu <<>> lxx1
;; global options: +cmd
;; Got answer:
;; ->>HEADER<
;; flags: qr rd ra ad; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0
;; QUESTION SECTION:
;lxx1. IN A
;; ANSWER SECTION:
lxx1. 582 IN A 121.42.42.51
;; Query time: 1 msec
;; SERVER: 127.0.0.1#53(127.0.0.1)
;; WHEN: Wed Jun 24 18:29:02 CST 2015
;; MSG SIZE rcvd: 42
可以看到 Query time: 1 msec ,速度非常快的,再也不用等待域名解析啦!
版权声明:本文标题:自建网络加速服务器,自建DNS缓存服务器加快上网速度 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://m.elefans.com/xitong/1726531970a1074247.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论