用 dns 缓存服务提高上网速度

    由于 Firefox 解析 DNS 很慢,严重影响其上网速度,决定装个本地 DNS 服务器当缓存用,测试后速度有明显提升。

OS: Ubuntu Gutsy Server
kernel: 2.6.22-14-generic
dnsmasq: Version 2.39

1.首先安装 dnsmasq

sudo apt-get install dnsmasq

2.编辑 /etc/dnsmasq.conf

sudo vi /etc/dnsmasq.conf
把 "listen-address" 的注释号去掉,改为:
listen-address=127.0.0.1

3.编辑 /etc/dhcp3/dhclient.conf

sudo vi /etc/dhcp3/dhclient.conf
修改为:
#supersede domain-name "fugue.com home.vix.com";
prepend domain-name-servers 127.0.0.1;
request subnet-mask, broadcast-address, time-offset, routers,
domain-name, domain-name-servers, host-name,
netbios-name-servers, netbios-scope;

4.编辑/etc/resolv.conf

sudo vi /etc/resolv.conf
在第一行添加
nameserver 127.0.0.1

5.重启服务

sudo /etc/init.d/dnsmasq restart

6.测试

执行两次就能看出查询时间的差异了:
dig 3gcomet.com

; <<>> DiG 9.4.1-P1 <<>> 3gcomet.com
;; global options:  printcmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 44560
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;3gcomet.com.                   IN      A

;; ANSWER SECTION:
3gcomet.com.            3600    IN      A       125.65.112.94

;; Query time: 407 msec
;; SERVER: 127.0.0.1#53(127.0.0.1)
;; WHEN: Thu Jan  3 00:24:20 2008
;; MSG SIZE  rcvd: 45

dig 3gcomet.com

; <<>> DiG 9.4.1-P1 <<>> 3gcomet.com
;; global options:  printcmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 25502
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;3gcomet.com.                   IN      A

;; ANSWER SECTION:
3gcomet.com.            3598    IN      A       125.65.112.94

;; Query time: 4 msec
;; SERVER: 127.0.0.1#53(127.0.0.1)
;; WHEN: Thu Jan  3 00:24:22 2008
;; MSG SIZE  rcvd: 45

发表评论

电子邮件地址不会被公开。 必填项已用*标注

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据