Ubuntu under/etc/resolv.conf file always automatically clears the problem solution

Source: Internet
Author: User
Tags nameserver

Recently learning Linux, installed in the virtual machine is the Ubuntu operating system, a few days to find Ubuntu can not surf the Internet, open the command terminal, Input command:

Ping Www.baidu.com-c2

Results display name is not recognized, and directly with the host to use the IP address to ping each other, you can ping the www.baidu.com in Ubuntu Browser, cannot open Baidu Web page, but input Baidu's IP address, you can open Baidu, This indicates that there is a problem with the DNS service, find a workaround on the web, modify the/etd/resolv.conf file, but there is such a sentence in the file:

# do     not edit the This file by HAND--YOUR changes'll be overwritten // don't edit the files manually, your changes are rewritten

Sure enough, although the file added nameserver xxx.xxx.xxx.xxx, a moment is available, but after restarting the content and empty, and can not resolve the domain name.

Again on the Internet search solution, and some said to close the NetworkManager service, as shown on this page: http://my.oschina.net/HIJAY/blog/223118

But the personal feeling of service is not to close the good. Later found two solutions, pro-Test search effective:

Scenario 1:

(i) Create a/etc/resolvconf/resolv.conf.d/tail file (the head and base files are already in the ETC/RESOLVCONF/RESOLV.CONF.D folder)

(ii) Write the DNS server that you want in the file (which will later supplement the method of viewing the DNS server under Windows )

NameServer 202.118.176.2

(iii) restarting the RESOLVCONF program

sudo/etc/init.d/resolvconf Restart ( I tried it in, no effect, and restarted the virtual machine, effective )

(iv) View the/etc/resolv.conf file, you can see the inside automatically added nameserver 202.118.176.2, Ping www.baidu.com A can pass the

Scenario 2:

To modify the/etc/network/interfaces file:

# # #interfaces中 #######     auto     eth0static     192.168.  1.200     255.255.  255.0                  #子网掩码      192.168.  1.1                      192.168.  1.255     DNS202.118.  176.2    #设置dns服务器  ---This line is newly added.

That is, add the new dns-nameservers 202.118.176.2 line.

( Note that the nameserver is in plural form: dns-nameservers.) The first time I added no care, with Dns-nameserver, it won't work )

In summary, the individual feels that the second solution is simple because the/etc/network/interfaces file itself exists.

——————————————————————————————————————————————

Split Line ***********************************

To view DNS server ip************************ with a Windows host

1. Open the network and Sharing Center:

2. Click on the network you are currently using:

3. Click "Details":

4. You can see the DNS server URL:

Ubuntu under/etc/resolv.conf file always automatically clears the problem solution

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.