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


sudo apt install dnsmasq

Configure 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 " aggregation/11696.html ">nameserver" 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" 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:


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


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

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:


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


Replace with one of the following statements


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


Find the following

#prepend domain-name-servers;

Related Article

Beyond APAC's No.1 Cloud

19.6% IaaS Market Share in Asia Pacific - Gartner IT Service report, 2018

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

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: and provide relevant evidence. A staff member will contact you within 5 working days.