Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I would like to configure a machine image with all the bells and whistles and then be able to launch multiple instances of it in VirtualBox. However, it allows me to launch only a single instance of each VM. I tried cloning VMs (and selecting reinitialize MAC address) and launching the clones, however, the clone doesn't get an IP address. So the original has the following network configuration:

>ifconfig
eth0      Link encap:Ethernet  HWaddr 08:00:27:92:0a:ec  
          inet addr:192.168.103.49  Bcast:192.168.255.255  Mask:255.255.0.0
          inet6 addr: fe80::a00:27ff:fe92:aec/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:5317 errors:0 dropped:0 overruns:0 frame:0
          TX packets:68 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:516671 (516.6 KB)  TX bytes:10492 (10.4 KB)

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:4 errors:0 dropped:0 overruns:0 frame:0
          TX packets:4 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:337 (337.0 B)  TX bytes:337 (337.0 B)

whereas the clone has no eth0, only lo and I cannot ssh into it.

share|improve this question
    
This limitation isn't unique to VirtualBox. The best way to do this would be to configure it once, clone the hdd and change the UID, then duplicate configuration for each additional instance you created. You won't be able to run multiple virtual machines without changing the UID and creating multiple virtual hdd files. –  Ramhound Oct 9 '13 at 15:18
    
@Ramhound, you are correct, however cloning a VM in Virtualbox does just that, it changes the UID and creates a new virtual hdd file. –  tbenz9 Oct 9 '13 at 18:28
    
@amphibient, please include the network configuration and Linux flavor. For example if this is Ubuntu, please say so and include the contents of /etc/interfaces/network. –  tbenz9 Oct 9 '13 at 18:29
    
@tbenz9 - I should explain I almost always just copy and paste the actual file by hand then use the command line tool to change the UID on new file itself –  Ramhound Oct 9 '13 at 18:30
    
@Ramhound thats great and I know that works. I have personally found the GUI clone tool to be much easier to use and just as effective. I try not to mess with the UID unless I have no other choice. I think this question is more of a networking issue rather than a how-to cloning issue. Even if amphibient cloned using your method they would still have the same networking issues. Thanks for the comment though! –  tbenz9 Oct 9 '13 at 18:38
show 5 more comments

1 Answer

Update

I was able to re-create your issue exactly. The easiest solution I found was to simply remove the contents of /etc/udev/rules.d/70-persistent-net.rules and reboot. This file is automatically generated when you reboot and it will reset eth0 to the MAC currently assigned.

original Answer

When you clone a VM and reinitialize the mac the OS thinks the new mac is a new network device. It usually assigns the new mac address to eth1. If eth1 has not been configured properly you won't have any networking and wont be able to ssh in.

You can clear the udev networking rules to force the OS to forget about the previous MAC and assign the new MAC to eth0, or you can configure eth1 to be the primary networking interface.

Here is a pretty good explaination of why udev rules are important and applicable to your situation: "For example, on a computer having two network cards made by Intel and Realtek, the network card manufactured by Intel may become eth0 and the Realtek card becomes eth1. In some cases, after a reboot the cards get renumbered the other way around. To avoid this, create Udev rules that assign stable names to network cards based on their MAC addresses or bus positions."

Another possible problem would be if the IP address was statically set in the network configuration. If you have a DHCP server that is supposed to be handing out IP addresses then make sure the network configuration is set to DHCP.

quote source and udev rules documentation

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.