(LInux)network网卡重启失败原因及解决方法

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/GX_1_11_real/article/details/82024213

前言


在我们进行网络配置的时候,经常会遇到配置成功后却无法重启网卡的问题,下面就介绍的是network重启失败的原因及解决方法。



报错


Job for network.service failed because the control process exited with error code. See “systemctl status network.service” and “journalctl -xe” for details.



network重启失败原因



【1】(ifcfg-…)网卡配置文件错误导致



【2】重启命令不正确导致



【3】network与NetworkManager冲突导致



解决方法



【1】查看配置文件是否出错


注意

由于服务器拥有很多的网口,所以配置ip时要修改对应网口的网卡的配置文件,修改没插网线的网卡的配置文件配置ip无用

一般,服务器的网口从左到右,对应序号为从0增长的配置文件(例:eth0到eth5).

注意网卡设备的名称,不一定为eth,可能为em


最基础的ip配置文件

cat /etc/sysconfig/network-script/ifcfg-eth0

TYPE=Ethernet            (可忽略)
BOOTPROTO=none           (系统启动地址协议;none同static,配置为静态IP;dhcp,配置为动态IP,自动获取)
NAME=eth0                (名称)
DEVICE=eth0              (网络接口名称,必与该配置文件后缀的名称相同)
ONBOOT=yes               (系统启动时是否激活)
IPADDR=10.10.20.212      (ip地址)
NETMASK=255.255.254.0    (子网掩码)
GATEWAY=10.10.20.254     (网关)
DNS1=8.8.8.8             (DNS,域名解析,可写其他的dns)

解决方法

<1>修改配置文件为正确的



【2】配置文件无问题,使用对应网卡重启命令


注意
不同系统,不同系统版本的命令的使用方法会有差别


例如

/etc/init.d/network restart              (centos6)
service network restart                  (centos6)

systemctl restart network                (centos7)

解决方法

<1>使用对应版本的重启命令



【3】如非输入错误,则是与NetworkManager冲突导致(最常见原因)


解决方法

<1>禁用NetworkManager

临时禁用
/etc/init.d/NetworkManager stop    (centos6)
service NetworkManager stop        (centos6)
systemctl stop NetworkManager      (centos7)


永久
chkconfig NetworkManager off       (centos6)
systemctl disable NetworkManager   (centos7)

<2>重启network

/etc/init.d/network restart         (centos6)
service network restart             (centos6)


systemctl restart network           (centos7)

猜你喜欢

转载自blog.csdn.net/GX_1_11_real/article/details/82024213