Reputation: 43
I have started learning Vagrant. What I want to do is create a private network with 2 guests : ip private network: 192.168.3.0 ip guest #1 (centos8): 192.168.3.1 ip guest #2 (ubuntu20.o4): 192.168.3.2
So: Vagrant.configure("2") do |config| config.vm.network "private_network", ip: "192.168.3.1" end Vagrant.configure("2") do |config| config.vm.network "private_network", ip: "192.168.3.2" end
I thought that setting a network as "Private" no other guests on Vagrant were able to do ping to them or do ssh... Because I can do it. What Must I do? to isolate that network from others guests.
Upvotes: 0
Views: 1531
Reputation: 1052
The only solution I know is specific to the VirtualBox provider, using VirtualBox's internal network feature:
Internal Networking is similar to bridged networking in that the VM can directly communicate with the outside world. However, the outside world is limited to other VMs on the same host which connect to the same internal network.
https://www.virtualbox.org/manual/ch06.html#network_internal
In vagrant you would specify the internal network like this:
config.vm.network "private_network", ip: "192.168.100.4",
virtualbox__intnet: "isolatednet1"
Where isolatednet1
can be any name you want for the internal network. All VirtualBox VMs using the isolatednet1
network will be able to communicate with each other, but they won't be able to communicate with VMs outside the internal network.
Note that instead of a network name you can use a boolean value of true
for virtualbox__intnet
but in that case Vagrant will assign all VMs to the network "intnet". So if you want to achieve isolation you need to assign a unique internal network name for each group of VMs you want to isolate.
Upvotes: 1