其他分享
首页 > 其他分享> > device does not seem;RTNETLINK answers:File exists

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地址是否正确

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

现在确认MAC地址不一致,我们修改网卡配置文件

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

再次重启网卡

[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)检查配置文件名称

[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

重启服务尝试

[root@localhost ~]# systemctl restart network

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

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

如果没有这个文件这一步可以跳过,有的话比对信息
(3)刷新网卡

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

一般这些做完就可以排除网卡配置问题
如果还有问题请检查route、dns、到DHCP服务器是否正常、如果是虚拟机的话查看虚拟机网卡配置是否正常等

标签:10,network,exists,Apr,47,answers,网卡,RTNETLINK,localhost
来源: https://blog.51cto.com/13229718/2485644