0

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.

1 Answer 1

0

I found the issue, by default, my network's Adapter Type was set to "Intel PRO/1000 MT Desktop". I changed it to "PCNet FAST III", and then networking works and my machine gets a valid IP.

There is a related question here.

There is more information about the different adapter types in VirtualBox's docs:

The PCNet FAST III is the default because it is supported by nearly all operating systems, as well as by the GNU GRUB boot manager. As an exception, the Intel PRO/1000 family adapters are chosen for some guest operating system types that no longer ship with drivers for the PCNet card, such as Windows Vista.

The Intel PRO/1000 MT Desktop type works with Windows Vista and later versions. The T Server variant of the Intel PRO/1000 card is recognized by Windows XP guests without additional driver installation. The MT Server variant facilitates OVF imports from other platforms.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .