让你的linux 解析域名更快
albume
|
1#
albume 发表于 2007-12-22 10:10
让你的linux 解析域名更快
兄弟们是否用LINUX 的时候觉得firefox 打开网站的时候显示正在解析主机。ie是正在连接主机。。有什么让我们第一次连接这个让点以后。第二次花更少点时间来解析这个域名呢。可能有些说历史记录可以。但我认为历史记录不过是记录网页的内容。域名的应该不会被缓存下来。。我以cent os 平台为例。这里介绍一个软件包叫 dnsmasq 可能通用yum 安装
1: yum -y install dnsmasq 2: hash 3: 修改/etc/dnsmasq.conf 把listen_address= 前面的#号去掉,然后再=后面加上本机环回地址127.0.0.1 或者在配置文件底部增加一行 listen-address=127.0.0.1 修改/etc/resolv.conf 文件 把第一DNS SERVER 改成 nameserver 127.0.0.1 4: 然后启动dnsmasq 服务 /etc/rc.d/init.d/dnsmasq start chkconfig dnsmasq on 现在我把安装dnsmasq 前解析域名的时间和安装dnsmasq 后解析域名所用的时间贴出来。 安装dnsmasq 前: ig baidu.com ; <<>> DiG 9.2.4 <<>> baidu.com ;; global options: printcmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 61569 ;; flags: qr rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 0 ;; QUESTION SECTION: ;baidu.com. IN A ;; ANSWER SECTION: baidu.com. 466 IN A 202.108.22.46 baidu.com. 466 IN A 220.181.38.84 ;; Query time: 40 msec ;; SERVER: 202.96.134.133#53(202.96.134.133) ;; WHEN: Wed Aug 29 21:43:31 2007 ;; MSG SIZE rcvd: 59 第二次查询 [root@abc ~]# dig baidu.com ; <<>> DiG 9.2.4 <<>> baidu.com ;; global options: printcmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 58802 ;; flags: qr rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 0 ;; QUESTION SECTION: ;baidu.com. IN A ;; ANSWER SECTION: baidu.com. 465 IN A 202.108.22.46 baidu.com. 465 IN A 220.181.38.84 ;; Query time: 39 msec ;; SERVER: 202.96.134.133#53(202.96.134.133) ;; WHEN: Wed Aug 29 21:43:32 2007 ;; MSG SIZE rcvd: 59 第三次查询 [root@abc ~]# dig baidu.com ; <<>> DiG 9.2.4 <<>> baidu.com ;; global options: printcmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 30773 ;; flags: qr rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 0 ;; QUESTION SECTION: ;baidu.com. IN A ;; ANSWER SECTION: baidu.com. 464 IN A 220.181.38.84 baidu.com. 464 IN A 202.108.22.46 ;; Query time: 31 msec ;; SERVER: 202.96.134.133#53(202.96.134.133) ;; WHEN: Wed Aug 29 21:43:33 2007 ;; MSG SIZE rcvd: 59 第四次 [root@abc ~]# dig baidu.com ; <<>> DiG 9.2.4 <<>> baidu.com ;; global options: printcmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 48642 ;; flags: qr rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 0 ;; QUESTION SECTION: ;baidu.com. IN A ;; ANSWER SECTION: baidu.com. 463 IN A 202.108.22.46 baidu.com. 463 IN A 220.181.38.84 ;; Query time: 43 msec ;; SERVER: 202.96.134.133#53(202.96.134.133) ;; WHEN: Wed Aug 29 21:43:34 2007 ;; MSG SIZE rcvd: 59 发现次是30-50 msec 之间 那么看安装dnsmasq 之后的查询速度 ; <<>> DiG 9.2.4 <<>> baidu.com ;; global options: printcmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 10817 ;; flags: qr rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 0 ;; QUESTION SECTION: ;baidu.com. IN A ;; ANSWER SECTION: baidu.com. 6164 IN A 202.108.22.46 baidu.com. 6164 IN A 220.181.38.84 ;; Query time: 2 msec ;; SERVER: 127.0.0.1#53(127.0.0.1) ;; WHEN: Wed Aug 29 22:01:05 2007 ;; MSG SIZE rcvd: 59 把dnsmasq 服务关掉后查询域名的速度 [root@abc ~]# service dnsmasq stop Shutting down Lightweight caching nameserver (dnsmasq): [ OK ] [root@abc ~]# dig baidu.com ; <<>> DiG 9.2.4 <<>> baidu.com ;; global options: printcmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 51018 ;; flags: qr rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 0 ;; QUESTION SECTION: ;baidu.com. IN A ;; ANSWER SECTION: baidu.com. 6122 IN A 220.181.38.84 baidu.com. 6122 IN A 202.108.22.46 ;; Query time: 51 msec ;; SERVER: 202.96.134.133#53(202.96.134.133) ;; WHEN: Wed Aug 29 22:01:47 2007 ;; MSG SIZE rcvd: 59 |