0

I'm trying to have 3 VirtualBox VMs all running at the same time on one host (Windows host, Ubuntu guest) so I can test running clusters of various services.

Problem is, I can't get the networking configuration of the VirtualBox VMs right.

I need: 1) All three guests can access the internet 2) All three guests can access the host separately, and the host can access all three guests separately (ie. each host has their own unique IP, as if they were completely independent servers)

I can't get this working. I'm trying with two network adapters on each box, one NAT (for the internet access) and the other Host-only network (for communication with host). I sort of got this working; although it's hit or mess.. sometimes when the guests boot up, they refuse to activate one of the two connections, getting stuck on the "A start job is running for Raise network interfaces" line in the boot, then one of the interfaces doesn't start. When it does work, however, all three guests end up with the exact same IP address on both interfaces. And yes, I checked--they do have different MAC addresses.

How do I fix this and have the three guests consistently succeed in setting up their networks, and have all three with their own IPs, while still ensuring all three guests can access the internet?

1
  • Set static IP for VMs. Set differebt subnets for NAT and host only network.
    – Biswapriyo
    Commented Aug 14, 2017 at 20:28

1 Answer 1

0

Seriously, use Vagrant for that. It handles the second network adapter quite nicely. Here's an example Vagrantfile I use with docker swarm:

$prepare_swarm_manager_script = <<SCRIPT
<<<shell commands>>>
SCRIPT

$prepare_swarm_node_script = <<SCRIPT
<<<shell commands>>>
SCRIPT

Vagrant.configure(2) do |config|
  config.vm.define "swarm_manager" do |config|
    config.vm.box = "ubuntu/xenial64"
    config.vm.hostname = "swarm-manager"
    config.vm.network "private_network", ip: "10.0.7.11"
    config.vm.provision "shell", inline: $prepare_swarm_manager_script
  end

  config.vm.define "swarm_node1" do |config|
    config.vm.box = "ubuntu/xenial64"
    config.vm.hostname = "swarm-node1"
    config.vm.network "private_network", ip: "10.0.7.12"
    config.vm.provision "shell", inline: $prepare_swarm_node_script
  end

  config.vm.define "swarm_node2" do |config|
    config.vm.box = "ubuntu/xenial64"
    config.vm.hostname = "swarm-node2"
    config.vm.network "private_network", ip: "10.0.7.13"
    config.vm.provision "shell", inline: $prepare_swarm_node_script
  end

The shell commands are executed as the ubuntu user (so use sudo). Then go vagrant up and get a beer.

But key information here is that you add the host-only network adapter before every VM installation and in the global virtualbox preferences check the host-only network adapter settings (that's what Vagrant handles for you). When you set up the subnet correctly, they can see each other

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .