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
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.
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.
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.
Cheat the dns resolution with https://github.com/adrienthebo/vagrant-hosts ?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With