Welcome 微信登录
编程资源 图片资源库 蚂蚁家优选 PDF转换器

首页 / 操作系统 / Linux / Linux中通过缓存DNS的解析来提高上网的响应速度

用Firefox浏览网页的时候,一开始总会看到左下角有一行提示:

     “正在解析主机 xxx ...”   

看上去是等待DNS服务器对域名的解析,于是闲来无事,决定做一个DNS Cache来提高下速度!

找了一下,有一个:

[xport@Ubuntu ~] $ apt-cache search "dns" | fgrep "cach"
dnsmasq - A small caching DNS proxy and DHCP server

去翻翻资料,设定的步骤如下:

1. 安装dnsmasq:

# 安装dnsmasq的软件包
[xport@ubuntu ~] $ sudo apt-get install "dnsmasq"

2.设定dnsmasq接管本机的DNS解析请求:

# 修改dnsmasq的配置文件
[xport@ubuntu ~] $ sudo gedit /etc/dnsmasq.conf

# 找到下面的内容,并进行修改
# If you want dnsmasq to listen for DHCP and DNS requests only on
# specified interfaces (and the loopback) give the name of the
# interface (eg eth0) here.
# Repeat the line for more than one interface.
# interface=
# Or you can specify which interface _not_ to listen on
# except-interface=
# Or which to listen on by address (remember to include 127.0.0.1 if
# you use this.)
listen-address=127.0.0.1 # 把这一行前面的注释去掉


3.修改dhclient的配置:

# 修改dnsmasq的配置文件
[xport@ubuntu ~] $ sudo gedit /etc/dhcp3/dhclient.conf

# 找到下面的内容,并进行修改
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.修改resolv.conf的配置:

[xport@ubuntu ~] $ sudo gedit /etc/resolv.conf

# 因为dnsmasq会接管本机的DNS解析请求,所以把127.0.0.1的地址放在最前面
nameserver 127.0.0.1
nameserver xxx.xxx.xxx.xxx
nameserver xxx.xxx.xxx.xxx
search localdomain


5. 重新开启dnsmasq的服务:

[xport@ubuntu ~] $ sudo /etc/init.d/dnsmasq restartlinux zend 乱码问题的解决hp v3159笔记本安装rhel4 u4小记相关资讯      Linux  缓存DNS 
  • Linux 即将 25 岁:足够伟大 却不  (01月01日)
  • Linux 这么棒是因为开源?  (08/28/2015 09:21:02)
  • FreeBSD 和 Linux 有什么不同?  (07/31/2015 09:15:06)
  • 盘点全球“国家级” Linux 项目  (09/25/2015 06:11:28)
  • 庆祝 Linux 24 岁生日!  (08/26/2015 06:13:36)
  • 【观点】离了Linux,我就活不了!  (10/31/2013 19:39:56)
本文评论 查看全部评论 (0)
表情: 姓名: 字数