I created a virtual machine with a CLI iso of Lubuntu 16.04 with VirtualBox. Now I need several machines with the same characteristics (but different IPs, in order to test a C network application I wrote), so I cloned the first one.

I changed the network settings of both machines so they both would have a network adapter attached to an internal network with the same name.

If I try to run $ ifconfig on both machines I get the same IP (i.e. Why? How to get different IPs?

Here's what's inside /etc/network/interfaces of both machines:

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

source /etc/network/interfaces.d/*

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto enp0s3
iface enp0s3 inet dhcp
  • 1
    When you cloned the VM, did you check 'Reinitialize the MAC address of all network cards' ? – user4556274 Sep 13 '17 at 11:20
  • @user4556274 yes I did! Indeed MAC addresses are different, just IP is the same. – Robb1 Sep 13 '17 at 11:46
  • @Robb1 Are the images using DHCP or static addresses? If they're configured for static addresses you'll get the same one each time. If they're configured for DHCP and have different MAC addresses the DHCP server should handle them. – Centimane Sep 13 '17 at 12:13
  • @Centimane thanks for your answer. How to check if they are using DHCP? I can't find it in network settings – Robb1 Sep 13 '17 at 12:15
  • 1
    @Robb1 help.ubuntu.com/lts/serverguide/… see the dynamic IP address assignment and static IP address assignment sections. Basically check /etc/network/interfaces and look for iface [interface] inet dhcp or iface [interface] inet static. – Centimane Sep 13 '17 at 12:19

The address indicates that you have your VM on the NAT network. This is probably not what you want, it basically allows a machine access to the world but no direct connection to other machines (physical or virtual).

When you clone the machine, you have the option of resetting the MAC address. Do this.

For Network type, it depends on your needs. Do these VMs need to access each other? The host machine? Internet? Other machines on your host machine's LAN?

Here's a c/p of some info from an answer I gave for a similar question -

Network connectivity to your VM - assuming of course that it has a properly configured service to connect to - depends on what network type you've chosen in the VM settings.

1) NAT - this does what it says. Unfortunately, it doesn't create a matching address on your host machine. The only way to connect is to forward individual ports, just like you would on your home router. This is done in the manager interface, in the settings for the machine, on the networks tab. If you have "NAT" selected as the network type and the card is active/enabled, the Port Forwarding button will be active and available.

2) Bridged - this bridges across one of your ethernet devices in the host machine, and connects directly to the network as if it were plugged in to a jack somewhere. HOWEVER... some work places, schools, etc. do not allow multiple MAC addresses to communicate through a single managed switch port, and if that is the case on whatever LAN you are connecting to it Won't Work.

3) Host Only - this creates a virtual network between your host machine and the guest(s). There is a dhcp service available, but it won't provide a gateway. If you want your guests to connect, you'll need to set up NAT/etc on the host machine and provide access that way.

4) Internal only - this connects machines to a virtual internal dumb switch. No DHCP service, no gateway access, nothing. Oh, and no matching adapter on your host machine.

What I do for a lot of practice/playground/experimentation is set up one machine with 2 interfaces - one on bridged, and one internal. I then turn that into a router machine, with a fake domain (fake.tld) DNS service, DHCP, caching DNS service for the world, etc. and then spin up other VMS to actually experiment and do things with on the internal only network.


All I had to do was initialize a DHCP server with the proper netname (e.g. mynetwork) running the following command:

$ VBoxManage dhcpserver add --netname mynetwork --ip --netmask --lowerip --upperip --enable

Of course also the ips depend on what you need.

  • Can you explain how you chose the name mynetwork and the numbers 11.11.11.x? This doesn't look like the same network that you have in the question – isapir Mar 25 '18 at 16:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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