How to modify DNS restart in Ubuntu

Source: Internet
Author: User
Tags one more line nameserver

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.

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.