linux6重启后resolv中DNS信息会自动修改的示例分析

发布时间:2021-11-09 10:55:40 作者:小新
来源:亿速云 阅读:360

这篇文章给大家分享的是有关linux6重启后resolv中DNS信息会自动修改的示例分析的内容。小编觉得挺实用的,因此分享给大家做个参考,一起跟随小编过来看看吧。

linux 6的/etc/resolv.conf重启后修改的原因,是因为重启时如果NetworkManager服务自动启动则该服务会读取网卡信息中的NM_CONTROLLED和DNS配置,如果网卡中配置了NM_CONTROLLED=yes,如果网卡中配置了DNS则把网卡中的DNS写入到resolv.conf,如果网卡没有配置DNS则把空的DNS信息写入resolv.conf

如果不希望重启时/etc/resolv.conf被修改,则关闭NetworkManager服务service NetworkManager stop 
chkconfig --level 0123456 NetworkManager off
并修改网卡NM_CONTROLLED=no



也就是说重启时,如果有Network Manager服务,且网卡配置了Network Manager服务,则该服务会根据网卡的DNS修改/etc/resolv.conf

而网卡中DNS配置,不需要每个有IP的网卡都配置,只要其中一个配置了DNS就可以,因为DNS是共享的,但是DNS必须配置在有IP的网卡上,如果有很多个网卡但是没有IP,就算这些网卡配置了DNS,则重启后/etc/resolv.conf也不会获取这个DNS




故障现象1,/etc/resolv.conf里面设置的nameserver信息丢失了
[root@bsdb ~]# cat /etc/resolv.conf
# Generated by NetworkManager
# No nameservers found; try putting DNS servers into your
# ifcfg files in /etc/sysconfig/network-scripts like so:
#
# DNS1=xxx.xxx.xxx.xxx
# DNS2=xxx.xxx.xxx.xxx
# DOMAIN=lab.foo.com bar.foo.com

查看文件属性,发现文件被修改了
[root@bsdb ~]# ll /etc/resolv.conf
-rw-r--r--. 1 root root 228 6月  19 11:06 /etc/resolv.conf

发现文件修改时间和重启时间匹配
[root@bsdb ~]# last |grep reboot
reboot   system boot  2.6.32-431.el6.x Tue Jun 19 11:06 - 11:27 (2+00:20)

查看网卡的IP
[root@bsdb ~]# grep IPADDR /etc/sysconfig/network-scripts/ifcfg-eth*
/etc/sysconfig/network-scripts/ifcfg-eth0:IPADDR=192.168.21.16
/etc/sysconfig/network-scripts/ifcfg-eth4:IPADDR=192.167.120.11

查看网卡的DNS信息,没有配置DNS
[root@bsdb ~]# grep DNS  /etc/sysconfig/network-scripts/ifcfg-eth*
/etc/sysconfig/network-scripts/ifcfg-eth2:PEERDNS=yes
/etc/sysconfig/network-scripts/ifcfg-eth3:PEERDNS=yes
/etc/sysconfig/network-scripts/ifcfg-eth5:PEERDNS=yes
/etc/sysconfig/network-scripts/ifcfg-eth6:PEERDNS=yes

查看网卡是否启用了NetworkManager管理,即NM_CONTROLLED=yes
[root@bsdb ~]# grep NM_CONTROLLED /etc/sysconfig/network-scripts/ifcfg-eth*
/etc/sysconfig/network-scripts/ifcfg-eth0:NM_CONTROLLED=yes
/etc/sysconfig/network-scripts/ifcfg-eth2:NM_CONTROLLED=yes
/etc/sysconfig/network-scripts/ifcfg-eth3:NM_CONTROLLED=yes
/etc/sysconfig/network-scripts/ifcfg-eth4:NM_CONTROLLED=yes
/etc/sysconfig/network-scripts/ifcfg-eth5:NM_CONTROLLED=yes
/etc/sysconfig/network-scripts/ifcfg-eth6:NM_CONTROLLED=yes

检查NetworkManager是否运行
[root@bsdb ~]# service NetworkManager status
NetworkManager (pid  6297) 正在运行...

OS版本
[oraprod@bsdb ~]$ cat /etc/issue
CentOS release 6.5 (Final)




故障现象2,/etc/resolv.conf里面设置的nameserver被修改了
[root@lmdb ~]# cat /etc/resolv.conf
# Generated by NetworkManager
nameserver 192.168.30.50
nameserver 192.168.130.50

查看文件属性,发现文件被修改了
[root@lmdb ~]# ll /etc/resolv.conf
-rw-r--r--. 1 root root 81 6月  19 11:04 /etc/resolv.conf

发现文件修改时间和重启时间匹配
[root@lmdb ~]# last |grep reboot
reboot   system boot  2.6.32-642.el6.x Tue Jun 19 11:04 - 10:09 (1+23:04)

查看网卡的IP
[root@lmdb ~]# grep IPADDR /etc/sysconfig/network-scripts/ifcfg-eth*
/etc/sysconfig/network-scripts/ifcfg-eth0:IPADDR=192.168.148.200
/etc/sysconfig/network-scripts/ifcfg-eth2:IPADDR=192.168.130.200

查看网卡的DNS信息,配置了DNS,且配置DNS的是有IP的网卡之一
[root@lmdb ~]# grep DNS /etc/sysconfig/network-scripts/ifcfg-eth*
/etc/sysconfig/network-scripts/ifcfg-eth0:PEERDNS=yes
/etc/sysconfig/network-scripts/ifcfg-eth2:DNS1=192.168.30.50
/etc/sysconfig/network-scripts/ifcfg-eth2:DNS2=192.168.130.50
/etc/sysconfig/network-scripts/ifcfg-eth2:PEERDNS=yes
/etc/sysconfig/network-scripts/ifcfg-eth3:PEERDNS=yes
/etc/sysconfig/network-scripts/ifcfg-eth4:PEERDNS=yes
/etc/sysconfig/network-scripts/ifcfg-eth5:PEERDNS=yes
/etc/sysconfig/network-scripts/ifcfg-eth6:PEERDNS=yes

查看网卡是否启用了NetworkManager管理,即NM_CONTROLLED=yes
[root@lmdb ~]# grep NM_CONTROLLED /etc/sysconfig/network-scripts/ifcfg-eth*
/etc/sysconfig/network-scripts/ifcfg-eth0:NM_CONTROLLED=yes
/etc/sysconfig/network-scripts/ifcfg-eth2:NM_CONTROLLED=yes
/etc/sysconfig/network-scripts/ifcfg-eth3:NM_CONTROLLED=yes
/etc/sysconfig/network-scripts/ifcfg-eth4:NM_CONTROLLED=yes
/etc/sysconfig/network-scripts/ifcfg-eth5:NM_CONTROLLED=yes
/etc/sysconfig/network-scripts/ifcfg-eth6:NM_CONTROLLED=yes

检查NetworkManager是否运行
[root@lmdb ~]# service NetworkManager status
NetworkManager (pid  3173) 正在运行...

OS版本
[root@lmdb ~]# cat /etc/issue
CentOS release 6.8 (Final)
Kernel \r on an \m

感谢各位的阅读!关于“linux6重启后resolv中DNS信息会自动修改的示例分析”这篇文章就分享到这里了,希望以上内容可以对大家有一定的帮助,让大家可以学到更多知识,如果觉得文章不错,可以把它分享出去让更多的人看到吧!

推荐阅读:
  1. 如何解决CentOS 7.4重启后/etc/resolv.conf被重置问题?
  2. 修改iptables后重启返回错误

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

dns linux6

上一篇:Oracle 11goracle修改AWR数据采样时间间隔及历史快照保留时间

下一篇:数据库中如何修改默认表空间

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》