在CentOS 7下,手工设置 /etc/resolv.conf 里的DNS,过了一会,发现被系统重新覆盖或者清除了。
这个情况和CentOS 6下的设置DNS方法不同,具体的解决方法如下:
首先先判断当前的dns是否有问题,如果有问题按照方法修改。
cat /etc/resolv.conf /查看是否有dns相关信息
cat /etc/sysconfig/network-scripts/ifcfg-eth0 //查看网络配置中是否有dns 名称请根据自己的情况修改eth0
如果都没有发现dns的设置,那么可以按照下面的方法处理,几种方法供选择:
方法1、使用传统方法,手工修改 /etc/resolv.conf
修改 /etc/NetworkManager/NetworkManager.conf 文件,在main部分添加 “dns=none” 选项:
nano /etc/NetworkManager/NetworkManager.conf
[main]
plugins=ifcfg-rh
dns=none
NetworkManager
重起相关服务加载上面修改的配置
systemctl restart NetworkManager.service
然后:手工修改 nano /etc/resolv.conf
,增加下列配置
nameserver 114.114.114.114
nameserver 8.8.8.8
方法2、使用全新的命令行工具 nmcli 来设置
#显示当前网络连接
nmcli connection show //键入命令
NAME UUID TYPE DEVICE
eth0 5fb06bd0-0bb0-7ffb-45f1-d6edd65f3e03 802-3-ethernet eth0
#修改当前网络连接对应的DNS服务器,这里的网络连接可以用名称或者UUID来标识
nmcli con mod eth0 ipv4.dns "114.114.114.114 8.8.8.8"
#将dns配置生效
nmcli con up eth0
注意:在输入nmcli命令提示错误 Error: NetworkManager is not running的,需要启用或者安装NetworkManager 服务。
1、查看NetworkManager状态:
systemctl status NetworkManager
2、如果没启动,要重启NetworkManager,
systemctl restart NetworkManager
或者
systemctl stop NetworkManager
systemctl start NetworkManager
3、开机自启动
systemctl enable NetworkManager
4、如果版本不匹配yum -y update
会升级NetworkManager的(包含nmcli)
rpm -qf /usr/bin/nmcli
NetworkManager-1.8.0-9.el7.x86_64
nmcli -v
nmcli tool, version 1.8.0-9.el7
5、没安装的需要安装,执行如下命令安装NetworkManager
yum install NetworkManager -y
版权属于: 三三世界-百宝箱
本文链接: http://33f.net/build/centos_dns.html
本文最后更新于2021年11月22日 ,已超过1125天没有更新,若内容或图片失效,请留言反馈。
本文允许转载,但请在转载时请以超链接或其它形式标明文章出处
@Doug Shume it's ok for me , you can post here.
Saved as a favorite, I like your website!
If some one wishes to be updated with hottest technologies after that he must be visit this site and be up to date daily.
Heello would you mind sharing which blog platform you're using? I'm planning to start my own blog in the near future but I'm having a tough time making a decision between BlogEngine/Wordpress/B2evolution and Drupal. The reason I ask is because your layout seems different then moost blogs and I'm looking for something completely unique. P.S Apologies forr being off-topic butt I had to ask!
Thanks to my father who shared with me regarding this webpage, this website is genuinely amazing.
Hi, I have an overflow of customers that I'd like to send to you but I want to make sure you can handle more leads, let me know if you'd like me to send you more info.
zh.us.to 有效
kms.03k.org 有效
kms.chinancce.com
kms.shuax.com 有效
kms.dwhd.org 有效
kms.luody.info 有效
kms.digiboy.ir 有效
kms.lotro.cc 有效
www.zgbs.cc 有效
cy2617.jios.org 有效
@ 权限问题,试试sudo 再加命令。
你好提示Permission denied 怎么办啊