一、问题描述
系统:CentOS 6.9
重启网卡后:service network restart报:
Bringing up interface eth0: Device eth0 does not seem to be present,delaying initialization. [FAILED];
原因是copy虚拟机造成的。使用vmworkstation打开虚拟机的时候,要选择copy而非move。
二、解决思路
1)、确认vmx配置文件的mac地址
2、确定第一步里的MAC地址和下面Mac地址相同时,
vim /etc/udev/rules.d/70-persistent-net.rules,查看ATTR{address}的值是否跟 ifconfig -a 里边 eth1的 HWaddr(物理地址)值相等,执行下面操作
1)、重命名/etc/sysconfig/network-scripts/ifcfg-eth0为ifcfg-eth0
2)、 删除网卡配置文件里不必要的参数
)3、修改vim /etc/udev/rules.d/70-persistent-net.rules(注释eth0 网卡)
4、重启网络服务
三、解决方法
1、确认vmx配置文件的mac地址
ethernet0.generatedAddress = "00:0C:29:57:7F:85" 【在该虚拟机安装文件下】
2、修改70-persistent-net.rules
查看规则文件(vim /etc/udev/rules.d/70-persistent-net.rules);确定里面的Mac地址和上面第一步存在相同的Mac地址(若不存在相同的Mac地址,则手动创建一个和上面一样的Mac地址)
[root@db01 ~]# vim /etc/udev/rules.d/70-persistent-net.rules
# 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) 【由于该网卡Mac地址和上面不匹配,则注销该网卡信息】
# SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:9d:d1:26",ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
# PCI device 0x8086:0x100f (e1000)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:57:7f:85", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"
[root@db01 ~]# ifconfig -a
eth1 Link encap:Ethernet HWaddr 00:0C:29:57:7F:85
inet addr:10.0.0.8 Bcast:10.0.0.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fe57:7f85/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:97 errors:0 dropped:0 overruns:0 frame:0
TX packets:129 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:11501 (11.2 KiB) TX bytes:20472 (19.9 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:65536 Metric:1
RX packets:29 errors:0 dropped:0 overruns:0 frame:0
TX packets:29 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:2219 (2.1 KiB) TX bytes:2219 (2.1 KiB)
3、重命名网卡
[root@db01 ~]# mv /etc/sysconfig/network-scripts/ifcfg-eth0 /etc/sysconfig/network-scripts/ifcfg-eth1
4、修改网卡配置文件
[root@db01 ~]# vim /etc/sysconfig/network-scripts/ifcfg-eth0
#修改参数和删除无用参数
DEVICE="eth1"
TYPE=Ethernet
BOOTPROTO="dhcp"
ONBOOT=yes
HWADDR="00:0C:29:57:7F:85"
5、重启网卡
[root@db01 ~]# service network restart