Linux--Ubuntu modified static IP address cannot be resolved after restarting the Internet

Source: Internet
Author: User
Tags nameserver

Ubuntu set static IP address, not on the network

The article also mentions that if you add DNS in/etc/resolv.conf, because Ubuntu has a resolvconf service, if you restart it, then/etc/resolv.conf content will be modified to the default appearance, the file also has the hint text: "Do

Not edit this FILE by HAND--YOUR changes would be overwritten ", so you cannot modify/etc/resolv.conf directly.

Another thing to note is that/etc/resolv.conf is actually a link, it is really pointing to the/etc/resolvconf/resolv.conf.

Therefore, when we set a static IP address, found that the machine can not surf the internet, this time need to set up DNS, the following two ways:

The first method :

Add dns-nameservers xxx.xxx.xxx.xxx information in the configuration file of the NIC

Static192.168. 1.250  192.168. 1.1  255.255. 255.0 DNS 192.168. 3.45 192.168. 8.10

The second method :

Modify NameServer in/etc/resolv.conf

Modify When you view Ubuntu DNS,/etc/resolv.conf will see that the DNS that he uses is nameserver 127.0.1.1,

Because Ubuntu starts the DNSMASQ service and does not need to be acquired by the network operator to resolve the domain name.
The parsing speed will be slower than the network operator (with the cache).
You are using a telecommunications network, Ping Telecom's DNS speed in (1 MS, 2 ms) around, the speed is very fast.
But using the network operator's DNS will have some uncomfortable places, such as the unresolved domain name jump to 114xxxxxxxxxxxxxx ....
Some of the parsing has not been gfw to be blocked (GFW will be filtered and parsed).
Using DNSMASQ is far more beneficial than using DNS for network operators.

Using Ubuntu has rarely moved to/etc/resolv.conf this file because of its own DNSMASQ plus the router can hijack the domain name

The normal modification of Linux DNS is to edit the/etc/resolv.conf file.
The format is: nameserver,
As modified DNS for 218.85.152.99 (Fujian Telecom DNS)

218.85. 152.99

In general this is directly good.

however , if the system is equipped with NetworkManager , such modifications are only temporary, such as restarting the computer, or Plug and unplug the network cable/etc/resolv.conf is reset to: "NameServer 127.0.0.1" (There is a definition in base, reload the contents of base)
Ubuntu by default is loaded with NetworkManager.

If it is required to be permanent, you will need to /etc/NetworkManager/NetworkManager. conf in the dns=dnsmasq comment out. Disable the use of the DNSMASQ plugin.

[Main]plugins=Ifupdown,keyfile,ofono#dns=dnsmasq [ifupdown]managed=false 

Then restart NetworkManager
Note: This terminal cannot use Su to switch to root, only the current user can use Sudo to execute.

Service Network-manager Restart

This time we edit/etc/resolv.conf or specify DNS in the Ubuntu network connection will not empty the/etc/resolv.conf.

1/etc/resolv.conf is actually a link, it is actually pointing to the/run/resolvconf/resolv.conf
2 Ubuntu has a resolvconf service, if you restart it, then/etc/resolv.conf content will be modified to the default appearance
So you can't modify/etc/resolv.conf directly.

To modify the configuration file for the resolvconf service:/etc/resolvconf/resolv.conf.d/head (or three files of base, tail), join the required nameservers: nameserver xxx.xxx.xxx.xxx

Search Mydomain.comnameserver 61.139.39.73nameserver 61.139.2.69

The completion of the modification requires the execution of 2 commands as follows:

$resolvconf-U (more information about resolvconf services, can be viewed with man: Man resolvconf) $/etc/init.d/networking restart

Linux--Ubuntu modified static IP address cannot be resolved after restarting the Internet

Related Article

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.