Hyper-V VM network connection problem with Default Switch

Ulrich Plabst 6 Reputation points
2020-11-23T11:18:05.603+00:00

Hi,
since 2 Months I have no internet connectivity from my hyper-V VMs that use the Default Switch. On the same day also my WSL2 lost all internet connection (and never regained it). I think both problems are related because WSL2 uses a vSwitch with NAT under the hood just as a hyper V VM with the DefaultSwitch. As of now I disabled WSL to focus on just getting Hyper-V VMs to work. Let me describe the problems and all the troubleshooting i've done so far:

  • I disabled Hyper-V and WSL, rebooted and reenabled Hyper-V to start all fresh
  • I installed two totally fresh Ubuntu VMs one 20.04 one 18.04 (to check if it's an OS problem).
  • Both Ubuntu VMs have ufw disabled
  • I disabled Windows Defender on all network kinds and enabled Logging of dropped packets. The logs always remain empty.
  • The Host can ping the VMs
  • From neither VM I can ping the Host IP (the IP listed under the DefaultSwitch in ipconfig output) or any other IP Adress (e.g. 8.8.8.8).
  • I can however ping the other VM from either VM
  • from Ubuntu ip neighbour shows the HostIP is REACHABLE
  • tracepath HostIP shows no reply after first hop from either vm: uli@18_04-VM:~$ tracepath 172.8.144.1
    1?: [LOCALHOST] pmtu 1500
    1: no reply
    2: no reply
  • tracepath from Ubuntu 18.04 VM to 20.04 VM works uli@18_04-VM:~$ tracepath 172.28.147.203
    1?: [LOCALHOST] pmtu 1500
    1: 172.28.147.203 0.420ms reached
    1: 172.28.147.203 0.526ms reached
    Resume: pmtu 1500 hops 1 back 1
    • tracepath from Ubuntu 20.04 VM to 18.04 VM show strange output. I could not find out what "???" means in that context. Maybe that problem is unreleated though. uli@20_04-VM:~$ tracepath 172.28.157.110
      1?: [LOCALHOST] pmtu 1500
      1: ??? 0.325ms reached
      1: ??? 0.371ms reached
      Resume: pmtu 1500 hops 1 back 1
    • If I create an external vSwitch and bridge it with my Ethernet Adapter and plug that vSwitch into my VMs I get internet connectivity. Unfortunately that only works when my Laptop is connected via Ethernet. When I try to create an External vSwitch that is bridged with my Wifi Adapter an Error arises "Adding ports to the switch 'External' failed". Then my Host Network is totally broken, I need to reboot and delete the created bridge to fix it. I read somewhere that Hyper-V does not support all Wifi Adapters. I don't know if that makes sense but this just makes me want to solve the problem with the DefaultSwitch even more.
    • I used the easy fix program from https://learn.microsoft.com/en-us/troubleshoot/windows-client/virtualization/cannot-create-hyper-v-virtual-switch several times (I found that it deletes and recreates the DefaultSwitch) because my messing with the Switches totally broke my HostNetwork several times. Unfortunately it does not resolve the connectivity problem of the DefaultSwitch.
    • I checked the syslogs in both VMs and the only suspicous lines I saw was a message that indicated that a degraded feature set for DNS server. I think this is a different problem and probably unrelated, as I cannot ping ip addresses directly so DNS is not involved. Nov 23 10:43:29 18_04-VM systemd-resolved[638]: Using degraded feature set (TCP) for DNS server 172.28.144.1.
      Nov 23 10:44:17 18_04-VM systemd-resolved[638]: Using degraded feature set (UDP) for DNS server 172.28.144.1.
    • I checked the Host Windows EventLog but could not find any suspicous Error or Warning Events
    • Relevant outputs from Ubuntu 18.04 VM uli@18_04-VM:~$ ip addr show
      1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
      link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
      inet 127.0.0.1/8 scope host lo
      valid_lft forever preferred_lft forever
      inet6 ::1/128 scope host
      valid_lft forever preferred_lft forever
      2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
      link/ether 00:15:5d:02:70:00 brd ff:ff:ff:ff:ff:ff
      inet 172.28.157.110/20 brd 172.28.159.255 scope global dynamic noprefixroute eth0
      valid_lft 82910sec preferred_lft 82910sec
      inet6 fe80::16b4:42b1:139:7a3e/64 scope link noprefixroute
      valid_lft forever preferred_lft forever uli@18_04-VM:~$ ip neighbour show
      172.28.147.203 dev eth0 lladdr 00:15:5d:02:70:01 STALE
      172.28.144.1 dev eth0 lladdr 00:15:5d:83:89:cb REACHABLE uli@uli-VM:~$ ip route
      default via 172.28.144.1 dev eth0 proto dhcp metric 20100
      169.254.0.0/16 dev eth0 scope link metric 1000
      172.28.144.0/20 dev eth0 proto kernel scope link src 172.28.157.110 metric 100 uli@uli-VM:~$ ping -c 3 8.8.8.8
      PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data. --- 8.8.8.8 ping statistics ---
      3 packets transmitted, 0 received, 100% packet loss, time 2030ms
    • Host ipconfig output PS C:\Users\uli> ipconfig Windows IP Configuration Ethernet adapter Ethernet: Media State . . . . . . . . . . . : Media disconnected
      Connection-specific DNS Suffix . : Ethernet adapter vEthernet (Default Switch): Connection-specific DNS Suffix . :
      Link-local IPv6 Address . . . . . : fe80::f05e:a6e9:e82f:663c%44
      IPv4 Address. . . . . . . . . . . : 172.28.144.1
      Subnet Mask . . . . . . . . . . . : 255.255.240.0
      Default Gateway . . . . . . . . . : Wireless LAN adapter Local Area Connection* 9: Media State . . . . . . . . . . . : Media disconnected
      Connection-specific DNS Suffix . : Wireless LAN adapter Wi-Fi: Connection-specific DNS Suffix . :
      Link-local IPv6 Address . . . . . : fe80::a547:9652:c867:4f50%5
      IPv4 Address. . . . . . . . . . . : 192.168.2.112
      Subnet Mask . . . . . . . . . . . : 255.255.255.0
      Default Gateway . . . . . . . . . : 192.168.2.1 Ethernet adapter Bluetooth Network Connection: Media State . . . . . . . . . . . : Media disconnected
      Connection-specific DNS Suffix . :
    • Host System Info: Windows 10 Professional Version 10.0.19041 Build 19041

Any Help or guide how to do further troubleshooting would be greatly appreciated. I think something is broken with how the DefaultSwitch uses my Host NAT. Anyhow I invested many many hours into finding the problem now and I could not get anywhere. It would be nice to avoid reinstalling windows as it would require a lot of hours to setup all my developer tools again.

Thanks

Hyper-V
Hyper-V
A Windows technology providing a hypervisor-based virtualization solution enabling customers to consolidate workloads onto a single server.
2,740 questions
0 comments No comments
{count} vote

2 answers

Sort by: Most helpful
  1. Mico Mi 1,926 Reputation points
    2020-11-24T08:51:34.133+00:00

    Hi,
    I found some solutions which may be helpful for you.
    Steps to troubleshoot no internet connection on Ubuntu virtual machine in Hyper-V:

    • In your VM's Hyper-V settings, connect the network adapter to the Default Switch which gives access to host computer's network.
    • In Ubuntu VM, go to Ethernet settings, then select IPv4 tab. Set IPv4 Method to Automatic (DHCP). In front of DNS turn Automatic to OFF, and enter 1.1.1.1,1.0.0.1 for CloudFlare's DNS. Click Apply. Turn off Ethernet and turn back on. I've found this is necessary for changes to take effect, so make sure to turn the Ethernet off and on every time you change Ethernet settings.

    For most cases the above should fix the problem, but if it didn't there are a few more things you can try.

    • In Ubuntu VM, go to Ethernet settings. On Details tab verify that IPv4 Address is in the same network as the host computer on the Default Switch. To verify that, run ipconfig on the host machine, and take a note of the IPv4 Address under Default Switch, for example 172.10.100.15. In Ubuntu VM, if the first 3 parts of the IPv4 Address are the same, for example 172.22.100.75 then they are on the same network. If not, go to IPv4 tab and set IPv4 Method to Manual. Then enter addresses as follows:

    Address: Set it to some IP that is in the same network as the host machine on Default Switch.
    Netmask: Set it to Subnet Mask of the host machine on Default Switch.
    Gateway: Set it to the IP address of the host machine on Default Switch.
    Apply the changes and turn Ethernet off and on again.

    Other things to try:

    • If your router has Access Control enabled, then whitelist the MAC address of the network adapter of the Ubuntu VM.
    • Make sure the network category of the NIC on the switch you are connecting to is "Private".

    $Profile = Get-NetConnectionProfile -InterfaceAlias "vEthernet (Default Switch)"
    $Profile.NetworkCategory = "Private"
    Set-NetConnectionProfile -InputObject $Profile

    • Try installing a Legacy Network Adapter on the VM. You need to use a Generation 1 VM to have this option.
    • Try creating and connecting to an External Virtual Switch and go through the above troubleshooting steps again, replacing Default Switch with External Switch.

    For further information, you can check the following link:
    https://superuser.com/questions/1096918/ubuntu-16-04-vm-on-windows-10-hyper-v-no-network-connectivity
    Please note: Information posted in the given link is hosted by a third party. Microsoft does not guarantee the accuracy and effectiveness of information.

    Thanks for your time!
    Best Regards,
    Mico Mi

    -----------------------------

    If the Answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    2 people found this answer helpful.

  2. Ulrich Plabst 6 Reputation points
    2020-11-25T08:25:24.527+00:00

    Thanks for the reply. Unfortunately I had no luck with your suggestions. It is definitely not a subnet problem. Even if I disable DHCP and configure ip adress, subnet and default gateway myself there is no connection. Switching to an external virtual switch is not an acceptable workaround for me, as it does not work with my wifi adapter only with my ethernet adapter.
    I tried $Profile = Get-NetConnectionProfile -InterfaceAlias "vEthernet (Default Switch)" but it says it cannot find the network. It only works for InterfaceAlias "Wi-Fi" which is the adapter that is connected to the internet at the moment. What does that mean? That there is no network detected that is connected via the "vEthernet (Default Switch)" NIC?
    Anyhow I did some more researching. Especially I now researched that my WSL network connection is broken too (which I think has the same cause). And one possible issue that I can now think of is that the NAT is broken and chooses the wrong network adapter to NAT to. Say for example it NATs to my ethernet Networkadapter but this one is not connected to the internet so it never gets a connection. I read a lot of posts about networking issues with WSL and some of them fixed it with uninstalling an unused network adapter. Unfortunately I do not have unused network adapters.
    Is there any way to configure the NAT behavior of the DefaultSwitch? Or to influence which networkadapter is used for NATting?


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.