Page 1 of 1

Cloned Etch guest loses networking

Posted: 7. Sep 2007, 23:04
by gnuser
Summary (details are at end of post):

On a Kubuntu Feisty host using VirtualBox 1.5 (and 1.4 before
with the same result) I created a Debian Etch guest using the default
(NAT) networking configuration. Then I cloned the disk and used it to
create a new virtual machine, but networking fails (eth0 just won't
come up).

On the original machine, starting networking reports, among other
stuff, that eth0 is up at 100MB, Full-Duplex.

On the cloned machine it just says:

Configuring network interfaces...done.

and all I have is lo. If I try ifup eth0, I get:

[boilerplate omitted]
SIOCSIFADDR: No such device
eth0: ERROR while getting interface flags: No such device
eth0: ERROR while getting interface flags: No such device
Bind socket to interface: No such device
Failed to bring up eth0.

What am I doing wrong?

Ted

Details:

**********************************************************************
Create the template VM:

1. Create a dynamically-expanding 5GB disk named
base-etch-5gb.vdi. Create a new linux 2.6 virtual machine named
base-etch. Take defaults for everything else (including NAT for
networking).

2. Boot from the Debian 4.0 business-card iso and install the OS,
mainly from the network.

3. Finish initial installation and reboot to login prompt.

4. Log in as root, install openssh-server and dependences:
apt-get install openssh-server

5. Shut down, then set up ssh port forwarding:
VBoxManage setextradata "base-etch" \
"VBoxInternal/Devices/pcnet/0/LUN#0/Config/guestssh/Protocol" TCP
VBoxManage setextradata "base-etch" \
"VBoxInternal/Devices/pcnet/0/LUN#0/Config/guestssh/GuestPort" 22
VBoxManage setextradata "base-etch" \
"VBoxInternal/Devices/pcnet/0/LUN#0/Config/guestssh/HostPort" 60022

6. Boot, log in remotely as root, install packages (and dependences):

apt-get install cvs gcc keychain linux-headers-2.6-k7 \
linux-kbuild-2.6.18 make ntp ntpdate sudo xbase-clients xless

7. Install Guest Additions (mount the Guest Additions iso then run
the script). Since there's no X, the X drivers won't get
installed.

8. Verify that everything is as it should be, then shut down. This is
now the template base-etch.

Create a clone:

1. Clone the 5GB disk base-etch-5gb.vdi (this takes a while):
VBoxManage clonevdi base-etch-5gb.vdi clonetest-5gb.vdi

2. Create a new linux 2.6 virtual machine named clonetest using the
new disk clonetest-5gb.vdi.

3. Boot the new machine. It looks just like the other machine but
eth0 won't come up.

**********************************************************************

Filed bug report #660

Posted: 10. Sep 2007, 14:12
by gnuser
I have filed a bug report on this problem, #660.

Problem solved

Posted: 10. Sep 2007, 18:04
by gnuser
Thanks to frank's helpful response to Ticket #660, I now have the
answer.

It's not a VirtualBox bug, it's a Debian feature! And a wonderful
feature it is, if you happen to be running on a physical box.

An automatically-generated file called
/etc/udev/rules.d/rules.d/z25_persistent-net.rules ensures that once a
network device is detected, that hardware (MAC) address will always
get the same interface name (for example, eth0). This way, if you
switch from one device to another, they won't steal each other's names
and confuse your configuration scripts.

Unfortunately, when you clone a virtual machine, you'll get a new MAC
address for the network device (as you should). The Debian udev device
management system notes that "eth0" is already taken by the original
MAC address, so the new one becomes "eth1", for which you've probably
not included an entry in /etc/network/interfaces.

Assuming you're not juggling multiple network interfaces and want the
default interface to remain eth0, the solution is to edit
/etc/udev/rules.d/rules.d/z25_persistent-net.rules to find the line
for eth0, replace the original MAC address with the new one and then
remove the newly-added line for eth1.

An even simpler solution is just to delete
/etc/udev/rules.d/rules.d/z25_persistent-net.rules and then regenerate
it by stopping and restarting udev:

rm /etc/udev/rules.d/rules.d/z25_persistent-net.rules
/etc/init.d/udev stop
/etc/init.d/udev start

I'm surprised this hasn't come up before, since it's guaranteed to
happen to any Debian Etch guest in any virtual environment (not just
VirtualBox).

The elegant solution

Posted: 10. Sep 2007, 22:25
by gnuser
Even better: VirtualBox guru frank describes the ultimate elegant
solution:
______________
Look at the file /etc/udev/persistent-net-generator.rules. There is
already a rule to ignore VMware interfaces from generating a
persistent rule. Just add after the VMware rule

# ignore VirtualBox virtual interfaces
ATTR{address}=="08:00:27:*", GOTO="persistent_net_generator_end"

Finally remove /etc/udev/z25_persistent-net.rules. Don't change
/etc/network/interfaces. Reboot your guest and the interface should be
well-detected.
______________

I didn't find a VMware rule, but frank's advice is still sound. Note that this can be done once, right in the original Etch guest, so all the clones will just work.

Posted: 10. Mar 2008, 22:47
by MikeMeilleur
Hello all,

Thanks for your help.

I have another problem : now, my clone machine (debian) has the same IP address as the first one. I'm using NAT.

Do you know why the Vbox internal DHCP deliver the same IP address ? This is very strange ?

Do you know how to solve this problem ?

Regards,

Posted: 2. Jun 2008, 14:49
by ouro
I'm using Hostif and none of the solutions works for me. I have a bridge "br0" and two virtual interfaces attached: "tap0" and "tap2". I've installed etch in a virtual machine with hostif ("tap0") and everything works fine. Then I've cloned the virtual disk and created a new virtual machine using this new disk. I've attached the new machine to "tap1" but networking doesn't work. Virtual systems looks fine and i've configured eth0 to use networking but i can ping neither host machine nor internet.

what can i do?