我的原创地址:https://dongkelun.com/2020/10/26/vmwareClone/
前言
记录一下vmware如何克隆一个虚拟机,并解决克隆的centos7虚拟机遇到的网络问题
克隆方法
右键点击要克隆的虚拟机->管理->克隆,然后下一步->下一步,克隆类型选择创建完整克隆->输入虚拟机名称,选择位置,点击完成,然后等待一直到完成
开启虚拟机
输入用户名、密码,和之前被克隆的用户名密码一样
修改克隆后的ip
因为之前我设置的固定ip(vmware centos7 设置固定ip),所以克隆后的ip和我之前设置的固定ip一致,这样会冲突,需要修改
不修改的话ip会随机生成,并且每次都可能不一样,不重启虚拟机ip也会主动变化
vi /etc/sysconfig/network-scripts/ifcfg-eno16777736
IPADDR=192.168.44.129
重启网络
service network restart
然后发现重启失败
[root@master ~]# service network restart
Restarting network (via systemctl): Job for network.service failed. See 'systemctl status network.service' and 'journalctl -xn' for details.
[FAILED]
查看网络状态也是失败的
root@master ~]# systemctl status network
network.service - LSB: Bring up/down networking
Loaded: loaded (/etc/rc.d/init.d/network)
Active: failed (Result: exit-code) since Mon 2020-10-26 17:07:57 CST; 1min 17s ago
Process: 2257 ExecStop=/etc/rc.d/init.d/network stop (code=exited, status=0/SUCCESS)
Process: 2421 ExecStart=/etc/rc.d/init.d/network start (code=exited, status=1/FAILURE)
Oct 26 17:07:57 master network[2421]: Bringing up loopback interface: Could not load file '/etc/sysconfig/network-scripts/ifcfg-lo'
Oct 26 17:07:57 master network[2421]: Could not load file '/etc/sysconfig/network-scripts/ifcfg-lo'
Oct 26 17:07:57 master network[2421]: Could not load file '/etc/sysconfig/network-scripts/ifcfg-lo'
Oct 26 17:07:57 master network[2421]: Could not load file '/etc/sysconfig/network-scripts/ifcfg-lo'
Oct 26 17:07:57 master network[2421]: [ OK ]
Oct 26 17:07:57 master network[2421]: Bringing up interface eno16777736: Error: no device found for connection 'eno16777736'.
Oct 26 17:07:57 master network[2421]: [FAILED]
Oct 26 17:07:57 master systemd[1]: network.service: control process exited, code=exited status=1
Oct 26 17:07:57 master systemd[1]: Failed to start LSB: Bring up/down networking.
Oct 26 17:07:57 master systemd[1]: Unit network.service entered failed state.
异常解决
修改mac地址
查看mac地址
[root@master ~]# ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eno16777736: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 00:0c:29:19:34:5c brd ff:ff:ff:ff:ff:ff
inet 192.168.44.132/24 brd 192.168.44.255 scope global dynamic eno16777736
valid_lft 1150sec preferred_lft 1150sec
inet6 fe80::20c:29ff:fe19:345c/64 scope link
valid_lft forever preferred_lft forever
link/ether和brd之间的00:0c:29:19:34:5c就是我们要复制的新mac地址
修改
vi /etc/sysconfig/network-scripts/ifcfg-eno16777736
HWADDR="00:0c:29:19:34:5c"
然后重启网络
[root@master ~]# service network restart
Restarting network (via systemctl): [ OK ]
重启虚拟机
重启网络,用ifconfig 查看ip地址并没有改变为我们修改的192.168.44.129,重启一下虚拟机,再查看一下就会发现生效了