Linux through caching DNS resolution to improve the response speed of the internet! __linux

Source: Internet
Author: User
Tags nameserver

After a few days of hard and careful, found in the browser Web page with Firefox, the beginning will always see the lower left corner of a line of hints:

"Resolving Host XXX ..."

Appears to be waiting for DNS server to resolve domain names, idle, and decided to do a DNS cache to improve the speed of the Internet.

Looking for, found a software to meet the requirements:

[Xport@ubuntu ~] $ apt-cache Search "DNS" | Fgrep "Cach"
DNSMASQ-A Small caching DNS proxy and DHCP server


To go over the data, set the steps as follows:

1. Install DNSMASQ:

# Install the DNSMASQ package
[Xport@ubuntu ~] $ sudo apt-get install "DNSMASQ"


2. Set DNSMASQ to take over the local DNS resolution request:

# Modify the DNSMASQ configuration file
[Xport@ubuntu ~] $ sudo gedit/etc/dnsmasq.conf

# Find the content below and make the changes
# If You are want DNSMASQ to listen for DHCP and DNS requests only
# Specified interfaces (and the loopback) give the name of the
# interface (eg eth0) here.
# Repeat for more than one interface.
# interface=
# Or You can specify which interface _not_ to listen on
# except-interface=
# Or which to listen in by (remember to include 127.0.0.1 if
# with this.
listen-address=127.0.0.1 # Take away the comments in front of this line


3. Modify the configuration of the dhclient:

# Modify the DNSMASQ configuration file
[Xport@ubuntu ~] $ sudo gedit/etc/dhcp3/dhclient.conf

# Find the content below and make the changes
Prepend domain-name-servers 127.0.0.1; # get rid of the comments in front of this line
Request Subnet-mask, Broadcast-address, Time-offset, routers,
Domain-name, Domain-name-servers, Host-name,
Netbios-name-servers, Netbios-scope;


4. Modify the configuration of the resolv.conf:

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

# Note: The contents of my resolv.conf file will not be overwritten because of ADSL dialing
# because DNSMASQ will take over the native DNS resolution request, put the 127.0.0.1 address on the front
NameServer 127.0.0.1
NameServer xxx.xxx.xxx.xxx
NameServer xxx.xxx.xxx.xxx
Search LAN


5. Re-open the DNSMASQ service:

[Xport@ubuntu ~] $ sudo/etc/init.d/dnsmasq Restart


6. See DNS resolution required time, before and after the data comparison 2 times:

[Xport@ubuntu ~] $ dig baidu.com #首次执行
... Omit output information from several ...
;; Query Time:8 msec
;; server:127.0.0.1#53 (127.0.0.1)
;; When:mon Feb 19 20:43:32 2007
;; MSG SIZE rcvd:229

[Xport@ubuntu ~] $ dig baidu.com #再次运行
... Omit output information from several ...
;; Query time:0 msec
;; server:127.0.0.1#53 (127.0.0.1)
;; When:mon Feb 19 20:45:27 2007
;; MSG SIZE rcvd:59


All right, finish the call.
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.