Linux下网速慢的问题


机器是双系统,分别是Windows XP 和 CentOS-5.3,问题是这样的,在windows 下网速很快,然后切换到Linux下网速就变得蜗牛爬一样慢,忍受了有些日子了。试过在Linux下重新装了网卡驱动,效果为零,问题依旧。不废话了,问题的根本原因是dns解析花费了大量时间,解决方法是利用dnsmasq建立dns 缓存。

1、安装dnsmasq

dnsmasq的官方网址是:http://www.thekelleys.org.uk/dnsmasq/doc.html。利用里面的下载链接下载安装即可。

2、配置dnsmasq

配置相当简单,也不用命令行。在CentOS打开System——>Administration——>Network:

到DNS标签下添加一个新的DNS服务器:127.0.0.1,并且放在第一的位置上。原来的保留不变,只是挪一下位置,降一下顺序。

The other way to do this is to edit /etc/resolv.conf file.Add an new line at the top of the /etc/resolv.conf file and the line looks like this nameserver:127.0.0.1 which means add a new dns server.

3、启动、停止dnsmasq

/etc/init.d/dnsmasp start

/etc/init.d/dnsmasp stop

/etc/init.d/dnsmasp restart

利用/etc/init.d/dnsmasp start来启动或者配置修改后用/etc/init.d/dnsmasp restart来重新启动使dnsmasq生效。

4、测试DNS缓存

4.1dnsmasq启动之前执行dig结果

dig www.google.com

;; Query time: 1 msec

;; SERVER: xxx.xxx.xxx.xxx#53(xxx.xxx.xxx.xxx)        #这里屏蔽真实DNS地址

;; WHEN: Mon Aug 31 13:13:40 2009

;; MSG SIZE  rcvd: 292

4.2dnsmasq启动之后执行dig结果

dig www.google.com

;; Query time: 0 msec

;; SERVER: 127.0.0.1#53(127.0.0.1)

;; WHEN: Mon Aug 31 13:16:02 2009

;; MSG SIZE  rcvd: 110

相关内容