How to change CentOS IP address on a cloned VM

本文介绍了解决克隆CentOS虚拟机后遇到的网络问题的方法。主要涉及更新udev配置文件和ifcfg-eth0文件以匹配新的网络接口控制器设置。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

I cloned a CentOS VM(wmware) but couldn't bring the network up, it said "device eth0 does not seem to be present, delaying initialization".


It turns out that the NIC on the cloned VM was being renamed for eth*.


To list the current eth* device:
# ls /sys/class/net
eth* lo




There is a device manager, udev, which stores the settings,When you clone a vm it also changes the mac address of the NIC and as a result the vm sees it as a new NIC and assigns it to /dev/eth*.


As a result, we now have to edit the udev config file as well as the ifcfg-eth0 file to get the newly update virtual NIC card to operate on the eth0 device.


First, edit: /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 0x15ad:0x07b0 (vmxnet3) (custom name provided by external tool)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:50:56:bc:00:45", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"


# PCI device 0x15ad:0x07b0 (vmxnet3)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:50:56:bc:00:46", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"




  1. Check the VM MAC address from vsphere client side and just keep the correct SUBSYSTEM item according to the MAC address you have got.
  2. Delete the rest of SUBSYSTEM entry in the file.
  3. Update the 'eth1' attribute in the remaining entry to 'eth0'
  4. Edit /etc/sysconfig/network-scripts/ifcfg-eth0
  5. Change the HWADDR to match the new mac address listed in the newly edited 70-persistent-net.rules file.
  6. Check file "/etc/sysconfig/network" if needs to be updated.
  7.  Run #service network restart
  8. Reboot



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值