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-eth3:IPADDR=192.167.120.11
檢視網路卡的DNS資訊,沒有配置DNS
[root@bsdb ~]# grep DNS /etc/sysconfig/network-scripts/ifcfg-eth*
/etc/sysconfig/network-scripts/ifcfg-eth1:PEERDNS=yes
/etc/sysconfig/network-scripts/ifcfg-eth2:PEERDNS=yes
/etc/sysconfig/network-scripts/ifcfg-eth4:PEERDNS=yes
/etc/sysconfig/network-scripts/ifcfg-eth5: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-eth1: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
檢查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-eth1: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-eth1:DNS1=192.168.30.50
/etc/sysconfig/network-scripts/ifcfg-eth1:DNS2=192.168.130.50
/etc/sysconfig/network-scripts/ifcfg-eth1:PEERDNS=yes
/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
檢視網路卡是否啟用了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-eth1: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
檢查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
如果不希望重啟時/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-eth3:IPADDR=192.167.120.11
檢視網路卡的DNS資訊,沒有配置DNS
[root@bsdb ~]# grep DNS /etc/sysconfig/network-scripts/ifcfg-eth*
/etc/sysconfig/network-scripts/ifcfg-eth1:PEERDNS=yes
/etc/sysconfig/network-scripts/ifcfg-eth2:PEERDNS=yes
/etc/sysconfig/network-scripts/ifcfg-eth4:PEERDNS=yes
/etc/sysconfig/network-scripts/ifcfg-eth5: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-eth1: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
檢查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-eth1: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-eth1:DNS1=192.168.30.50
/etc/sysconfig/network-scripts/ifcfg-eth1:DNS2=192.168.130.50
/etc/sysconfig/network-scripts/ifcfg-eth1:PEERDNS=yes
/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
檢視網路卡是否啟用了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-eth1: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
檢查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
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/30126024/viewspace-2156443/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- centos 修改resolv.conf後重啟系統恢復原狀CentOS
- vmvare 避免網路卡DHCP設定每次重啟時自動修改/etc/resolv.conf
- swoole 下開發,修改程式碼後,自動重啟工具
- Centos修改DNS重啟或者重啟network服務後丟失問題處理CentOSDNS
- 【RAC】Oracle19.13之後的grid,節點重啟後不會自動驅動Oracle
- win10為什麼關機後自動重啟 win10關機後自動重啟的方法Win10
- [Linux]Vmware Oracle Linux6.5 避免網路卡DHCP設定每次重啟時自動修改/etc/resolv.confLinuxOracle
- win10如何設定藍屏後自動重啟_win10藍屏後自動重啟的設定步驟Win10
- Nginx學習系列三Nginx的啟動、停止、修改配置檔案後重啟Nginx
- 系統重啟後卷不能自動掛載
- Win7 英文版 啟用自動更新後的不自動重啟方式Win7
- win10關機後自動重啟怎麼辦 win10關機都會重啟解決方法Win10
- Docker重啟保持容器自動啟動Docker
- win10如何設定藍色畫面後自動重啟_win10藍色畫面後自動重啟的設定步驟Win10
- vmvare ip地址重啟會自動改變解決方法
- 系統重啟後DNS地址預設修改修改引起的一次事故(Tomcat報錯:java.net.UnknownHostException)DNSTomcatJavaException
- Win8.1關機後自動重啟的解決辦法
- Nagios之批量修改nrpe配置檔案並自動重啟iOS
- 修改檔案後瀏覽器自動重新整理解決方案瀏覽器
- win10電腦開機自動重啟迴圈怎麼辦_win10開機後自動重啟的解決方法Win10
- 配置作業系統重啟後,Oracle資料庫和監聽自動啟動作業系統Oracle資料庫
- 如何修改docker容器的重啟策略(重啟模式)?Docker模式
- DNS中MX記錄的理解DNS
- 修改程式碼後無需重啟就生效的配置
- Orace RAC安裝-DNS安裝-修改RacNode1和DNSServer中的/etc/resolv.conf檔案及測試DNSServer
- win10 自動黑屏重啟如何解決_win10黑屏自動重啟的解決教程Win10
- 配置單例項自動重啟單例
- win10系統設定更新後不提示自動重啟的方法Win10
- Linux--/tmp目錄檔案重啟後自動刪除Linux
- win10 自動重啟關閉方法_win10自動重啟怎麼關閉Win10
- 如何手動重啟 Node.js 和用守護程式自動重啟Node.js
- springboot 配置熱啟動 不需重啟自動部署Spring Boot
- centOS修改主機名,重啟後無效解決CentOS
- DNS中MX記錄的理解(轉)DNS
- win10快速啟動後重啟怎麼辦_win10開機快速啟動後重啟解決方法Win10
- Win10系統關閉安裝更新後自動重啟功能的方法Win10
- Win10系統休眠後喚醒就自動重啟的解決方法Win10
- Win10下通過登錄檔禁止更新後自動重啟的方法Win10