hashicorp / vagrant

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

Static IP issues on Windows 8.1 Host #4125

Closed activelogic closed 10 years ago

activelogic commented 10 years ago

Hi, I'm working on an 8.1 Windows Host with Vagrant 1.6.3 and VirtualBox 4.3.12 with the Extension Pack installed.

I've created a custom Centos 6.5 minimal box and packaged it using the VirtualBox GUI.

When attempting to configure a private_network with a static IP I am experiencing two issues:

  1. Vagrant is creating a new network adapter each time with the name VirtualBox Host-Only Ethernet Adapter #X, where X increments each time. This is viewable via the Device Manager > Network Adapters on my Windows host.
  2. The IP as set in the Vagrantfile never matches up with the subnet on the host-only adapter; therefore, does not work. Eg. I've set the IP to be 192.168.100.10 and the host-only adapter on my Windows Host has an IP of 172.28.128.3.

My Vagrantfile is barebones as follows:

config.vm.box = "centos65"
config.vm.network "private_network", ip: "192.168.100.10"

If I switch the configuration to use 'dhcp' instead, everything seems to work fine: IP address is set via dhcp and a single adapter is created and reused on the Windows host for vagrant up calls.

I've looked at https://github.com/mitchellh/vagrant/pull/3818, but it doesn't seem to apply as I'm using 1.6.3 on my Windows Host.

Any ideas how this can be resolved?

Also, I tried to get the debug output, but was unable to, using: vagrant up --debug > debug.log

rpcjacobs commented 10 years ago

Just had the same problem and came here to post the solution as it isn't noted in any documentation, which i found weird. The problem also didn't properly forward the ip ports and network bridges and thus i could not reach the private_network ip.

You need to 'vagrant up' the box, using an elevated prompt (e.g. as administrator). I now also made sure vagrant is always run as administrator, to prevent future issue's.

kikitux commented 10 years ago

hello, the debug must be

VAGRANT_LOG=debug vagrant up

On Mon, Jun 30, 2014 at 7:22 AM, activelogic notifications@github.com wrote:

Hi, I'm working on an 8.1 Windows Host with Vagrant 1.6.3 and VirtualBox 4.3.12 with the Extension Pack installed.

I've created a custom Centos 6.5 minimal box and packaged it using the VirtualBox GUI.

When attempting to configure a private_network with a static IP I am experiencing two issues:

1.

Vagrant is creating a new network adapter each time with the name VirtualBox Host-Only Ethernet Adapter #X, where X increments each time. This is viewable via the Device Manager > Network Adapters on my Windows host. 2.

The IP as set in the Vagrantfile never matches up with the subnet on the host-only adapter; therefore, does not work. Eg. I've set the IP to be 192.168.100.10 and the host-only adapter on my Windows Host has an IP of 172.28.128.3.

My Vagrantfile is barebones as follows:

config.vm.box = "centos65" config.vm.network "private_network", ip: "192.168.100.10"

If I switch the configuration to use 'dhcp' instead, everything seems to work fine: IP address is set via dhcp and a single adapter is created and reused on the Windows host for vagrant up calls.

I've looked at #3818 https://github.com/mitchellh/vagrant/pull/3818, but it doesn't seem to apply as I'm using 1.6.3 on my Windows Host.

Any ideas how this can be resolved?

Also, I tried to get the debug output, but was unable to, using: vagrant up --debug > debug.log

— Reply to this email directly or view it on GitHub https://github.com/mitchellh/vagrant/issues/4125.

mitchellh commented 10 years ago

Closing due to lack of response. Please let me know if you find out more.

vbezruchkin commented 9 years ago

Greetings

I have the same problem. When I start my box using vagrant up I get a new #x network interface created. I use Windows 8.1, vagrant 1.6.5, virtualbox 4.3.16

Could you please advise what to do in order to assign only one interface for my box?

Thanks!

Zeromax commented 9 years ago

I can confirm this Problem as well.

@mitchellh What do you need? Any Debug Output? Tell me how I can help you.

vbezruchkin commented 9 years ago

@zeromax - that's I used different vagrant box and I don't have this problem anymore. Not sure what setting caused the issue. Here is the vagrant config for the server that works fine if it helps:

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

# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  # All Vagrant configuration is done here. The most common configuration
  # options are documented and commented below. For a complete reference,
  # please see the online documentation at vagrantup.com.

  # Every Vagrant virtual environment requires a box to build off of.
  config.vm.box = "ubuntu/trusty32"

  # Disable automatic box update checking. If you disable this, then
  # boxes will only be checked for updates when the user runs
  # `vagrant box outdated`. This is not recommended.
  # config.vm.box_check_update = false

  # Create a forwarded port mapping which allows access to a specific port
  # within the machine from a port on the host machine. In the example below,
  # accessing "localhost:8080" will access port 80 on the guest machine.
  # config.vm.network "forwarded_port", guest: 80, host: 8080

  # Create a private network, which allows host-only access to the machine
  # using a specific IP.
  # config.vm.network "private_network", ip: "192.168.33.10"

  # Create a public network, which generally matched to bridged network.
  # Bridged networks make the machine appear as another physical device on
  # your network.
  # config.vm.network "public_network"

  # If true, then any SSH connections made will enable agent forwarding.
  # Default value: false
  # config.ssh.forward_agent = true

  # Share an additional folder to the guest VM. The first argument is
  # the path on the host to the actual folder. The second argument is
  # the path on the guest to mount the folder. And the optional third
  # argument is a set of non-required options.
  # config.vm.synced_folder "../data", "/vagrant_data"

  # Provider-specific configuration so you can fine-tune various
  # backing providers for Vagrant. These expose provider-specific options.
  # Example for VirtualBox:
  #
  # config.vm.provider "virtualbox" do |vb|
  #   # Don't boot with headless mode
  #   vb.gui = true
  #
  #   # Use VBoxManage to customize the VM. For example to change memory:
  #   vb.customize ["modifyvm", :id, "--memory", "1024"]
  # end
  #
  # View the documentation for the provider you're using for more
  # information on available options.

  # Enable provisioning with CFEngine. CFEngine Community packages are
  # automatically installed. For example, configure the host as a
  # policy server and optionally a policy file to run:
  #
  # config.vm.provision "cfengine" do |cf|
  #   cf.am_policy_hub = true
  #   # cf.run_file = "motd.cf"
  # end
  #
  # You can also configure and bootstrap a client to an existing
  # policy server:
  #
  # config.vm.provision "cfengine" do |cf|
  #   cf.policy_server_address = "10.0.2.15"
  # end

  # Enable provisioning with Puppet stand alone.  Puppet manifests
  # are contained in a directory path relative to this Vagrantfile.
  # You will need to create the manifests directory and a manifest in
  # the file default.pp in the manifests_path directory.
  #
  # config.vm.provision "puppet" do |puppet|
  #   puppet.manifests_path = "manifests"
  #   puppet.manifest_file  = "default.pp"
  # end

  # Enable provisioning with chef solo, specifying a cookbooks path, roles
  # path, and data_bags path (all relative to this Vagrantfile), and adding
  # some recipes and/or roles.
  #
  # config.vm.provision "chef_solo" do |chef|
  #   chef.cookbooks_path = "../my-recipes/cookbooks"
  #   chef.roles_path = "../my-recipes/roles"
  #   chef.data_bags_path = "../my-recipes/data_bags"
  #   chef.add_recipe "mysql"
  #   chef.add_role "web"
  #
  #   # You may also specify custom JSON attributes:
  #   chef.json = { mysql_password: "foo" }
  # end

  # Enable provisioning with chef server, specifying the chef server URL,
  # and the path to the validation key (relative to this Vagrantfile).
  #
  # The Opscode Platform uses HTTPS. Substitute your organization for
  # ORGNAME in the URL and validation key.
  #
  # If you have your own Chef Server, use the appropriate URL, which may be
  # HTTP instead of HTTPS depending on your configuration. Also change the
  # validation key to validation.pem.
  #
  # config.vm.provision "chef_client" do |chef|
  #   chef.chef_server_url = "https://api.opscode.com/organizations/ORGNAME"
  #   chef.validation_key_path = "ORGNAME-validator.pem"
  # end
  #
  # If you're using the Opscode platform, your validator client is
  # ORGNAME-validator, replacing ORGNAME with your organization name.
  #
  # If you have your own Chef Server, the default validation client name is
  # chef-validator, unless you changed the configuration.
  #
  #   chef.validation_client_name = "ORGNAME-validator"

  config.vm.network :forwarded_port, guest: 3000, host: 3000
  config.vm.network "private_network", ip: "192.168.56.2", auto_config: false
end
Zeromax commented 9 years ago

@vbezruchkin thanks for your replay. I have tested your Vagrantfile and the same Problem occures. Vagrant creates a new Network Interface each time with a different IP Adress.

E:\vagrant test>vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Box 'ubuntu/trusty32' could not be found. Attempting to find and install...
    default: Box Provider: virtualbox
    default: Box Version: >= 0
==> default: Loading metadata for box 'ubuntu/trusty32'
    default: URL: https://vagrantcloud.com/ubuntu/trusty32
==> default: Adding box 'ubuntu/trusty32' (v14.04) for provider: virtualbox
    default: Downloading: https://atlas.hashicorp.com/ubuntu/boxes/trusty32/versions/14.04/providers/virtualbox.box
==> default: Box download is resuming from prior download progress
    default: Progress: 100% (Rate: 1398k/s, Estimated time remaining: --:--:--)
==> default: Successfully added box 'ubuntu/trusty32' (v14.04) for 'virtualbox'!
==> default: Importing base box 'ubuntu/trusty32'...
==> default: Matching MAC address for NAT networking...
==> default: Checking if box 'ubuntu/trusty32' is up to date...
==> default: Setting the name of the VM: vagranttest_default_1423498503879_25707
==> default: Clearing any previously set forwarded ports...
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
    default: Adapter 2: hostonly
==> default: Forwarding ports...
    default: 3000 => 3000 (adapter 1)
    default: 22 => 2222 (adapter 1)
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: 127.0.0.1:2222
    default: SSH username: vagrant
    default: SSH auth method: private key
    default: Warning: Connection timeout. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
==> default: Mounting shared folders...
    default: /vagrant => E:/vagrant test

E:\vagrant test>ping 192.168.56.2

Ping wird ausgeführt für 192.168.56.2 mit 32 Bytes Daten:
Zeitüberschreitung der Anforderung.
Zeitüberschreitung der Anforderung.
Zeitüberschreitung der Anforderung.
Zeitüberschreitung der Anforderung.

Ping-Statistik für 192.168.56.2:
    Pakete: Gesendet = 4, Empfangen = 0, Verloren = 4
    (100% Verlust),

The IP Adress inside the machine is set up correct (192.168.56.2). But it is not the same as the ip adress in the hostonly Network Interface (169.254.131.58). The Problem is not the box. It is vagrant which is not able to set the correct Network Interface and IP Adress.

So is there a debug Output which I can show you to help finding the Problem?

Zeromax commented 9 years ago

@mitchellh can you please reopen and tell me what Information do you need?

Zeromax commented 9 years ago

@mitchellh so look here, vagrant up first time: https://gist.github.com/Zeromax/cad69a86864775de408b then a normal vagrant halt vagrant up the second time https://gist.github.com/Zeromax/92a5a334d965c4d98a13

Please have a look at the debug Output. I have installed VB 4.3.24 and Vagrant 1.7.2

Zeromax commented 9 years ago

So I have looked into the log and I think I get the Problem of recreation. Vagrant is searching for a hostonly Adapter with my IP INFO network: Searching for matching hostonly network: 192.168.56.101 Vagrant can not find it and creates a new one instead using the current one which is already set to the VM.

Zeromax commented 9 years ago

Oh man... I think it is a virtual box Problem: https://www.virtualbox.org/ticket/8796 That's a pity...