vagrant icon indicating copy to clipboard operation
vagrant copied to clipboard

Private network can not be set up on Ubuntu 20 with Vagrant and VirtualBox

Open nagyt234 opened this issue 3 years ago • 1 comments

I have a brand new server and I just installed VirtualBox and Vagrant. If I try to set up a private network, I get the error below in the chapter Actual behavior.

I think the problem is, that vboxmanage hostonlyif create gives this error, what should be ignored, because there are already 128 unconfigured network vboxnet0 - vboxnet127, as to see in output of ifconfig -a.

If I configure the network manually with the following command, than vagrant up is working correctly:

vbvboxmanage hostonlyif ipconfig vboxnet0 --ip 172.16.2.2 --netmask 255.240.0.0

Vagrant version

Vagrant 2.2.19

VirtualBox version

virtualbox 6.1.32-dfsg-1~ubuntu1.20.04.1

Host operating system

Ubuntu 20.04.4 LTS

Guest operating system

Ubuntu 20.04.4 LTS

Vagrantfile

Vagrant.configure("2") do |config|
  config.vm.box = "ubuntu/focal64"
  config.vm.network :private_network, ip: "172.16.2.2", netmask: "255.240.0.0"
end

Debug output

https://gist.github.com/nagyt234/936678060c5a1369fa88ed85ca6034a4

Expected behavior

The VM should be started and the private network shold be configured.

Actual behavior

The VM is not started and the following error reported:

==> default: Importing base box 'ubuntu/focal64'...
==> default: Matching MAC address for NAT networking...
==> default: Checking if box 'ubuntu/focal64' version '20220314.0.0' is up to date...
==> default: Setting the name of the VM: zg2t1_default_1647332766478_80377
==> default: Clearing any previously set network interfaces...
There was an error while executing `VBoxManage`, a CLI used by Vagrant
for controlling VirtualBox. The command and stderr is shown below.

Command: ["hostonlyif", "create"]

Stderr: 0%...
Progress state: NS_ERROR_FAILURE
VBoxManage: error: Failed to create the host-only adapter
VBoxManage: error: VBoxNetAdpCtl: Error while adding new interface: VBoxNetAdpCtl: ioctl failed for /dev/vboxnetctl: Cannot allocate memory
VBoxManage: error: Details: code NS_ERROR_FAILURE (0x80004005), component HostNetworkInterfaceWrap, interface IHostNetworkInterface
VBoxManage: error: Context: "RTEXITCODE handleCreate(HandlerArg*)" at line 95 of file VBoxManageHostonly.cpp

Steps to reproduce

  1. Install a brand new Ubuntu 20
  2. Install VirtualBox and Vagrant
  3. Try to start a minimal VM with private network

nagyt234 avatar Mar 15 '22 09:03 nagyt234

@nagyt234 I have the same version of Vagrant installed with Virtualbox 6.1 (Version 6.1.32_Ubuntu r149290) I am looking at my working Vagrantfile and I have declared a vagrant private network for ubuntu 22.04 (bento/ubuntu-22.04) using the following syntax:

configloop.vm.network "private_network", ip: "192.168.56.100"

I received no errors and virtualbox shows the following: Adapter 1: NAT Adapter 2: Host-only Adapter, 'vboxnet0'

Are you attempting to tell Virtualbox that your network declared above is the only network and should also be the host-only adapter like the docs show:

Vagrant.configure("2") do |config|
  config.vm.network "private_network", ip: "172.16.2.2", netmask: "255.240.0.0",
    virtualbox__intnet: true
end

References:

Providers: VirtualBox - Networking

edits: Wrong code pasted, grammar

MBfromOK avatar Jun 27 '22 22:06 MBfromOK

Hi there,

Thanks for reporting this bug. There have been multiple Vagrant releases since the original report, we recommend upgrading. I'm going to close this issue now and request you reopen the issue if you're still experiencing this problem.

Cheers!

chrisroberts avatar Jun 30 '23 21:06 chrisroberts