"网卡eth0,未识别的端口"的解决方法

发布时间:2020-08-03编辑:脚本学堂
用service network restart 后,有时会得到这样的提示(serivce network status 读取的是etc/sysconfig/network-script/ifcfg-*文件)。

用service network restart 后,有时会得到这样的提示(serivce network status 读取的是etc/sysconfig/network-script/ifcfg-*文件)
Shutting down loopback interface:                          [  OK  ]
Bringing up loopback interface:                              [  OK  ]
Bringing up interface eth0:  Error: No suitable device found: no device found for connection ' System eth0'.
                                                                                [FAILED]
用ifconfig eth0 up 提示eth0: unknown interface: No such device

网络在启动的时候会去配置文件 /etc/udev/rules.d/70-persistent-net.rules 读取相应的信息,如:
# PCI device 0x8086:0x100e (e1000) (custom name provided by external tool)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="08:00:27:25:d3:1c", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"

# PCI device 0x8086:0x100e (e1000)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="08:00:27:37:20:1e", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"

表明在 setup 网络设置中设置了两个网卡,eth0 和 eth1,系统看到这个信息会自动去读取网卡对应的文件:
etc/sysconfig/network-script/ifcfg-eth0  和 etc/sysconfig/network-script/ifcfg-eth1

会发现这 eth0 文件的网卡物理地址和电脑的网卡不匹配,才会出现开始的错误信息提示,可以把 eth1 中信息 copy 到 eth0中,这样在启动时,eth0就可以找到与之匹配的网卡设备。