最好連接到console,而不要在SSH下面進行,因爲可能導致網絡中斷,到時候你就連不到機器了
chkconfig --level 35 network on
chkconfig --level 0123456 NetworkManager off
service NetworkManager stop
service network stop
service network start
如果還不行,重啓系統看看
service network start 出現RTNETLINK answers: File exists錯誤解決 或者
/etc/init.d/network start 出現RTNETLINK answers: File exists錯誤解決 (呵呵,其實兩者是等效的,其實前者執行的就是這個命令)。
在centos下出現該故障的原因是啓動網絡的兩個服務有衝突:/etc/init.d/network 和 /etc/init.d/NetworkManager這兩個服務有衝突吧。
從根本上說是NetworkMaganager(NM)的帶來的衝突,停用NetworkManager即可解決。重啓即可。
1.切換到root賬戶,並用chkconfig命令查看network 和 NetworkManager兩個服務的開機啓動配置情況;
[wzb@embedded ~]$ su - root
口令:
[root@embedded ~]# chkconfig --list network
network 0:關閉 1:關閉 2:啓用 3:啓用 4:啓用 5:啓用 6:關閉
[root@embedded ~]# chkconfig --list NetworkManager
NetworkManager 0:關閉 1:關閉 2:關閉 3:啓用 4:關閉 5:關閉 6:關閉
[root@embedded ~]#
2.停用NetworkManager,開機時,不讓其啓動:
[root@embedded ~]# chkconfig --level123456 NetworkManager off
3.啓用network服務,開機啓動。在3、4、5用戶模式下;
[root@embedded ~]# chkconfig --level345 network on
或者 通過編輯 vi /etc/rc.d/rc.local文件在最後添加一行:/etc/init.d/network start
[root@embedded ~]# vi /etc/rc.d/rc.local
#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.
/etc/init.d/network start
4.停用NetworkManager.,通過重啓如果是遠程的話,比較安全。
[root@embedded ~]# reboot
注意:如果不是遠程的話也可以通過如下命令解決,不過上述配置將在下次重啓後,生效。
[root@embedded ~]# /etc/init.d/NetworkManager stop //若果是遠程的的話,這將中斷你的網絡,即不能進行遠程控制了(相當於自殺)
[root@embedded ~]# /etc/init.d/NetworkManager status
NetworkManager 已停
[root@embedded ~]# /etc/init.d/network stop //若果是遠程的的話,這將中斷你的網絡,即不能進行遠程控制了(相當於自殺)
[root@embedded ~]# /etc/init.d/network start
彈出環回接口: [確定]
彈出界面 eth0: [確定]
[root@embedded ~]#
5.測試網絡: ping http://www.baidu.com/
如果能夠ping通的話,說明網絡已經錯誤了。
如果ping不通的話,說明網絡dns配置有問題,既然遠程連上你的主機,說明主機的網絡沒問題,而你用的是ip。而你的遠程主機ping域名ping不通,當時你若嘗試ping ip話也是能ping通的,這就更進一步說明,是dns配置的問題。這都network Manager帶來的問題,使DNS的配置文件 /etc/resolv.conf 爲默認狀態,即沒有配置域名服務器;
可以通過編輯 vi /etc/resolv.conf 文件:
以google的域名服務器爲例:在最後添加兩句:
search google.com
nameserver 8.8.8.8
保存/etc/resolv.conf 並退出。
再次ping www.baidu.com 發現成功了。
6.總結: 問題產生的原因:是兩個配置網絡的服務的衝突造成的。卸載 NetworkManager這個罪魁禍首,是根本。
yum erase NetworkManager
你兩次執行 /etc/init.d/network start 同樣會產生上述問題的症狀。正常的情況下,在網絡開啓的狀態下,應該用 /etc/init.d/network restart.
(可能網絡的配置文件 ip 、dns的配置文件,是這兩個配置服務的臨界資源吧,這可能是造成衝突的主要原因)。
本文轉自:http://blog.csdn.net/chenjiayi_yun/article/details/8963851