Applicable version: Ubuntu Fasty & Hardy
sudo apt install dnsmasq
See DNSMASQ Help
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:
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 127.0.0.1;