前言

  • CentOS6.5
  • 已安装好一台CentOS6.5虚拟机,假定为A。在A上执行克隆操作,获得B。在B启动后,遇到错误Device eth0 does not seem to be present

错误原因

在A系统上,网卡是eth0,系统的网络配置也是eth0(/etc/sysconfig/network-scripts/ifcfg-eth0)。
克隆得到的B系统,网卡是eth1,而系统的网络配置还是eth0(/etc/sysconfig/network-scripts/ifcfg-eth0)。
因此,错误为Device eth0 does not seem to be present

使用ifconfig命令查看网卡,结果如下:

shell> ifconfig -a
eth1      Link encap:Ethernet  HWaddr 00:0C:29:EE:B4:01
          inet addr:192.168.150.31  Bcast:192.168.150.255  Mask:255.255.255.0
          inet6 addr: fe80::20c:29ff:feee:b401/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:48 errors:0 dropped:0 overruns:0 frame:0
          TX packets:48 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:6369 (6.2 KiB)  TX bytes:6959 (6.7 KiB)

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)

解决办法

  • 删掉网卡eth0的配置。
  • 创建网卡eth1的配置。
shell> cd /etc/sysconfig/network-scripts/
shell> mv ifcfg-eth0 ifcfg-eth1
shell> vi ifcfg-eth1
----------------------------
DEVICE=eth1
TYPE=Ethernet
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=none
IPADDR=192.168.150.32
PREFIX=24
GATEWAY=192.168.150.2
DNS1=192.168.150.2
DEFROUTE=yes
IPV4_FAILURE_FATAL=yes
IPV6INIT=no
NAME="System eth1"
----------------------------
shell> service network restart
Shutting down interface eth1:                              [  OK  ]
Shutting down loopback interface:                          [  OK  ]
Bringing up loopback interface:                            [  OK  ]
Bringing up interface eth1:  Determining if ip address 192.168.150.32 is already in use for device eth1...
                                                           [  OK  ]

另一种解决办法

  • 将网卡从eth1改名为eth0
shell> cp /etc/udev/rules.d/70-persistent-net.rules /etc/udev/rules.d/70-persistent-net.rules.backup
shell> /etc/udev/rules.d/70-persistent-net.rules
-----------删掉eth0的配置,将eth1改为eth0-----------------
# This file was automatically generated by the /lib/udev/write_net_rules
# program, run by the persistent-net-generator.rules rules file.
#
# You can modify it, as long as you keep each rule on a single
# line, and change only the value of the NAME= key.

# PCI device 0x8086:0x100f (e1000)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:04:0c:28", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"

# PCI device 0x8086:0x100f (e1000)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:ee:b4:01", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"
----------------------------
shell> vi ifcfg-eth0
-----------删掉UUID和HWADDR-----------------
DEVICE=eth0
TYPE=Ethernet
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=none
IPADDR=192.168.150.32
PREFIX=24
GATEWAY=192.168.150.2
DNS1=192.168.150.2
DEFROUTE=yes
IPV4_FAILURE_FATAL=yes
IPV6INIT=no
NAME="System eth0"
----------------------------

上述步骤完成后,重启操作系统

参考

https://blog.csdn.net/mier9042/article/details/86666388
https://www.linuxidc.com/Linux/2018-08/153407.htm
https://www.runoob.com/linux/linux-comm-ifconfig.html

Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐