“No route to host”: understanding networking between Vagrant VMs


I'd like to have a pair of VMs with a network between them. I made the following Vagrantfile

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  config.vm.define :alpha do |alpha|
    alpha.vm.box = "centos-6.4"
    alpha.vm.network :private_network, ip: ""

    alpha.vm.provision "shell", inline: "yum install -y nc"

  config.vm.define :beta do |beta|
    beta.vm.box = "centos-6.4"
    beta.vm.network :private_network, ip: ""
    beta.vm.provision "shell", inline: "yum install -y nc"

At first, I thought that things were working, because I can do

vagrant ssh alpha

and then




And those both work. But it looks like it's actually only those two operations that work. If I have beta listen on port 3000 and try to connect to it, I can't:

$ ssh -p3000
ssh: connect to host port 3000: No route to host

How can I get it so that all traffic can pass between the two VMs?

I've got VirtualBox 4.2.18 as the provider and Vagrant 1.3.3

Edit: After more experimentation, I can reproduce this with CentOS on VirtualBox alone, and if I change the base-box to an Ubuntu one, I do not have this problem (with no other changes to the Vagrantfile). Is this a problem with networking with CentOS on VirtualBox?

Best Answer

Turns out this was just the iptables on the base box tripping me up. Switching this off (service iptables stop to temporarily disable the firewall) allowed me to route between the two machines.