I want to create multiple servers that can communicate directly with each other without using public IPs. They'll still need internet access but nothing from outside the network will need to connect to them. Creating one box usually works, but when I add additional servers the networking fails.
MacOS: 10.8.5
Virtualbox: 4.3.12
GuestOS: Ubuntu "precise64"
Using version 2 of the Vagrant config
Most of the time if I use private network I get:
saltminion01: Warning: Connection timeout. Retrying...
saltminion01: Warning: Connection timeout. Retrying...
saltminion01: Warning: Connection timeout. Retrying...
saltminion01: Warning: Connection timeout. Retrying...
saltminion01: Warning: Connection timeout. Retrying...
saltminion01: Warning: Connection timeout. Retrying...
saltminion01: Warning: Connection timeout. Retrying...
saltminion01: Warning: Connection timeout. Retrying...
saltminion01: Warning: Connection timeout. Retrying...
Does anybody have a sample Vagrantfile that does this?
You can either use so called multi-machine environment to manage these boxes together in one project/Vagrantfile. They don't necessarily have to be somehow connected, ease of management may be the reason alone, e.g. if you need to start them up at the same time.
Configure port forwarding This allows you to access a port on your own machine, but actually have all the network traffic forwarded to a specific port on the guest machine. To set up a forwarded port so you can access Apache on your guest, add the config. vm.network parameter to your Vagrantfile.
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.
Vagrant.configure("2") do |config| # ... end. The "2" in the first line above represents the version of the configuration object config that will be used for configuration for that block (the section between the do and the end ). This object can be very different from version to version.
Here's an example which creates two VMs:
From inside either VM you can reach the other by IP address, and can connect to the outside world.
Vagrantfile:
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrant multi-machine sample setup
Vagrant.configure("2") do |config|
config.vm.define :alpha do |alpha|
alpha.vm.box = "hashicorp/precise64"
alpha.vm.network :private_network, ip: "10.0.0.10"
alpha.vm.hostname = "alpha"
end
config.vm.define :beta do |beta|
beta.vm.box = "hashicorp/precise64"
beta.vm.network :private_network, ip: "10.0.0.11"
beta.vm.hostname = "beta"
end
end
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