Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can Multiple Vagrant VMs communicate by VM hostname?

I am managing multiple VMs with Vagrant. Networks are configured as private, ip addresses have been set and hostnames are assigned. As shown in the Vagrantfile below.

The VMs can communicate with each other via the IP address, but I would like to know how to allow VMs to communicate using their assigned hostname. I.e. How to make ping comtest2 work from comtest1?

Vagrantfile:

Vagrant.configure("2") do |config|    config.vm.define "comtest1" do |comtest1|     comtest1.vm.box = "precise32"     comtest1.vm.hostname = "comtest1"     comtest1.vm.network "private_network", ip: "192.168.10.21"   end    config.vm.define "comtest2" do |comtest2|     comtest2.vm.box = "precise32"     comtest2.vm.hostname = "comtest2"     comtest2.vm.network "private_network", ip: "192.168.10.22"   end  end 
like image 238
Nick Avatar asked Dec 19 '13 11:12

Nick


People also ask

Can I have more than one Vagrant box?

You can definitely run multiple Vagrant boxes concurrently, as long as their configuration does not clash with one another in some breaking way, e.g. mapping the same network ports on the host, or using same box names/IDs inside the same provider.

Which interface should the network bridge to Vagrant?

Default Network Interface If more than one network interface is available on the host machine, Vagrant will ask you to choose which interface the virtual machine should bridge to. A default interface can be specified by adding a :bridge clause to the network definition.

What does Vagrant box add do?

You can add a box to Vagrant with vagrant box add . This stores the box under a specific name so that multiple Vagrant environments can re-use it. If you have not added a box yet, do so now. Vagrant will prompt you to select a provider.


1 Answers

Cheat the dns resolution with https://github.com/adrienthebo/vagrant-hosts ?

like image 63
mestachs Avatar answered Nov 04 '22 03:11

mestachs