Vagrant: Cannot get IPv4 address for Linux guest on Windows host (Hyper-V)

Created on 8 Nov 2018  ยท  5Comments  ยท  Source: hashicorp/vagrant

Vagrant version

Vagrant 2.2.0

Host operating system

Windows 10 Pro 1803

Guest operating system

CentOS 7.5

Vagrantfile

Stripped down from vagrant init centos/7:

Vagrant.configure("2") do |config|
    config.vm.box = "centos/7"
end

Debug output

Provide a link to a GitHub Gist containing the complete debug output:
https://www.vagrantup.com/docs/other/debugging.html. The debug output should
be very long. Do NOT paste the debug output in the issue, just paste the
link to the Gist.

Expected behavior

I used to see an IPv4 address.

Actual behavior

I'm now seeing an IPv6 address, which I can't readily use with all of my downstream tooling.

PS> vagrant up
Bringing machine 'default' up with 'hyperv' provider...
==> default: Verifying Hyper-V is enabled...
==> default: Verifying Hyper-V is accessible...
==> default: Importing a Hyper-V instance
    default: Creating and registering the VM...
    default: Successfully imported VM
    default: Please choose a switch to attach to your Hyper-V instance.
    default: If none of these are appropriate, please open the Hyper-V manager
    default: to create a new virtual switch.
    default:
    default: 1) DockerNAT
    default: 2) Default Switch
    default:
    default: What switch would you like to use? 2
    default: Configuring the VM...
    default: Setting VM Integration Services
==> default: guest_service_interface is enabled
==> default: Starting the machine...
==> default: Waiting for the machine to report its IP address...
    default: Timeout: 120 seconds
    default: IP: fe80::215:5dff:fe9a:19df
==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: fe80::215:5dff:fe9a:19df:22
    default: SSH username: vagrant
    default: SSH auth method: private key
    default:
    default: Vagrant insecure key detected. Vagrant will automatically replace
    default: this with a newly generated keypair for better security.
    default:
    default: Inserting generated public key within guest...
    default: Removing insecure key from the guest if it's present...
    default: Key inserted! Disconnecting and reconnecting using new SSH key...
==> default: Machine booted and ready!

Almost every time I'm given an IPv6 address, I have problems SSHing into the box (not sure if related).

PS> vagrant ssh
An error occurred while executing a PowerShell script. This error
is shown below. Please read the error message and see if this is
a configuration error with your system. If it is not, then please
report a bug.

Script: get_network_config.ps1
Error:

Failed to determine IP address

Sometimes if I reload and ssh again, I can get in, but the box is useless?

[vagrant@localhost ~]$ ping google.com
ping: google.com: Name or service not known

And literally stops responding to input and eventually the shell exits.

needs-repro networking providehyperv waiting-reply

Most helpful comment

Yeah I'm seeing the exact same problem on/off using the builtin "Default Switch" with Hyper-v.

All 5 comments

Yeah I'm seeing the exact same problem on/off using the builtin "Default Switch" with Hyper-v.

Are you experiencing this issue with the latest version of Vagrant (or at least 2.2.1)? It included this PR #10410 which should make address detection more reliable.

For people other than the reporter, check your release version with [Environment]::OSVersion.Version and refer to
https://docs.microsoft.com/en-us/windows/windows-10/release-information

I have one machine with update 1607 and one with 1809. I can reproduce the issue using the bbrala/ubuntu1604 box. @chrisroberts is it reasonable to remove the needs-repro tag?

On the 1809 machine, Hyper-V creates a default switch. This default switch has some unique properties, and works to report the IP address. The 1607 machine does not have this behaviour. I would guess it was introduced in 1809.

If you cannot upgrade your OS, try the workaround in my comment on #9750 ; specifically, the section about applying an IP address to the guest.

Note that on 1607, on first boot, the guest's console showed it was taking a while to apply this IP config, causing vagrant ssh to timeout - but on subsequent boot, everything worked nicely.

I'm no longer experiencing this issue on

Vagrant 2.2.7
Windows 10 Pro 1909 Build 18363.592
Hyper-V 10.0.18362.1

I'm going to lock this issue because it has been closed for _30 days_ โณ. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

Was this page helpful?
0 / 5 - 0 ratings