Speed up your Internet browsing on Linux with a DNS Cache server

Most Linux distributions, unlike OpenSuSE, OS X and Windows, do not have a DNS Cache serviceinstalled by default.Your computer will need to lookup a website’s IP address every time you visit it. The lookup request is passed on to the DNS server(s) specified in the /etc/resolv.conf file. It will take the server a few ms (milliseconds) at best to respond. It can take a ‘long’ time if your using a slow Internet connection (or a wireless LAN).

Caching DNS acts just like a regular DNS, from the users point of view. The service is configured to respond to lookup requests and return IP addresses. If the Caching DNS does not know the answer to the request, he will simply forward the request to the correct server and then forward the reply to you once it has been received.

So what’s the difference?

An Caching DNS holds a small database of recent requests, or so to speak. He will keep each entry in his database for a specified amount of time  (more about TTL). If the Caching DNS receives a requests for a entry currently in his database, he will respond to it instantly without contacting any other servers. If the Caching DNS is on your local computer, this will occur in 0 milliseconds.
You can check the responce time of your DNS server by running the following command:

dig google.com | grep “Query time”

Let me demonstrate this by running the command two times on two different targets and explain the output.

petur@petur-desktop:/etc$ dig google.com|grep “Query time”
;; Query time: 49 msec
petur@petur-desktop:/etc$ dig google.com|grep “Query time”
;; Query time: 51 msec

Look at the above output. 49 msec (milli seconds) and 51 msec. The small difference between the lookup time for the two requests indicates that the DNS server I’m using has the answer to the request in the cache. Google.com is after all a very popular destination and someone on my campus has probably visited it recently.

What about a site nobody on my campus is likely to visit? I’ll go for australian.jp

petur@petur-desktop:/etc$ dig australian.jp|grep “Query time”
;; Query time: 610 msec
petur@petur-desktop:/etc$ dig australian.jp|grep “Query time”
;; Query time: 46 msec

The first request took 610 msec, that’s because the DNS server I’m using didn’t know the answer to my request and had to contact the DNS in charge of australian.jp (which I guess is located somewhere in Japan).

Now, the second request took only 46 msec, that’s because the DNS I’m using has cached the request and does not have to contact the _Japanese_ server again any time too soon.

When the Caching DNS receives a lookup request, he will first check to see if he has the answer cached, if not he will contact the server responsible for the domain in question.

I would like to shave those 50 msec, by average, off each site I visit on the web.

I’ll show you how this can be done on Ubuntu Linux.

Begin by installing dnsmasq either from “Applications->Ubuntu Software Center” or by using the command sudo apt-get install dnsmasq from the console.

Next you’ll need the change the order of your DNS servers, do this by going to “System->Preferences->Network Connections”
Select the name of the connection you are using and click Edit…

Goto IPv4 Settings

If you have “Method: Manual”, put “127.0.0.1,” (without the quotation marks) in front of whatever it says in your “DNS servers:” field.

If you have “Method: Automatic(DHCP)” -> Change to “Automatic (DHCP) address only” and put “127.0.0.1,8.8.8.8″ in the “DNS servers:” field.

8.8.8.8 is Googles DNS server, you might want to replace this with the one provided by your ISP (Internet Service Provider).
Reboot the network-manager service by executing the command sudo service network-manager restartfrom the command line.

You now have a DNS Caching service running on your computer.
Let me demonstrate the benefit:

petur@petur-desktop:/etc$ dig australian.jp|grep “Query time”
;; Query time: 610 msec
petur@petur-desktop:/etc$ dig australian.jp|grep “Query time”
;; Query time: 0 msec

Other Linux distrobutions:
1. Install dnsmasq
2. Put “nameserver 127.0.0.1″ at the top of your /etc/resolv.conf file
3. You might have to bring your interface down\up using ifconfig or ifdown\ifup

Questions or comments?

原文发布时间为:2011-03-28


时间: 2025-01-14 06:49:42

Speed up your Internet browsing on Linux with a DNS Cache server的相关文章

Linux下用dnsmasq做dns cache server的配置方法_Linux

目前最新版是2.7.1 ,可去其FTP下载:http://www.thekelleys.org.uk/dnsmasq/ 安装过程比较简单 yum -y install dnsmasq* wget http://www.keepalived.org/software/keepalived-1.2.9.tar.gz tar zxvf keepalived-1.2.9.tar.gz cd keepalived-1.2.9 ./configure --prefix=/usr/local/keepaliv

在Linux下访问MS SQL Server数据库(转)

server|访问|数据|数据库 在Linux下访问MS SQL Server数据库 ---- Linux 作 为 一 个 免 费 的Unix 类 操 作 系 统, 以 其 开 放 性 源 代 码. 多 任 务.X window 等 特 点 为 众 多 的 用 户 所 采 用, 并 有 很 多 企 业 采 用Linux 来 作 为 其 内 部 网 的 全 功 能 服 务 器(WWW,FTP,Email.DNS). 企 业 的 内 部 网 不 仅 要 提 供 文 本 信 息 的 访 问, 还 要

在linux下配置DNS服务器的方法

有两台邮件服务器分别为192.168.1.1(windows下主机名为b.test.cn)和192.168.1.3(linux下主机名为a.test.com). 在linux下配置DNS服务器,下面是配置过程中设置过的一些文件, /etc/hosts 文件的具体内容如下: # Do not remove the following line, or various programs# that require network functionality will fail.127.0.0.1 l

Linux CentOS上安装Couchbase Server的过程

Couchbase 是一个开源的.分布式的.面向文档(document-oriented)的 NoSQL 数据库,并且内置了 Memcached 服务.本文分享的是自己在 Linux 上成功安装 Couchbase Server 的实际操作步骤. Linux 发行版是 CentOS. 1. 下载 Couchbase 安装包 用 wget 命令进行下载: wget http://packages.couchbase.com/releases/2.0.0/couchbase-server-enter

如何在Linux系统上安装Domino Server

前言 在Linux系统上安装Domino Server是一个小小的挑战,其实并没有大家想想的复杂,既然是商业性的软件,OEM早就为我们解决了安装的难度,还有就是选择自己熟悉的Linux发行版,各个发行版操作上还是有一定的区别的,这里选择最新的Ubuntu Server 13.04,尽量在Server版本的Ubuntu上安装,虽然说Desktop版本也可以. 安装 Unbuntu server 13.4 下载Ubuntu server镜像 http://releases.ubuntu.mirror

linux网络编程-LINUX下模拟DNS编程,写报文时关于DOMAIN NAME 的格式转换程序

问题描述 LINUX下模拟DNS编程,写报文时关于DOMAIN NAME 的格式转换程序 这段程序要求是转换格式,如www.baidu.com换成3www5baidu3com0 网上有代码 void ChangetoDnsNameFormat(unsigned char* dns,unsigned char* host) { int lock = 0 , i; strcat((char*)host,"."); for(i = 0 ; i < strlen((char*)host)

Linux 内存中的 Cache 真的能被回收么?

Linux 内存中的 Cache 真的能被回收么? 在 Linux 系统中,我们经常用 free 命令来查看系统内存的使用状态.在一个 RHEL6 的系统上,free 命令的显示内容大概是这样一个状态: [root@tencent64 ~]# free total used free shared buffers cached Mem: 132256952 72571772 59685180 0 1762632 53034704 -/+ buffers/cache: 17774436 11448

Linux编译安装Darwin Streaming Server 6.0.3

买回来VPS后就一直想在上面搭建一个流媒体服务,在网上搜索了很多资料,大部分都是介绍Linux中安装Darwin Streaming Server 5.5.5版本,因为这个版本提供了针对linux的安装脚本.但既然官网有了6.0.3版本,于是果断尝试安装最新的版本. 1.什么是Darwin Streaming Server     目前主流的流媒体服务器有微软的windows media server.RealNetworks的Helixserver和苹果公司的Darwin Streaming

远程Linux VSP(Virtual Private Server)安装tomcat

问题描述 远程Linux VSP(Virtual Private Server)安装tomcat 远程在Linux VSP(Virtual Private Server)上面安装tomcat的时候,什么jdk啊,然后tomcat的环境变量我都设置了,启动tomcat也是显示启动,但是打开默认页面,上面中文字:显示无法连接mysql 我以为是我的方法有问题,同样的方法在本地ubuntu上面安装,tomcat一切OK 解决方案 记录一下,端口被占用,改成8888就OK了