I'm starting up a VM with Vagrant, but the Bridged Network Adapter in the guest VM gets an invalid IP. So I can't communicate with it from my host.
When I do vagrant up
I select the WiFi network to be used by the public_network
interface you see in my Vagrantfile:
==> default: Available bridged network interfaces:
1) wlp4s0
If I take a look at the host's IP in that network, it has an IP in the range 192.168.2.0/24
:
wlp4s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.2.172 netmask 255.255.255.0 broadcast 192.168.2.255
...
But the guest machine gets an IP in a range that looks invalid for this network:
eth1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 172.28.128.3 netmask 255.255.255.0 broadcast 172.28.128.255
...
My Vagrantfiule looks like this:
Vagrant.configure(2) do |config|
config.vm.box = 'bento/ubuntu-18.04'
config.vm.hostname = 'ubuntu'
config.vm.provider "virtualbox" do |v|
v.name = 'MyVM'
v.memory = 2048
end
# This is the bridged network:
config.vm.network "public_network", dhcp: true
end
If I change the network like this, to specify an exact IP, then networking works as intended:
config.vm.network "public_network", dhcp: true, ip: "192.168.2.180"
But I can't hardcode an IP there as that depends on what network my users select when doing vagrant up
.
Is there something I'm doing wrong in my Vagrantfile?
Please note: I don't have a wired network outlet available at my location, so I can't test if this issue happens also with ethernet.