centos7 重啟網卡失敗
今天在centOS 7 network服務重啟不了
現把各種解決方法歸納整理,希望能讓後面的同學少走點歪路。。。
首先看問題:執行service network restart命令後出現下面的錯誤:
Restarting network (via systemctl): Job for network.service failed because the control process exited with error code.
See "systemctl status network.service" and "journalctl -xe" for details. [失敗]
根據提示輸入systemctl status network.service命令後出現如下錯誤信息:
● network.service - LSB: Bring up/down networking
Loaded: loaded (/etc/rc.d/init.d/network; bad; vendor preset: disabled)
Active: failed (Result: exit-code) since 五 2017-07-14 19:01:47 CST; 1min 16s ago
Docs: man:systemd-sysv-generator(8)
Process: 4681 ExecStart=/etc/rc.d/init.d/network start (code=exited, status=1/FAILURE)
CGroup: /system.slice/network.service
└─1192 /sbin/dhclient -H mini1 -1 -q -lf /var/lib/dhclient/dhclient--ens33.lease -pf /v...
7月 14 19:01:47 mini1 network[4681]: RTNETLINK answers: File exists
7月 14 19:01:47 mini1 network[4681]: RTNETLINK answers: File exists
7月 14 19:01:47 mini1 network[4681]: RTNETLINK answers: File exists
7月 14 19:01:47 mini1 network[4681]: RTNETLINK answers: File exists
7月 14 19:01:47 mini1 network[4681]: RTNETLINK answers: File exists
7月 14 19:01:47 mini1 network[4681]: RTNETLINK answers: File exists
7月 14 19:01:47 mini1 systemd[1]: network.service: control process exited, code=exited status=1
7月 14 19:01:47 mini1 systemd[1]: Failed to start LSB: Bring up/down networking.
7月 14 19:01:47 mini1 systemd[1]: Unit network.service entered failed state.
7月 14 19:01:47 mini1 systemd[1]: network.service failed.
network服務啟動不了首先保證/etc/sysconfig/network-scripts目錄下的ifcfg-xxx(每臺機器不一定相同)沒有錯誤(如果你改動過的話),這裏的錯誤指的在更改過程中因為手誤敲錯字母之類的。
網上最常見的幾種做法如下:
1.和 NetworkManager 服務有沖突,這個好解決,直接關閉 NetworkManger 服務就好了, service NetworkManager stop,並且禁止開機啟動 chkconfig NetworkManager off 。之後重啟就好了。
2和配置文件的MAC地址不匹配,這個也好解決,使用ip addr(或ifconfig)查看mac地址
[root@royfans royfans]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN qlen 1
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN qlen 1000
link/ether 00:0c:29:5f:9e:1d brd ff:ff:ff:ff:ff:ff
3: virbr0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN qlen 1000
link/ether 52:54:00:67:8e:c3 brd ff:ff:ff:ff:ff:ff
inet 192.168.122.1/24 brd 192.168.122.255 scope global virbr0
valid_lft forever preferred_lft forever
4: virbr0-nic: <BROADCAST,MULTICAST> mtu 1500 qdisc pfifo_fast master virbr0 state DOWN qlen 1000
link/ether 52:54:00:67:8e:c3 brd ff:ff:ff:ff:ff:ff
00:0c:29:5f:9e:1d這個就是MAC地址了,將/etc/sysconfig/network-scripts/ifcfg-xxx中的HWADDR(如果沒有就添加上)改成這個MAC地址
3.設定開機啟動一個名為NetworkManager-wait-online服務,命令為:
systemctl enable NetworkManager-wait-online.service
=========================================================================================================
上面兩個是我看到最多的解決方法,但是很遺憾,我的並沒有解決。
有查看資料,發現了以下一些方法:
4.查看/etc/sysconfig/network-scripts下,將其余無關的網卡位置文件全刪掉,避免不必要的影響,即只留一個以ifcfg開頭的文件,
5.將ifcfg-xxx文件中的DEVICE一行註釋掉。
6.將ifcfg-xxx中的NAME改為和文件名一致。
centos7 重啟網卡失敗