fixed vbox centos找不到 eth0 设备问题

本文介绍在使用Oracle VirtualBox或VMWare克隆Red Hat、CentOS或Scientific Linux虚拟机后,如何解决网络接口配置问题。文章详细说明了删除内核网络规则文件、重启虚拟机以及更新接口配置文件等步骤。

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

原著

Fix eth0 network interface when cloning RedHat, CentOS or Scientific virtual machines using Oracle VirtualBox or VMWare

For years we’ve used bash scripting to ensure that all of our server configurations are standardised, so that we can expect servers with the same role to have the exact same configuration profile and exhibit the exact same behaviour. We’re in the process of moving to Chef but we’re not quite there yet. Recently we decided to redesign our network architecture with a higher level of focus around High Availability. This new design introduces Percona XtraDB Cluster and we’re writing our installation and configuration scripts to ensure that our new cluster boxes are both tuned and standardised.

We have base template linux VM’s in both VMWare and Oracle VirtualBox, and also templates that are specific to server roles such as web servers, HAproxy servers or MySQL Cluster servers. If we need to test a new configuration, or add a new node to the cluster, we just clone the appropriate template add some minor configuration and we’re good.

However if you clone a VMWare or Oracle VirtualBox VM, you’ll notice that it kills your network interfaces throwing errors like the one listed below:

#ifup eth0
Device eth0 does not seem to be present, delaying initialisation

What’s happening here is that when you clone your VM, VirtualBox and VMWare apply a new MAC Address to your network interfaces but they don’t update the linux configuration files to mirror these changes and so the kernel doesn’t firstly can’t find or start the interface that matches it’s configuration (with the old MAC Address) and it finds a new interface (the new MAC Address) that it has no configuration information for. The result is that only your networking service can only start the loopback networking interface and eth0 is dead.

So here’s how we fix it:

  1. Remove the kernel’s networking interface rules file so that it can be regenerated
    # rm -f /etc/udev/rules.d/70-persistent-net.rules

  2. Restart the VM
    # reboot

  3. UPDATE your interface configuration file
    # vim /etc/sysconfig/networking/devices/ifcfg-eth0

    Remove the MACADDR entry or update it to the new MACADDR for the interface (listed in this file: /etc/udev/rules.d/70-persistent-net.rules).

    Remove the UUID entry

    Save and exit the file

  4. Restart the networking service
    # service network restart

Happy cloning!


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值