goosefrumps
goosefrumps

Reputation: 91

How to create 2 vagrant instances in 2 seperate directories be on the same private network

The name of this post pretty much sums my question up. How do I create 2 vagrant instances in 2 seperate directories be on the same private network?

example:

app/
   Vagrantfile -> has a single vm instance running
some_other_app/
   Vagrantfile -> also has a single vm instance running

Now I want to put them on the same private network. I know that I should put the vms in one folder and it will wire them up for me, but I have a very confusingly written work project that has this structure. In order to test my dev changes I need the machines to be able to speak to eachother on the private network.

Remember: - I can not reformat the directory

There certainly has to be a VBoxManage command out there that does this for you.

https://www.virtualbox.org/manual/ch06.html

Upvotes: 0

Views: 50

Answers (1)

Tarun Lalwani
Tarun Lalwani

Reputation: 146510

Add below to your app Vagrantfile

  config.vm.network "private_network", ip: "192.168.33.100"

Then below to your other app Vagrantfile

  config.vm.network "private_network", ip: "192.168.33.101"

This will assign them IP in same network and then can reach each other using the IP 192.168.33.100 and 192.168.33.101

Upvotes: 1

Related Questions