vagrant icon indicating copy to clipboard operation
vagrant copied to clipboard

Vagrant fails to setup networking on ubuntu host using net-tools and ipv6+intnet on virtualbox

Open crasu opened this issue 3 years ago • 2 comments

Vagrant version

Vagrant 2.2.6

Host operating system

Ubuntu focal

Guest operating system

Ubuntu focal

Vagrantfile

Vagrant.configure("2") do |config|  
  config.vm.box = "magmacore/magma_dev"

  config.vbguest.auto_update = false
  config.vm.network "private_network", ip: "3001::10", nic_type: "82540EM", virtualbox__intnet: "mynetwork", netmask: "96"
end

Debug output

DEBUG network: Normalized configuration: {:type=>"static", :ip=>"3001::10", :netmask=>"96", :adapter=>4, :mac=>nil, :intnet=>"mynetwork", :auto_config=>true, :nic_type=>"82540EM", :virtualbox__intnet=>"mynetwork", :protocol=>"tcp", :id=>"bb5058ea-6b5e-4855-8530-13e7d75ad857"}

Expected behavior

The box should come up.

Actual behavior

Configuring the network fails.

The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!

/sbin/ifdown 'eth1' || true
/sbin/ip addr flush dev 'eth1'
# Remove any previous network modifications from the interfaces file
sed -e '/^#VAGRANT-BEGIN/,$ d' /etc/network/interfaces > /tmp/vagrant-network-interfaces.pre
sed -ne '/^#VAGRANT-END/,$ p' /etc/network/interfaces | tac | sed -e '/^#VAGRANT-END/,$ d' | tac > /tmp/vagrant-network-interfaces.post
cat \
  /tmp/vagrant-network-interfaces.pre \
  /tmp/vagrant-network-entry \
  /tmp/vagrant-network-interfaces.post \
  > /etc/network/interfaces
rm -f /tmp/vagrant-network-interfaces.pre
rm -f /tmp/vagrant-network-entry
rm -f /tmp/vagrant-network-interfaces.post

/sbin/ifup 'eth1'

Stdout from the command:



Stderr from the command:

RTNETLINK answers: Cannot assign requested address
Broadcast can be set only for IPv4 addresses
ifup: failed to bring up eth1

Steps to reproduce

  1. vagrant up with the included vagrant script

References

Network type set to static instead of static6 when using intnet option

This leads to a wrong template being rendered at this place: https://github.com/hashicorp/vagrant/blob/main/plugins/guests/debian/cap/configure_networks.rb#L137

crasu avatar Aug 16 '22 18:08 crasu

You can work around this issue by specifying the type of network. For example:

  config.vm.network "private_network", type: "static6", ip: "3001::10", nic_type: "82540EM", virtualbox__intnet: "mynetwork", netmask: "96"

I think Vagrant should be able to recognize that the provided ip is ipv6 and set the network type accordingly.

soapy1 avatar Aug 25 '22 15:08 soapy1

Yepp this seems to work thank you!

crasu avatar Sep 12 '22 09:09 crasu

This is resolved by https://github.com/hashicorp/vagrant/pull/13024 🙌

soapy1 avatar Jan 12 '23 21:01 soapy1