Centos7.x无法重启网络


1、在使用Centos7时,突然遇到使用systemctl status network命令发现网络无法正常重启。

[root@guardwhy ~]# systemctl start network
Job for network.service failed because the control process exited with error code. See "systemctl status network.service" and "journalctl -xe" for details.
[root@guardwhy ~]# systemctl status network

图示:

[root@guardwhy ~]# journalctl -xe

图示:

原因:

CentOS 7.x 系统,有NetworkManager和network两种网络管理工具。如果两种都配置会引起冲突,NetworkManager在网络断开的时候,会清理路由,如果自定义的路由,没有加入到NetworkManager的配置文件中,路由就被清理掉。

解决方案

1、使用ifconfig查询所有网卡的状态和信息。

2、切换到/etc/sysconfig/network-scripts/目录下

cd /etc/sysconfig/network-scripts/

图示:

3、CentOS 7 .x系统使用了一致性网络设备命名,配置中没有eth0,但是有ens33。将ens33文件重命名为eth0。

mv ifcfg-ens33 ifcfg-eth0

4、编辑vim ifcfg-eth0文件

TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=static
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=eth0
DEVICE=eth0
ONBOOT=yes
IPV6_PRIVACY=no
IPADDR=192.168.254.128
NETMASK=255.255.255.0
GATEWAY=192.168.254.2
DNS=8.8.8.8

5、将networkmanager暂停

systemctl stop NetworkManager
systemctl disable NetworkManager

6、重启网卡

systemctl restart network
systemctl status network

图示:

原文地址:https://www.cnblogs.com/Guard9/p/12766199.html