Vagrant: config.winrm.host + config.vm.network static ip conflict?

Created on 9 May 2018  ·  3Comments  ·  Source: hashicorp/vagrant

What am I trying to do here...?

I'm currently experimenting with Windows Server 2012 R2 automation and attempted to configure winrm with SSL enabled as my provisioner. As pointed out by the issue 9187 I'm forced to explicitly define a host parameter to circumvent an error.

Thus I changed my network adapters:

wlp2s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.0.26  netmask 255.255.255.0  broadcast 192.168.0.255
        inet6 2a00:9fe0:205:4500:e1c1:ff7b:e7b5:182e  prefixlen 64  scopeid 0x0<global>
        inet6 2a00:9fe0:205:4500::24  prefixlen 128  scopeid 0x0<global>
        inet6 fe80::a55:74a4:3902:7da0  prefixlen 64  scopeid 0x20<link>
        ether 9c:b6:d0:fa:d7:cb  txqueuelen 1000  (Ethernet)
        RX packets 821430  bytes 1082954017 (1.0 GiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 252856  bytes 63691135 (60.7 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

wlp2s0:0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.111.1  netmask 255.255.255.0  broadcast 192.168.111.255
        ether 9c:b6:d0:fa:d7:cb  txqueuelen 1000  (Ethernet)

My goal is to set a static IP for the guest VM to 192.168.111.10, but the combination of config.winrm.host = "192.168.111.10" and windows_server.vm.network "public_network", ip: "192.168.111.10", bridge: ENV['VAGRANT_BRIDGE'] doesn't correctly assign a static IP to my guest when running vagrant up. The environment variable VAGRANT_BRIDGE is set to wlp2s0 (since vagrant doesn't seem to recognize my virtual adapter wlp2s0:0 before vagrant up is called).

Vagrant version

Vagrant version: 2.1.1

Host operating system

Fedora 27

Guest operating system

Windows Server 2012 R2 (x64)

Vagrantfile

  config.vm.define "windows_server" do |windows_server|
    windows_server.vm.box = "packer/box/windows-server-2012-r2-x64.box"
    windows_server.vm.network "public_network", ip: "192.168.111.10", bridge: ENV['VAGRANT_BRIDGE']
    windows_server.vm.guest = "windows"
    windows_server.vm.network "forwarded_port", guest: 5986, host: 5986, host_ip: "192.168.111.1", auto_correct: true, guest_ip: '192.168.111.10'
    windows_server.vm.communicator = "winrm"
    windows_server.winrm.username = "Administrator"
    windows_server.winrm.host = "192.168.111.10"
    windows_server.winrm.port = 5986
    windows_server.winrm.guest_port = 5986
    windows_server.winrm.transport = "ssl"
    windows_server.winrm.timeout = 3600
    windows_server.vm.provider "virtualbox" do |virtualbox|
      virtualbox.name = "Windows Server 2012 R2"
      virtualbox.cpus = 4
      virtualbox.memory = 4096
    end
end

Debug output

See the gist

Expected behavior

Vagrant should've set the static IP (192.168.111.10) on the Windows Server guest.

Actual behavior

Vagrant picked an IP from the wrong subnet, instead of the correct subnet 192.168.111.1/24 it requested an arbitrary IP (most likely via DHCP) from 192.168.0.1/24.

References

gueswindows networking

Most helpful comment

@TonyApuzzo welp, good luck. I'm sure the Linux side of vagrant is at least possible to troubleshoot unlike this Windows abomination.

All 3 comments

I'm unsure if this is even an issue with vagrant on it's own or if my network configuration is just terrible.
Can somebody confirm this is a common issue?

I have been having vaguely similar problems with Vagrant since 2.1.0 with CentOS guest not paying attention to ip settings (in fact I keep getting duplicate IPs assigned with External Switches) But you are doing enough differently than me that our issues could be entirely separate. Sorry.

@TonyApuzzo welp, good luck. I'm sure the Linux side of vagrant is at least possible to troubleshoot unlike this Windows abomination.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

StefanScherer picture StefanScherer  ·  3Comments

tomhking picture tomhking  ·  3Comments

mpontillo picture mpontillo  ·  3Comments

Cbeck527 picture Cbeck527  ·  3Comments

hesco picture hesco  ·  3Comments