Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to solve the problem of loss after Centos modifies DNS restart or restart network service

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly introduces "how to solve the loss after Centos modifies DNS restart or restart network service". In daily operation, I believe many people have doubts about how to solve the problem after Centos modified DNS restart or restart network service. Xiaobian consulted all kinds of information and sorted out simple and useful operation methods. I hope it will be helpful to answer "how to solve the loss after Centos modifies DNS restart or restart network service". Next, please follow the editor to study!

cause

When we search for centos configuration dns information, we often say that we configure "/ etc/resolv.conf" in this file. After we add nameserver to this file, we can ping the domain name, but after restarting centos or restarting the network service, we will not be able to ping, and the nameserver information configured in "/ etc/resolv.conf" will also be lost.

Deal with

We found the corresponding network card configuration file "/ etc/sysconfig/network-scripts/ifcfg-eth"

Here can be 0, 1, 2, and so on, representing the configuration files of different network cards.

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

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

After opening it, insert the following 3 items

Peerdns=no

Dns1=192.168.1.1

Dns2=192.168.1.2

Then: wq save

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

Cat / etc/resolv.conf

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

And then let's take a look at the effect.

Ping www.baidu.com

Then we restart the network service

Service network restart

And then we're under ping.

Found that there was no problem.

And then we reboot the system.

Reboot

At this point, the study on "how to solve the loss after Centos modifies DNS restart or restart network service" is over. I hope to be able to solve everyone's doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report