No Network in Debian after Cloning with VirtualBox

I often work with virtual Debian instances to test new stuff. In order to reduce the likelihood that another test I’ve run before interferes with the new test, I clone them. I’ve installed a base system which runs using VirtualBox. Whenever I want to test something new I just clone it with this neat little function:

Unfortunately there’s one little change you have to make…

After you click on that dialog, you’ll be presented with another dialog where you can tell VirtualBox to assign a new MAC address. As I often run several virtual machines at the same time, I always tick this checkbox.

It’s just a matter of seconds and you have your new system up and running! Pretty cool! Is it? You’ll realize that you won’t have any network interfaces available. This is oft course not a new issue, lots of people have reported this and it’s easy to fix but I always forget where that file is located we have to modify. Usually when I write about something, it’s easier for me to remember it. This is a pretty selfish article!

If you run ifconfig, you’ll see that there’s just a loopback interface but not network connectivity:

ifconfig
 
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:8 errors:0 dropped:0 overruns:0 frame:0
          TX packets:8 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:560 (560.0 B)  TX bytes:560 (560.0 B)

Here’s the reason why Debian removed eth0

cat /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 0x8086:0x100e (e1000)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="08:00:27:bc:85:01", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
 
# PCI device 0x8086:0x100e (e1000)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="08:00:27:bc:85:02", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"

Debian automatically added a second device with the name eth1 but we only configured eth0! Since eth0 points to an address (08:00:27:bc:85:01) which doesn’t exist anymore, it’s safe to remove it and just change the name eth1 to eth0. Remove two lines and change one letter! My file looks like this afterwards:

# 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:0x100e (e1000)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="08:00:27:bc:85:02", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"

Reboot the system and you’ll have eth0 back:

ifconfig
eth0      Link encap:Ethernet  HWaddr 08:00:27:bc:85:b7
          inet addr:192.168.161.217  Bcast:192.168.161.255  Mask:255.255.255.0
          inet6 addr: fe80::a00:27ff:febc:85b7/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:1298 errors:0 dropped:0 overruns:0 frame:0
          TX packets:237 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:450363 (439.8 KiB)  TX bytes:24556 (23.9 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:8 errors:0 dropped:0 overruns:0 frame:0
          TX packets:8 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:560 (560.0 B)  TX bytes:560 (560.0 B)

Here’s the official ticket if you want to know a bit more about that problem: https://www.virtualbox.org/ticket/660




22 Comments

I have been banging my head over this for half a day, thanks.

I’m sure this didn’t used to happen though.

This is definitely a hassle in a no desktop server environment as x11 and virtualboxphp are really my only options. My master plan of making one base image and logging in over the network to change the routes and network settings on the CLI is shot.

This will have to do for now.

Great guide! Thanks!!

A big THANK YOU for this guide! You saved me from a serious headache.

In addition you might want to edit the file /etc/hostname to make the new clone unique.

Kind regards,
Michael

If you’re just doing quick testing, and only one of the clones is running at any given time, you can also just copy the MAC address from the original VM over to the clone in the advanced settings of the NIC.

thank you this saved me a lot of time,
was stuck since yesterday on this issue.
definitely bookmark worth

Another big thanks for me. Using OpenSuSe 12.1, but still everything solved in the same way in 5 minutes instead of 5 days… 🙂

This also applies when you create a new virtual machine from a virtual hd saved as VDI or VMDK, etc. When you create a new virtual machine, virtualbox create a new interface that Debian detected as new hardware and assigns a new line, different line in this file. By the same procedure described above, the interface eth0 function again.

Leave a Reply

Your email address will not be published. Required fields are marked *