How Ubuntu uses local DNS to speed network access

Source: Internet
Author: User
Keywords Name network access server how to use can
Tags /etc/resolv access apt cache configuration dns dns server dns servers

Applicable version: Ubuntu Fasty & Hardy

Install DNSMASQ

sudo apt install dnsmasq

Configure DNSMASQ

See DNSMASQ Help

Man DNSMASQ

There is a description of this: In order to configure DNSMASQ to act as cache for the host on abound it's running, put "http://www.aliyun.com/zixun/ aggregation/11696.html ">nameserver 127.0.0.1" in/etc/resolv.conf to force the local processes to send queries to DNSMASQ. Then either specify the upstream servers directly to DNSMASQ using--server options or put misspelling real in addresses file, SAY/ETC/RESOLV.DNSMASQ and run dnsmasq with the-r/etc/resolv.dnsmasq option.

The idea is that if you want DNSMASQ to be a DNS cache, you need to put "nameserver 127.0.0.1" in the/etc/resolv.conf file, usually the first non annotation statement, and then put the real DNS server information in a different file, such as "etc /RESOLV.DNSMASQ ", finally executes the command:

Dnsmasq-r/ETC/RESOLV.DNSMASQ

The first step, as prompted by the help document, requires that you modify the/etc/resolv.conf file. Can be manually modified, such as the use of VI, you can put the original content of all comments, and then write on the first line

NameServer 127.0.0.1;

You can also use the Ubuntu Network Management applet "receptacle Manager" to have an icon in the upper-right corner of the desktop, right-click on the icon, select "Edit Connection", select the connection you are using, click Edit, and in the "DNS Server" input box of the "IPv4 Settings" tab, Delete the original DNS server, enter

127.0.0.1.

The second step is to create a new RESOLV.DNSMASQ file in the ETC directory. The contents of the file are the addresses of the DNS servers and are true DNS servers, such as my file contents are:

NameServer 210.47.0.1
NameServer 202.98.5.68

The third step can not follow the help document said to execute the "dnsmasq-r/etc/resolv.dnsmasq" command, if so, not every time you have to enter in the command line, very troublesome, of course, you can consider this command to write "/etc/rc.local" file, Let the system help you run every time it starts. The method I use is to edit the "/etc/dnsmasq.conf" file. Find the following

#resolv-file=

Replace with one of the following statements

Resolv-file=/etc/resolv.dnsmasq

This is what follows the-r argument in the DNSMASQ command.

Edit/etc/dhcp3/dhclient.conf

Find the following

#prepend domain-name-servers 127.0.0.1;

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.