microsoft / WSL

Issues found on WSL
https://docs.microsoft.com/windows/wsl
MIT License
17.39k stars 819 forks source link

WSL Bridge - Packet Diagram #8208

Closed penguinpages closed 2 years ago

penguinpages commented 2 years ago

Version

Version 10.0.22000.556 (Windows 11)

WSL Version

Kernel Version

5.10.102.1

Distro Version

Ubuntu 20.04

Other Software

No response

Repro Steps

Related thread: https://docs.microsoft.com/en-us/answers/questions/788964/wsl-with-bridging-windows-11.html

Question:

WSL. 1) Does it use bridge to physical NIC and so Windows 11 "Bridge" is means to link from WSL virtual NIC to the physical device 2) Or.. Does it link the WSL virtual nic to HyperV switch.

TOday I can get it to work with HyperV switch "WSL" binding to Gb NIC (with mgmt so base OS works), then enable bridging WSL virtual adapter to Gb NIC.. Total hack job but.. WSL then routes and so does OS. But.. this is 1) Brittle and has to be recomfigured each reboot 2) Is more of poking in the dark then tactically setting up packet paths 3) Does not afford configuration profiles where how I connect (Gb, vs Wifi, vs VPN Virtual adapter) based on where I have to work with laptop.

If someone can explain the data path and connection logic, as well as to "WSL is hidden HyperV guest" and if so.. WHy are we hiding this? What can we do at a command prompt to effect the environment?

Windows11_WSL_HV_Bridging_Wifi

Windows11_WSL_HV_Bridging_Wifi

Expected Behavior

I link WSL to a logical interface:

"Bridge" adapter -> to do L2 bridging to a given NIC, or, Bridge to hyperV switch, which then offloads communication under known HyperV connection setup.... such as link to interface, or internal etc..

I want to run a command, and get back "how is WSL connected" .. the vNIC is listed, and return back is to what device / NIC that the Windows OS controls.

Actual Behavior

It is hidden. No commands exist to list what the virtual WSL host is connecting to No means to track down links and so configuration No means to change profile of bindings as host connections change: Ex: three profiles based on which "NIC" I have to link the WSL intance to.

Diagnostic Logs

Attached are images of trying to poke in the dark... to get things to work, as well as control with best practices.

penguinpages commented 2 years ago

It was suggested to view WSL switch configuruation and mapping to use commands with mixed result and maybe others can post means to map. I expected to see mapping of MAC of vNIC of Ubuntu Instance to map to MAC of some defined bridge interface.. but did not see that.

Windows Admin Powershell `PS C:\WINDOWS\system32> ovn-nbctl ovn-nbctl : The term 'ovn-nbctl' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:1 char:1

PS C:\WINDOWS\system32> get-hnsnetwork

ActivityId : B3FFFB67-59A6-4954-9CBD-7048C9C33DBD AdditionalParams : CurrentEndpointCount : 0 Extensions : {@{Id=E7C3B2F0-F3C5-48DF-AF2B-10FED6D72E7A; IsEnabled=False; Name=Microsoft Windows Filtering Platform}, @{Id=E9B59CFA-2BE1-4B21-828F-B6FBDBDDC017; IsEnabled=False; Name=Microsoft Azure VFP Switch Extension}, @{Id=430BDADD-BAB0-41AB-A369-94B67FA5BE0A; IsEnabled=True; Name=Microsoft NDIS Capture}} Flags : 11 GatewayMac : 00-15-5D-64-8A-00 Health : @{AddressNotificationMissedCount=0; AddressNotificationSequenceNumber=1; DHCPNotificationMissedCount=0; DNSCacheNotificationMissedCount=0; DNSCacheNotificationSequenceNumber=0; DNSNotificationMissedCount=0; DNSNotificationSequenceNumber=0; InterfaceNotificationMissedCount=0; InterfaceNotificationSequenceNumber=0; LastErrorCode=0; LastUpdateTime=132926056728747878; MacAddressNotificationMissedCount=0; MacAddressNotificationSequenceNumber=0; NeighborNotificationMissedCount=0; NeighborNotificationSequenceNumber=0; RouteNotificationMissedCount=0; RouteNotificationSequenceNumber=0; XlatNotificationMissedCount=0; XlatNotificationSequenceNumber=0} ID : C08CB7B8-9B3C-408E-8E30-5E16A3AEB444 IPv6 : False LayeredOn : D7F15566-9910-4732-A7DB-E7359B7E6B77 MacPools : {@{EndMacAddress=00-15-5D-6A-BF-FF; StartMacAddress=00-15-5D-6A-B0-00}} MaxConcurrentEndpoints : 0 Name : Default Switch NatName : ICSC5448807-C36F-41D7-A303-8871B2861C75 Policies : {} State : 1 Subnets : {@{AdditionalParams=; AddressPrefix=172.20.96.0/20; Flags=0; GatewayAddress=172.20.96.1; Health=; ID=B3B802D5-C4FE-4F76-8EA1-4261ED4316FA; IpSubnets=System.Object[]; ObjectType=5; Policies=System.Object[]; State=0}} SwitchGuid : C08CB7B8-9B3C-408E-8E30-5E16A3AEB444 SwitchName : Default Switch TotalEndpoints : 0 Type : ICS Version : 60129542144 Resources : @{AdditionalParams=; AllocationOrder=2; Allocators=System.Object[]; CompartmentOperationTime=0; Flags=0; Health=; ID=B3FFFB67-59A6-4954-9CBD-7048C9C33DBD; PortOperationTime=0; State=1; SwitchOperationTime=0; VfpOperationTime=0; parentId=F0E875DB-992B-48BD-8F3B-239AE5D652F3}

ActivityId : 2A1EFB9A-258A-40EE-8201-044D4ABB5E40 AdditionalParams : CurrentEndpointCount : 0 DNSServerList : 172.23.160.1 Extensions : {@{Id=E7C3B2F0-F3C5-48DF-AF2B-10FED6D72E7A; IsEnabled=False; Name=Microsoft Windows Filtering Platform}, @{Id=E9B59CFA-2BE1-4B21-828F-B6FBDBDDC017; IsEnabled=False; Name=Microsoft Azure VFP Switch Extension}, @{Id=430BDADD-BAB0-41AB-A369-94B67FA5BE0A; IsEnabled=True; Name=Microsoft NDIS Capture}} Flags : 9 GatewayMac : 00-15-5D-03-7D-B7 Health : @{AddressNotificationMissedCount=0; AddressNotificationSequenceNumber=0; DHCPNotificationMissedCount=0; DNSCacheNotificationMissedCount=0; DNSCacheNotificationSequenceNumber=0; DNSNotificationMissedCount=0; DNSNotificationSequenceNumber=0; InterfaceNotificationMissedCount=0; InterfaceNotificationSequenceNumber=0; LastErrorCode=0; LastUpdateTime=132926062586346043; MacAddressNotificationMissedCount=0; MacAddressNotificationSequenceNumber=0; NeighborNotificationMissedCount=0; NeighborNotificationSequenceNumber=0; RouteNotificationMissedCount=0; RouteNotificationSequenceNumber=0; XlatNotificationMissedCount=0; XlatNotificationSequenceNumber=0} ID : B95D0C5E-57D4-412B-B571-18A81A16E005 IPv6 : False IsolateSwitch : True LayeredOn : 66A34A8A-694B-4C49-A07A-1396CBA640E2 MacPools : {@{EndMacAddress=00-15-5D-03-7F-FF; StartMacAddress=00-15-5D-03-70-00}} MaxConcurrentEndpoints : 1 Name : WSL NatName : ICSEF5CE00F-95A8-4370-A1D8-DA4B257783F5 Policies : {} State : 1 Subnets : {@{AdditionalParams=; AddressPrefix=172.23.160.0/20; Flags=0; GatewayAddress=172.23.160.1; Health=; ID=C81DF97C-004B-46CA-B75A-4A81746D13EA; IpSubnets=System.Object[]; ObjectType=5; Policies=System.Object[]; State=0}} TotalEndpoints : 10 Type : ICS Version : 60129542144 Resources : @{AdditionalParams=; AllocationOrder=2; Allocators=System.Object[]; CompartmentOperationTime=0; Flags=0; Health=; ID=2A1EFB9A-258A-40EE-8201-044D4ABB5E40; PortOperationTime=0; State=1; SwitchOperationTime=0; VfpOperationTime=0; parentId=BC684798-A620-4D50-A213-1023FEE347EE}

PS C:\WINDOWS\system32>`

WSL Instance side PS C:\GitHub\cluster_devops\cluster_devops> wsl [sudo] password for ansible: ansible@laptop:/mnt/c/GitHub/blah/cluster_devops$ ip ad 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: bond0: <BROADCAST,MULTICAST,MASTER> mtu 1500 qdisc noop state DOWN group default qlen 1000 link/ether 06:06:dc:99:ab:84 brd ff:ff:ff:ff:ff:ff 3: dummy0: <BROADCAST,NOARP> mtu 1500 qdisc noop state DOWN group default qlen 1000 link/ether 26:b1:da:1e:91:e9 brd ff:ff:ff:ff:ff:ff 4: tunl0@NONE: <NOARP> mtu 1480 qdisc noop state DOWN group default qlen 1000 link/ipip 0.0.0.0 brd 0.0.0.0 5: sit0@NONE: <NOARP> mtu 1480 qdisc noop state DOWN group default qlen 1000 link/sit 0.0.0.0 brd 0.0.0.0 6: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000 link/ether 00:15:5d:03:75:5f brd ff:ff:ff:ff:ff:ff inet 172.16.100.133/24 scope global eth0 valid_lft forever preferred_lft forever ansible@laptop:/mnt/c/GitHub/blah/cluster_devops$

List of NICs from OS perspective `PS C:\WINDOWS\system32> ipconfig /all

Windows IP Configuration

Host Name . . . . . . . . . . . . : laptop Primary Dns Suffix . . . . . . . : Node Type . . . . . . . . . . . . : Hybrid IP Routing Enabled. . . . . . . . : No WINS Proxy Enabled. . . . . . . . : No DNS Suffix Search List. . . . . . : local

Ethernet adapter Ethernet:

Media State . . . . . . . . . . . : Media disconnected Connection-specific DNS Suffix . : myhome.local Description . . . . . . . . . . . : Intel(R) Ethernet Connection (6) I219-LM Physical Address. . . . . . . . . : 38-22-E2-4B-03-F7 DHCP Enabled. . . . . . . . . . . : Yes Autoconfiguration Enabled . . . . : Yes

Unknown adapter OpenVPN Wintun:

Media State . . . . . . . . . . . : Media disconnected Connection-specific DNS Suffix . : Description . . . . . . . . . . . : Wintun Userspace Tunnel Physical Address. . . . . . . . . : DHCP Enabled. . . . . . . . . . . : No Autoconfiguration Enabled . . . . : Yes

Ethernet adapter vEthernet (Default Switch):

Connection-specific DNS Suffix . : Description . . . . . . . . . . . : Hyper-V Virtual Ethernet Adapter Physical Address. . . . . . . . . : 00-15-5D-51-74-30 DHCP Enabled. . . . . . . . . . . : No Autoconfiguration Enabled . . . . : Yes Link-local IPv6 Address . . . . . : fe80::7f:7942:138b:3052%71(Preferred) IPv4 Address. . . . . . . . . . . : 172.20.96.1(Preferred) Subnet Mask . . . . . . . . . . . : 255.255.240.0 Default Gateway . . . . . . . . . : DHCPv6 IAID . . . . . . . . . . . : 1191187805 DHCPv6 Client DUID. . . . . . . . : 00-01-00-01-27-33-B4-AE-38-22-E2-4B-03-F7 NetBIOS over Tcpip. . . . . . . . : Enabled

Ethernet adapter Ethernet 5:

Media State . . . . . . . . . . . : Media disconnected Connection-specific DNS Suffix . : customer.com Description . . . . . . . . . . . : Check Point Virtual Network Adapter For Endpoint VPN Client Physical Address. . . . . . . . . : 54-DD-ED-17-0C-07 DHCP Enabled. . . . . . . . . . . : Yes Autoconfiguration Enabled . . . . : Yes

Unknown adapter NETGEAR-VPN:

Media State . . . . . . . . . . . : Media disconnected Connection-specific DNS Suffix . : Description . . . . . . . . . . . : TAP-Windows Adapter V9 Physical Address. . . . . . . . . : 00-FF-9B-E5-70-08 DHCP Enabled. . . . . . . . . . . : Yes Autoconfiguration Enabled . . . . : Yes

Wireless LAN adapter Local Area Connection* 2:

Media State . . . . . . . . . . . : Media disconnected Connection-specific DNS Suffix . : Description . . . . . . . . . . . : Microsoft Wi-Fi Direct Virtual Adapter #3 Physical Address. . . . . . . . . : 94-E6-F7-53-59-77 DHCP Enabled. . . . . . . . . . . : Yes Autoconfiguration Enabled . . . . : Yes

Wireless LAN adapter Local Area Connection* 3:

Media State . . . . . . . . . . . : Media disconnected Connection-specific DNS Suffix . : Description . . . . . . . . . . . : Microsoft Wi-Fi Direct Virtual Adapter #4 Physical Address. . . . . . . . . : 96-E6-F7-53-59-76 DHCP Enabled. . . . . . . . . . . : No Autoconfiguration Enabled . . . . : Yes

Ethernet adapter Ethernet 2:

Media State . . . . . . . . . . . : Media disconnected Connection-specific DNS Suffix . : Description . . . . . . . . . . . : Fortinet Virtual Ethernet Adapter (NDIS 6.30) Physical Address. . . . . . . . . : 00-09-0F-FE-00-01 DHCP Enabled. . . . . . . . . . . : Yes Autoconfiguration Enabled . . . . : Yes

Wireless LAN adapter Wi-Fi:

Connection-specific DNS Suffix . : local Description . . . . . . . . . . . : Intel(R) Wi-Fi 6 AX200 160MHz Physical Address. . . . . . . . . : 94-E6-F7-53-59-76 DHCP Enabled. . . . . . . . . . . : Yes Autoconfiguration Enabled . . . . : Yes IPv4 Address. . . . . . . . . . . : 172.16.13.61(Preferred) Subnet Mask . . . . . . . . . . . : 255.255.254.0 Lease Obtained. . . . . . . . . . : Wednesday, March 30, 2022 9:09:47 AM Lease Expires . . . . . . . . . . : Saturday, April 2, 2022 9:09:56 AM Default Gateway . . . . . . . . . : 172.16.12.1 DHCP Server . . . . . . . . . . . : 10.254.254.1 DNS Servers . . . . . . . . . . . : 1.1.1.1 1.1.1.1 NetBIOS over Tcpip. . . . . . . . : Enabled

Ethernet adapter Bluetooth Network Connection:

Media State . . . . . . . . . . . : Media disconnected Connection-specific DNS Suffix . : Description . . . . . . . . . . . : Bluetooth Device (Personal Area Network) Physical Address. . . . . . . . . : 94-E6-F7-53-59-7A DHCP Enabled. . . . . . . . . . . : Yes Autoconfiguration Enabled . . . . : Yes PS C:\WINDOWS\system32>`

Questions: 1) What are example commands to root cause the NIC binding from vNIC of WSL Ubuntu instance to physical NIC 2) Is there example power shell command where I can change binding from One Physical NIC to another (or back to original posting, bind it to "WSL" HyperV switch , or Windows Bridge.. and move that connection around to underlying "interface" that would allow the WSL instances to connect where I need. 3) Any insight if HyperV is required / used and hidden. Vs Windows Bridge is the connector and packet path.

Thanks for responses

penguinpages commented 2 years ago

Update:

After reboot , which I avoid like plague now due to the steps needed to get things back working with WSL, I have several weird things happen that may add needed color to above thread

1) The HyperV Virtual switch "WSL" linked to Gb NIC.. disapears 2) The Gb NIC has bridge checked as enabled.... but no icon showing "Network Bridge" 3) When I try to create HyperV switch called "WSL" external link to Gb NIC, it errors with code that it can't complete task that device with that name already exists. 4) When I try to launch WSL, it response:


PS C:\GitHub\cluster_devops\cluster_devops> wsl
The network was not found.
PS C:\GitHub\cluster_devops\cluster_devops>

What command can I run from powershell to query what Network is not found" that it is expecting?