Hyper-V VMs (and WSL 2) Unable to Bridge Internet

Avatar
9

Greetings All,

This has been killing me for a few weeks now.

Windows 10 Pro, everything working well from Windows.

However, after installing the Hyper-V toolchain and cremating a new VM, I’m unable to access outgoing internet in the guest VM (internet from the host remains fully functional).

The same thing happens with WSL 2 installs. I’ll download Ubuntu 20.04 LTS, from the MS Store, for instance. Ubuntu loads fine, but no outbound traffic. I can’t sudo apt update or even ping google.com (100% packet loss).

I’m sure I’ve muffed up the Virtual Switches or the NAT or whatever that Hyper-V is using but I don’t know how to tell nor can I figure out how to fix it (either I’m finding the wrong tutorials or I’m effing them up when following them).

Anyone have links to some good resources to get this all up and running.

I have tried uninstalling / reinstalling Hyper-V with Windows Add or Remove Features. I have also tried the network reset. But I’m not 100% sure I did it right.

Thanks in advance for your time!

Comments (9)

9 responses to “Hyper-V VMs (and WSL 2) Unable to Bridge Internet”

  1. Avatar

    wright_is

    Habe your created a bridge or Nat switch and attached it to the VM? If you are bridging, is the VM getting an IP address (DHCP) , or have you entered it manually? Is it in the correct sub net?


    Is the standard gateway correctly set in the IP settings? (ipconfig /all on Windows or ifconfig on Linux).


    I've not experienced any problems with WSL2.


    Do you have AV or firewall running on the Windows PC? Try turning off the firewall and test again.

    • Avatar

      curtisspendlove

      In reply to wright_is:

      I tried to manually create a NAT switch in Hyper-V but I don’t think I did it right.


      And this reminded me that I do have Docker s for Windows installed and it works correctly. It seems that it setup a Hyper-V Switch with NAT.


      It seems that Hyper-V can only have one switch with a NAT so if I want Docker and other VMs to be able to route out I think I need to remove it and create one myself that can work for all VMs.


      I’ll also try your ideas of configuring manually instead of via DHCP, etc.


      I am running a couple of UniFi network devices (EdgeRouter as my gateway and DHCP) and an 8 Port PoE switch. I will double check the IP / Submet as well. I’m running pretty standard on 192.168.1.x. But I’m a novice in networking so I wouldn’t be surprised if I had something configured incorrectly.


      Part of my problem is that I’m pretty new to “bridging” and NAT and the differences and such.


      Learning though. And even though this is a bit frustrating it is also kinda fun.


      ;)


      Thanks for the Ideas!

      • Avatar

        wright_is

        In reply to curtisspendlove:

        Bridging means that the VMs can see your network and get an IP address from your DHCP server (Unifi Edge?).

        NAT has its own subnet and needs to assign a network access on that subnet to the VMs and all external traffic must be handled by the PC. That means that the devices should have a different subnet to the main network.

      • Avatar

        infloop

        In reply to curtisspendlove:


        It could be the case that you got tripped up by the terminology Microsoft uses for their virtual switches, though. The virtual switch types are External, Internal, and Private. Microsoft does not have one that has NAT capabilities like VirtualBox, for example.


        External means the virtual switch binds to a physical network adapter, and any VMs that use the switch will be visible to the physical network that the network adapter is connected to. Internal means it will create a network that is for the virtual machines on the host and the host itself. It will not have access to a physical network. And Private means the virtual switch will create a network that only the virtual machines on the host will be able to see. So more restrictive than Internal as it leaves out the host.

  2. Avatar

    markwibaux

    What type of network are you bridging to, is it wired or wireless?

    If wireless, you could be hitting an issue with broadcast filtering in the configuration of your SSID. Different AP vendors call it different things in the config, it could be "broadcast filtering" or "ARP filtering" in the settings.

    Basically having that enabled will stop the VM being able to get an IP address/communicate over the shared wireless link

    • Avatar

      curtisspendlove

      In reply to MarkWibaux:

      I appreciate the feedback. I was not aware of this...exactly why I figured this community would have some great ideas.


      I have tried both wired and wireless with the same results. But honestly, I’ve done so many things to try to fix it that it’s tricky to remember specifics.


      :/


      I’m thinking at this point I’m going to do another uninstall of everything potentially using Hyper-V, reset my network, and reinstall in a very specific (but yet-to-be-determined) order.

  3. Avatar

    curtisspendlove

    Thanks for the input everyone. It all helped and I’m making progress.


    part of the problem is that I’m just used to things working with simpler solutions like VirtualBox. But I see that Hyper-V is more powerful (and therefore more complex).


    It also appears that Docker does some magic voodoo or something and takes over NAT. :: shrug ::


    I’m ripping down and resetting things again tomorrow and will try a few experiments to see what happens. (If it comes down to it I don’t need Docker desktop for Windows, I can just install WSL 2 and call it good. I was just trying to get a nice experience with Docker running since it has some really cool integrations with VS Code.)

  4. Avatar

    crboehm

    I've had a couple instances where WSL2 can't reach the internet and in my case it was a bad entry in the /etc/resolv.conf file.

    After some online searches I added the /etc/wsl.conf file with the following in it:

    [network]

    generateResolvConf = false

    nameserver 1.1.1.1


    I also changed the entry in resolv.conf to

    nameserver 1.1.1.1


    And that did the trick for me.

Leave a Reply