Pages

Thursday, March 12, 2015

How to setup a private network in Vagrant?

Follow the steps given below to setup a private network in Vagrant.
  • Specify the node names (node 1, node 2 etc) and their static IPs (any preferred IP) in the Vagrant configuration file as given below:

Vagrant.configure("2") do |config|
  config.vm.provision "shell", inline: "echo Hello"

  config.vm.define "master" do |master|
    master.vm.box = "hashicorp/precise32"
    master.vm.network :private_network, ip: "33.33.33.10"
  end

  config.vm.define “node01" do | node01|
    node01.vm.box = "hashicorp/precise32"
   node01.vm.network :private_network, ip: "33.33.33.11"
  end

  config.vm.define "node02" do |node02|
    node02.vm.box = "hashicorp/precise32"
    node02.vm.network :private_network, ip: "33.33.33.12"
  end
end

  • Start and initialise new Vagrant instances

vagrant init

  • You can ssh to each instance by their names
Example:
vagrant ssh node01

No comments:

Post a Comment