虚拟机VMware克隆之后网络不可用的解决办法

时间:2021-07-30 14:29:00

虚拟机VMware克隆之后网络不可用的解决办法

现在有两台虚拟机,113是111的克隆,要让113能够使用,需要做下面的修改

5、解决办法
5.1、修改克隆后机器(B机器)70-persistent-net.rules文件内容
对克隆后机器(B机器)/etc/udev/rules.d/70-persistent-net.rules文件进行两步修改:

(1) 将原NAME="eth0"行内容注释

(2) 将NAME="eth1"行内容中的"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:5e:35:00", ATTR{type}=="", KERNEL=="eth*", NAME="eth0"

SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:3a:f2:8e", ATTR{type}=="", KERNEL=="eth*", NAME="eth0"
5.2、修改克隆后机器(B机器)的Mac地址与IP地址
[root@ol6_weblogic_1 network-scripts]# vi/etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE="eth0"

HWADDR="00:0C:29:3a:f2:8e"

NM_CONTROLLED="yes"

ONBOOT="yes"

IPADDR=192.168.1.230

NETWORK=192.168.1.0

NETMAST=255.255.255.0

TYPE="Ethernet"

UUID="b1b9ac33-19ad-4bb3-ac6c-06d5a3fa7c5b"

特别注意:

修改的MAC地址,只能是与70-persistent-net.rules文件中ATTR{address}相同的地址

5.3、重启操作系统生效
经验证,重启网络服务(service network restart)方式,IP地址可以变化过来,但是网络接口名称修改不生效。

6、验证

[root@ol6_weblogic_1 ~]# ifconfig –a

eth0      Link encap:Ethernet  HWaddr 00:0C:29:3A:F2:8E

inet addr:192.168.1.230  Bcast:192.168.1.255  Mask:255.255.255.0

inet6 addr: fe80::20c:29ff:fe3a:f28e/64 Scope:Link

UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

RX packets:380 errors:0 dropped:0 overruns:0 frame:0

TX packets:402 errors:0 dropped:0 overruns:0 carrier:0

collisions:0 txqueuelen:1000

RX bytes:35506 (34.6 KiB)  TX bytes:54463 (53.1 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)

结果:eth1变回了eth0,并且IP地址为所设置的IP地址,网络已可正常使用