Set UbuntuDNS Cache

Source: Internet
Author: User
Set UbuntuDNS cache 1. Install dnsmasq: # Install the dnsmasq package [linuxidc @ linuxidc-ubuntu ~] $ Sudoapt-getinstall "dnsmasq" 2. Set dnsmasq to take over the local DNS resolution request: # modify the dnsmasq configuration file [linuxidc @ linuxidc-ubuntu ~] $ Sudogedit/etc/d

Set Ubuntu DNS Cache

1. Install dnsmasq:

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

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

# Modify the configuration file of dnsmasq
[Linuxidc @ linuxidc-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;

3. Modify the dhclient Configuration:

# Modify the configuration file of dnsmasq
[Linuxidc @ linuxidc-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:

[Linuxidc @ linuxidc-ubuntu ~] $ Sudo gedit/etc/resolv. conf

# Note: The content of my resolv. conf file will not be rewritten because of ADSL dialing.
# 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 lan

5. Restart the dnsmasq service:

[Linuxidc @ linuxidc-ubuntu ~] $ Sudo/etc/init. d/dnsmasq restart

6. Modify dsl-provider

Sudo gedit/etc/ppp/peers/dsl-provider
Add # Before usepeerdns, that is, overwrite this statement.
In case, the resolv. conf setting is overwritten by pppoe.

7. Take a look at the time required for DNS resolution, and compare the data between the two before and after DNS resolution:

[Linuxidc @ linuxidc-ubuntu ~] $ Dig baidu.com # first execution
... Omitted output information...
; 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

[Linuxidc @ linuxidc-ubuntu ~] $ Dig baidu.com # Run again
... Omitted output information...
; 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

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.