[Source] After Centos modifies DNS to restart or restarts the network service, the problem is lost. centosdns

Source: Internet
Author: User
Tags nameserver

[Source] After Centos modifies DNS to restart or restarts the network service, the problem is lost. centosdns

This article is copyrighted by mephisto and the blog Park. You are welcome to repost it, but you must keep this statement and provide the original article link. Thank you for your cooperation.

Written by mephisto, SourceLink

Reading directory
  • Introduction
  • Cause
  • Processing
  • GitHub

This article is copyrighted by mephisto and the blog Park. You are welcome to repost it, but you must keep this statement and provide the original article link. Thank you for your cooperation.

Written by mephisto, SourceLink

 

Introduction

When we configure Centos, we need to be able to connect to the Internet in many cases, so we need the DNS resolution function. By default, DNS information is not configured, so we need to configure DNS information.

Cause

 

When we search for the Centos DNS configuration information, many of them refer to configuring in this file "/etc/resolv. conf ", we can ping the domain name after adding the nameserver in it, but it cannot be pinged after restarting centos or the network service. In"/etc/resolv. conf "the configured nameserver information is also lost.

 

Processing

Find the corresponding Nic configuration file "/etc/sysconfig/network-scripts/ifcfg-eth <N>"

Here, <N> can be 0, 1, 2, and so on, representing the configuration files of different NICs.

For example, if the first network adapter in the system is eth0, its configuration file is/etc/sysconfig/network-scripts/ifcfg-eth0.

vim /etc/sysconfig/network-scripts/ifcfg-eth0

Insert the following three

PEERDNS=noDNS1=192.168.1.1DNS2=192.168.1.2

Then: wq save

Then let's review "/etc/resolv. conf"

cat /etc/resolv.conf

 

We found that the DNS information we modified in the ifcfg-eth0 can be seen in resolv. conf, which is why the column, because resolve. conf is just a link file.

Then let's take a look at the effect.

ping www.baidu.com

Then we restart the network service.

service network restart

Then ping

No problem found

Then, restart the system.

reboot

The result is what we expected.

GitHub

https://github.com/sinodzh/Linux/blob/master/dns.txt

This article is copyrighted by mephisto and the blog Park. You are welcome to repost it, but you must keep this statement and provide the original article link. Thank you for your cooperation.

Written by mephisto, SourceLink

 

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.