In Linux, cache DNS resolution is used to increase the speed of online response.

Source: Internet
Author: User
Tags nameserver
In Linux, cache DNS resolution is used to speed up the response to the Internet-Linux Enterprise Application-Linux server application information. The following is a detailed description. When you use Firefox to browse a webpage, you will always see a prompt in the lower left corner at the beginning:

"Parsing host xxx ..."

It seems that the DNS server is waiting for domain name resolution, so it is idle and decides to make a DNS Cache to increase the speed!

I found one:

[Xport @ ubuntu ~] $ Apt-cache search "dns" | fgrep "cach"
Dnsmasq-A small caching DNS proxy and DHCP server

Follow these steps:

1. Install dnsmasq:

# Install the dnsmasq Software Package
[Xport @ ubuntu ~] $ Sudo apt-get install "dnsmasq"

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

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

# Find the following content and modify it
# If you want dnsmasq to listen for DHCP and DNS requests only on
# Specified interfaces (and the loopback) give the name of
# Interface (eg eth0) here.
# Repeat the line for more than one interface.
# Interface =
# Or you can specify which interface _ not _ to listen on
# Define T-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 # Remove the comment above this line


3. Modify the dhclient Configuration:

# Modify the configuration file of dnsmasq
[Xport @ ubuntu ~] $ Sudo gedit/etc/dhcp3/dhclient. conf

# Find the following content and modify it
Prepend domain-name-servers 127.0.0.1; # Remove the comment above 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 resolv. conf configuration:

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

# Because dnsmasq takes over the DNS resolution request of the local machine, the address of 127.0.0.1 is placed at the beginning.
Nameserver 127.0.0.1
Nameserver xxx. xxx
Nameserver xxx. xxx
Search localdomain


5. Restart the dnsmasq service:

[Xport @ ubuntu ~] $ Sudo/etc/init. d/dnsmasq restart

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.