device does not seem;RTNETLINK answers:File exists

前言:Centos 7服务器出现网络异常的问题
排查步骤:
1.确认是否有IP地址
2.重启网卡是否成功
3.是否有冲突的网络管理工具(network&NetworkManger)
4.检查网卡的配置文件是否正常
Warning:主要看日志,默认Log存放位置(/var/log/messages)
(1)检测是否有IP地址
(这里就不上图了,能够看到网卡信息,可是没有IP地址)
咱们看一下日志服务器

Apr  8 10:35:20 localhost network: Bringing up interface eth0:  ERROR     : [/etc/sysconfig/network-scripts/ifup-eth] Device  has different MAC address than expected, ignoring.
Apr  8 10:35:20 localhost /etc/sysconfig/network-scripts/ifup-eth: Device  has different MAC address than expected, ignoring.
Apr  8 10:35:20 localhost network: [FAILED]
Apr  8 10:35:20 localhost systemd: network.service: control process exited, code=exited status=1
Apr  8 10:35:20 localhost systemd: Failed to start LSB: Bring up/down networking.
Apr  8 10:35:20 localhost systemd: Unit network.service entered failed state.
Apr  8 10:35:20 localhost systemd: network.service failed.

这里明显说明MAC地址问题咱们就看一下MAC地址是否正确网络

[root@localhost ~]# grep HAW /etc/sysconfig/network-scripts/ifcfg-eth0 
HAWDDR="打码不给你看"

而后确认一下eth0网卡的MAC地址是否正确ide

[root@localhost ~]# cat /sys/class/net/eth0/address 
打码打码

如今确认MAC地址不一致,咱们修改网卡配置文件工具

[root@localhost ~]sed -i 's'/原配置文件的MAC/如今配置文件的MAC/g' /etc/sysconfig/network-scripts/ifcfg-eth0

再次重启网卡rest

[root@localhost ~]# systemctl restart network

不出意外又报错了,咱们再看一下日志信息日志

Apr  8 10:43:47 localhost /etc/sysconfig/network-scripts/ifup-eth: Device  does not seem to be present, delaying initialization.
Apr  8 10:43:47 localhost network: [FAILED]
Apr  8 10:43:47 localhost network: RTNETLINK answers: File exists
Apr  8 10:43:47 localhost network: RTNETLINK answers: File exists
Apr  8 10:43:47 localhost network: RTNETLINK answers: File exists
Apr  8 10:43:47 localhost network: RTNETLINK answers: File exists
Apr  8 10:43:47 localhost network: RTNETLINK answers: File exists
Apr  8 10:43:47 localhost network: RTNETLINK answers: File exists
Apr  8 10:43:47 localhost network: RTNETLINK answers: File exists
Apr  8 10:43:47 localhost network: RTNETLINK answers: File exists
Apr  8 10:43:47 localhost network: RTNETLINK answers: File exists

此次的报错不同了,告诉咱们找不到文件(这种类型的报错范围广,不容易排查,咱们从一下几点排查)
1.首先排查配置文件是否指定网卡名称
对象:文件名
网卡配置:NAME、DEVICE
2.检查70-persistent-net.rules自定义网卡信息配置文件
3.网卡信息是否刷新
(1)检查配置文件名称code

[root@localhost ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth0 
# Generated by dracut initrd
NAME="eth0"
HWADDR="打码"
ONBOOT=yes
NETBOOT=yes
UUID="打码"
IPV6INIT=yes
BOOTPROTO=dhcp
TYPE=Ethernet

这里缺乏DEVICE名称咱们加上对象

[root@localhost ~]# sed -i '3a/DEVICE=eth0' /etc/sysconfig/network-scripts/ifcfg-eth0

重启服务尝试dns

[root@localhost ~]# systemctl restart network

服务正常了
(2)检查70-persistent-net.rules自定义网卡信息配置文件ip

[root@localhost ~]# cat /etc/udev/rules.d/70-persistent-net.rules

若是没有这个文件这一步能够跳过,有的话比对信息
(3)刷新网卡

[root@localhost ~]# ip addr flush dev eth0

通常这些作完就能够排除网卡配置问题若是还有问题请检查route、dns、到DHCP服务器是否正常、若是是虚拟机的话查看虚拟机网卡配置是否正常等