Solved on Windows 11, Virtual Box Version 6.1.40 r154048 (Qt5.6.2), Vagrant 2.3.4
Let's first understand some basic DHCP concepts. If you open up Virtual Box and go to File > Host Network Manager OR type Ctrl + H you will see the following window.
What you need to understand is that a DHCP server simple allocates IPs to new virtual machines in this context.
Click on the DCHP Server tab to see the range of available IP addresses.
What this picture is telling us is that we can allocate IP's ranging from 101 < n < 254 where n is placed on 192.168.56.n
So in our Vagrant file we can do, I picked an arbitrary box:
# -*- mode: ruby -*-
# vi: set ft=ruby :
# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure("2") do |config|
config.vm.box = "ubuntu/xenial64"
config.vm.define "web" do |web|
web.vm.network "private_network", ip: "192.168.56.101", virtualbox__intnet: false
end
config.vm.define "db" do |db|
db.vm.network "private_network", ip: "192.168.56.102", virtualbox__intnet: false
end
end
If you want to see the progress of your VM, click on Show
It will show you a command line displaying logs of the process
Once that is done, you can ping both of your machines from your host command line:
ping 192.168.56.101
Pinging 192.168.56.101 with 32 bytes of data:
Request timed out.
Request timed out.
Reply from 192.168.56.101: bytes=32 time=1ms TTL=64
Reply from 192.168.56.101: bytes=32 time=1ms TTL=64
As you can see, oddly enough the first pings timed out but after that they start reaching the VM. For this, I don't have an explanation but it works afterwards.
The virtualbox__intnet: false option basically tells Vagrant to allow connectivity from the host to the VMs. Otherwise, the VMs would only be able to communicate between each other but not the outside world. Here's the doc reference for that