This article is reproduced in: http://yubosun.akcms.com/tech/ubntu-dns-reset.htm
After Ubuntu is installed, a static IP address is set. After restarting, the domain name cannot be resolved. To reset the DNS, open/etc/resolv. conf.
CAT/etc/resolv. conf
# Dynamic resolv. conf (5) file for glibc resolver (3) generated by resolvconf (8)
# Do not edit this file by hand -- your changes will be overwritten
The content is a warning: the file is dynamically created by the resolvconf program. Do not manually edit the file. The modification will be overwritten.
Sure enough, the modification will expire after the restart. I searched for information about DNS settings in Ubuntu and summarized the following two methods:
Method 1Add the following sentence at the end of/etc/Network/interfaces:
DNS-nameservers 8.8.8.8
8.8.8.8 is a DNS service provided by Google. Here is just an example. You can also change it to a DNS service provided by a telecom carrier. After the DNS is restarted, the DNS takes effect. At this time, check/etc/resolv. conf again, and there will be one more line at the bottom:
# Dynamic resolv. conf (5) file for glibc resolver (3) generated by resolvconf (8)
# Do not edit this file by hand -- your changes will be overwritten
Nameserver 8.8.8.8
Method 2Modify:
/Etc/resolvconf/resolv. conf. d/base (this file is empty by default)
Insert in:
Nameserver 8.8.8.8
Nameserver 8.8.4.4
If there are multiple DNS servers, one line will apply.
Save the modification and execute
Resolvconf-u
Look at/etc/resolv. conf. There are two more lines at the bottom:
CAT/etc/resolv. conf
# Dynamic resolv. conf (5) file for glibc resolver (3) generated by resolvconf (8)
# Do not edit this file by hand -- your changes will be overwritten
Nameserver 8.8.8.8
Nameserver 8.8.4.4
We can see that our settings have been added, and then ping a domain name, then we can resolve it, without restarting.
Note: It is much easier to modify DNS in centos. directly modify/etc/resolv. conf with the following content:
Nameserver 8.8.8.8
Nameserver 8.8.4.4
The Save takes effect, and the restart is OK.