hashicorp / vagrant

Vagrant is a tool for building and distributing development environments.
https://www.vagrantup.com
Other
26.28k stars 4.43k forks source link

The way to create interfaces without attaching IP addresses #10927

Open proelbtn opened 5 years ago

proelbtn commented 5 years ago

I can't find a way to create interfaces without attaching IP addresses. so, I read the source code.

https://github.com/hashicorp/vagrant/blob/master/plugins/guests/debian/cap/configure_networks.rb#L42

I don't have any ideas to create interfaces without attaching IP addresses, so I decided to rewrite the source code.

                if network[:type].to_s == "dhcp"
                  entry["dhcp4"] = true
                elsif network[:ip] != nil
                  mask = network[:netmask]
                  if mask && IPAddr.new(network[:ip]).ipv4?
                    begin
                      mask = IPAddr.new(mask).to_i.to_s(2).count("1")
                    rescue IPAddr::Error
                      # ignore and use given value

are there other ways or options to create interfaces without attaching an IP address?

Vagrant version

$ vagrant -v
Vagrant 2.2.4

Host operating system

macOS Mojave 10.14.5

Guest operating system

ubuntu/bionic64

Vagrantfile

# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure("2") do |config|
  config.vm.define "dpdk" do |config|
    config.vm.box = "ubuntu/bionic64"
    config.vm.provider "virtualbox" do |v|
      v.cpus = 4
      v.memory = 8192
    end
    config.vm.network "private_network", ip: "172.16.0.101"
    config.vm.network "private_network", ip: nil, virtualbox__intnet: "dpdk-int-1"
    config.vm.network "private_network", ip: nil, virtualbox__intnet: "dpdk-int-2"
  end
end
briancain commented 5 years ago

Hi @proelbtn - I don't think that is currently supported at all with Vagrant. You might be able to do it with shell provisioners instead:

https://wiki.debian.org/NetworkConfiguration#Bringing_up_an_interface_without_an_IP_address

But I don't think it's possible otherwise at the moment with Vagrant.

proelbtn commented 5 years ago

I know that this problem is solved temporarily using shell provisioners. but, If we change the base box, we must change the provisioners. I think it's very frustrating. and I think this feature should be supported for convenience. so, I will issue the pull request. I would like to get your feedback.

briancain commented 5 years ago

Hi @proelbtn - We can likely try to support it in vagrant....however we'll have to make sure it works for every possible guests networking capability. That will likely take a decent amount of effort making this a fairly sizable issue. I've marked it as an enhancement for now. I think your quickest path to get this working at least is shell provisioners until we can work on this issue. Thanks!

proelbtn commented 5 years ago

Thanks, briancain! I'm looking forward to implementing this feature!