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/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- swoole 下開發,修改程式碼後,自動重啟工具
- 【RAC】Oracle19.13之後的grid,節點重啟後不會自動驅動Oracle
- win10為什麼關機後自動重啟 win10關機後自動重啟的方法Win10
- Nginx學習系列三Nginx的啟動、停止、修改配置檔案後重啟Nginx
- win10如何設定藍屏後自動重啟_win10藍屏後自動重啟的設定步驟Win10
- 系統重啟後DNS地址預設修改修改引起的一次事故(Tomcat報錯:java.net.UnknownHostException)DNSTomcatJavaException
- Docker重啟保持容器自動啟動Docker
- win10關機後自動重啟怎麼辦 win10關機都會重啟解決方法Win10
- win10如何設定藍色畫面後自動重啟_win10藍色畫面後自動重啟的設定步驟Win10
- Linux上監控Tomcat Down掉後自動重啟TomcatLinuxTomcat
- 如何修改docker容器的重啟策略(重啟模式)?Docker模式
- 修改程式碼後無需重啟就生效的配置
- win10電腦開機自動重啟迴圈怎麼辦_win10開機後自動重啟的解決方法Win10
- DNS中MX記錄的理解DNS
- springboot 配置熱啟動 不需重啟自動部署Spring Boot
- win10 自動黑屏重啟如何解決_win10黑屏自動重啟的解決教程Win10
- linux的centos版本修改時間重啟後無效的問題LinuxCentOS
- win10系統設定更新後不提示自動重啟的方法Win10
- centOS修改主機名,重啟後無效解決CentOS
- GitLab修改配置後nginx無法啟動GitlabNginx
- win10 自動重啟關閉方法_win10自動重啟怎麼關閉Win10
- 如何手動重啟 Node.js 和用守護程式自動重啟Node.js
- win10快速啟動後重啟怎麼辦_win10開機快速啟動後重啟解決方法Win10
- 【Linux】resolv.conf中search作用Linux
- .NET5修改配置不重啟自動生效
- 如何理解Java中的自動拆箱和自動裝箱?Java
- 啟用與禁用統計資訊自動收集
- Nginx每天莫名自動重啟問題Nginx
- SpringBoot2.4.0中嵌入式servlet容器的自動配置以及啟動原理(自我理解)Spring BootServlet
- Oracle sysman.mgmt_jobs導致資料庫自動重啟Oracle資料庫
- 4.2.9 修改元件的Oracle重啟配置元件Oracle
- 網站後臺管理如何修改?網站後臺修改自己資訊?網站
- 電腦一直自動重啟怎麼辦?電腦一直自動重啟的原因和解決辦法
- win10自動重啟藍屏怎麼辦_win10藍屏自動重啟解決方法Win10
- 寶塔liunx控制皮膚,監控程式斷了以後自動重啟的指令碼指令碼
- win10系統重啟後總是自動開啟未關閉程式如何解決Win10
- win10自動重啟怎麼解決_win10系統經常自動重啟修復方法Win10
- win10更新自動重啟怎麼關掉_如何徹底關掉win10更新自動重啟Win10