Open TobiX opened 8 months ago
Related to https://learn.microsoft.com/en-us/windows/wsl/networking#wsl-and-firewall, maybe?
As a side-note, the new mirrored
network mode has solved all these networking problems at once. (No NAT, no problem, I guess)
WSL use WSL (Hyper-V firewall)
as subnet name instead of old WSL
name, you should modify some lines of code
In fact, WSL has officially support similar feature but undocumented, see https://github.com/microsoft/WSL/discussions/9580
Just a heads-up, haven't debugged the problem thoroughly. I haven't been using this tool for a long time and have recently updated to Windows 11, where I ran into similar problems as before so I tried running this tool again, but it didn't affect my WSL2 networks... (So this might be either caused by the update to Windows 11 or some recent change in how WSL2 manages networks)
Running with
-list
now shows two different networks (at least after running the first WSL2 system) and my WSL2 systems seem to use the network this tool doesn't touch:Verbose output
``` > wsl-subnet.exe -list time="2024-03-01T10:09:28+01:00" level=info msg="Networks before action:" { "ID": "b95d0c5e-57d4-412b-b571-18a81a16e005", "Name": "WSL", "Type": "ICS", "Policies": [ { "Type": "VSwitchExtension", "Settings": { "ExtensionID": "f74f241b-440f-4433-bb28-00f89ead20d8" } }, { "Type": "VSwitchExtension", "Settings": { "ExtensionID": "e7c3b2f0-f3c5-48df-af2b-10fed6d72e7a" } }, { "Type": "VSwitchExtension", "Settings": { "ExtensionID": "430bdadd-bab0-41ab-a369-94b67fa5be0a", "Enable": true } } ], "MacPool": { "Ranges": [ { "StartMacAddress": "00-15-5D-B3-90-00", "EndMacAddress": "00-15-5D-B3-9F-FF" } ] }, "Dns": { "ServerList": [ "192.168.100.1" ] }, "Ipams": [ { "Subnets": [ { "IpAddressPrefix": "192.168.100.0/24", "Routes": [ { "NextHop": "192.168.100.1", "DestinationPrefix": "0.0.0.0/0" } ] } ] } ], "Flags": 41, "Health": { "Extra": { "Resources": { "AdditionalParams": {}, "AllocationOrder": 2, "Allocators": [ { "AdapterNetCfgInstanceId": "{3EAD1C6B-97F5-4466-8933-9067BA71E217}", "AdditionalParams": {}, "AllocationOrder": 0, "CompartmendId": 0, "Connected": true, "DNSFirewallRules": true, "DeviceInstanceID": "", "DevicelessNic": true, "DhcpDisabled": true, "EndpointNicGuid": "B95D0C5E-57D4-412B-B571-18A81A16E004", "EndpointPortGuid": "B95D0C5E-57D4-412B-B571-18A81A16E004", "Flags": 0, "Health": { "LastErrorCode": 0, "LastUpdateTime": 133537577228463572 }, "ID": "37F801CB-5BEC-479A-B09B-4A5E284BD124", "InterfaceGuid": "3EAD1C6B-97F5-4466-8933-9067BA71E217", "IsPolicy": false, "IsolationId": 0, "MacAddress": "00-15-5D-A2-D4-82", "ManagementPort": true, "NcfHidden": false, "NetworkId": "B95D0C5E-57D4-412B-B571-18A81A16E005", "NicFriendlyName": "WSL", "NlmHidden": true, "PortFriendlyNamePrefix": "Host Vnic", "PreferredPortFriendlyName": "Host Vnic B95D0C5E-57D4-412B-B571-18A81A16E005", "State": 3, "SwitchId": "B95D0C5E-57D4-412B-B571-18A81A16E005", "Tag": "Host Vnic", "VmPort": false, "WaitForIpv6Interface": false, "nonPersistentPort": false }, { "AdditionalParams": {}, "AllocationOrder": 1, "Dhcp": false, "DisableSharing": false, "Dns": true, "ExternalInterfaceConstraint": 0, "Flags": 0, "Health": { "DHCPState": 1, "DNSState": 2, "ICSState": 2, "LastErrorCode": 0, "LastUpdateTime": 133537577230681457 }, "ICSDHCPFlags": 0, "ICSFlags": 0, "ID": "E82A4145-EF41-4BF3-A821-667337EFFD20", "IsPolicy": false, "Prefix": 24, "PrivateInterfaceGUID": "3EAD1C6B-97F5-4466-8933-9067BA71E217", "State": 3, "SubnetIPAddress": "192.168.100.0", "Tag": "ICS" } ], "CompartmentOperationTime": 0, "Flags": 0, "Health": { "LastErrorCode": 0, "LastUpdateTime": 133537577228393226 }, "ID": "DC9A398E-AEEF-4F4B-ABF3-0B3688961C2D", "PortOperationTime": 0, "State": 1, "SwitchOperationTime": 0, "VfpOperationTime": 0, "parentId": "23DD44F3-6293-4317-816C-F7F36D031E82" }, "LayeredOn": "535afd17-af5c-4f56-92b9-eba63f41b4dd", "SwitchGuid": "b95d0c5e-57d4-412b-b571-18a81a16e005" } }, "SchemaVersion": { "Major": 2, "Minor": 0 } } { "ID": "790e58b4-7939-4434-9358-89ae7ddbe87e", "Name": "WSL (Hyper-V firewall)", "Type": "ICS", "Policies": [ { "Type": "VSwitchExtension", "Settings": { "ExtensionID": "e7c3b2f0-f3c5-48df-af2b-10fed6d72e7a" } }, { "Type": "VSwitchExtension", "Settings": { "ExtensionID": "f74f241b-440f-4433-bb28-00f89ead20d8", "Enable": true } }, { "Type": "VSwitchExtension", "Settings": { "ExtensionID": "430bdadd-bab0-41ab-a369-94b67fa5be0a", "Enable": true } } ], "MacPool": { "Ranges": [ { "StartMacAddress": "00-15-5D-1B-B0-00", "EndMacAddress": "00-15-5D-1B-BF-FF" } ] }, "Dns": { "ServerList": [ "172.19.80.1" ] }, "Ipams": [ { "Subnets": [ { "IpAddressPrefix": "172.19.80.0/20", "Routes": [ { "NextHop": "172.19.80.1", "DestinationPrefix": "0.0.0.0/0" } ] } ] } ], "Flags": 41, "Health": { "Extra": { "Resources": { "AdditionalParams": {}, "AllocationOrder": 2, "Allocators": [ { "AdapterNetCfgInstanceId": "{5FB0EA28-0BBB-4A84-BD4C-BE3E3382DE48}", "AdditionalParams": {}, "AllocationOrder": 0, "CompartmendId": 0, "Connected": true, "DNSFirewallRules": true, "DeviceInstanceID": "", "DevicelessNic": true, "DhcpDisabled": true, "EndpointNicGuid": "790E58B4-7939-4434-9358-89AE7DDBE87F", "EndpointPortGuid": "790E58B4-7939-4434-9358-89AE7DDBE87F", "Flags": 0, "Health": { "LastErrorCode": 0, "LastUpdateTime": 133537577613952682 }, "ID": "7C830209-376B-497C-ACE4-7E714BF934B0", "InterfaceGuid": "5FB0EA28-0BBB-4A84-BD4C-BE3E3382DE48", "IsPolicy": false, "IsolationId": 0, "MacAddress": "00-15-5D-0A-FD-5A", "ManagementPort": true, "NcfHidden": false, "NetworkId": "790E58B4-7939-4434-9358-89AE7DDBE87E", "NicFriendlyName": "WSL (Hyper-V firewall)", "NlmHidden": true, "PortFriendlyNamePrefix": "Host Vnic", "PreferredPortFriendlyName": "Host Vnic 790E58B4-7939-4434-9358-89AE7DDBE87E", "State": 3, "SwitchId": "790E58B4-7939-4434-9358-89AE7DDBE87E", "Tag": "Host Vnic", "VmPort": false, "WaitForIpv6Interface": false, "nonPersistentPort": false }, { "AdditionalParams": {}, "AllocationOrder": 1, "Dhcp": false, "DisableSharing": false, "Dns": true, "ExternalInterfaceConstraint": 0, "Flags": 0, "Health": { "DHCPState": 1, "DNSState": 2, "ICSState": 2, "LastErrorCode": 0, "LastUpdateTime": 133537577616071428 }, "ICSDHCPFlags": 0, "ICSFlags": 0, "ID": "649D8CEB-89B3-4016-A09A-BF5CDCD2D3FA", "IsPolicy": false, "Prefix": 20, "PrivateInterfaceGUID": "5FB0EA28-0BBB-4A84-BD4C-BE3E3382DE48", "State": 3, "SubnetIPAddress": "172.19.80.0", "Tag": "ICS" } ], "CompartmentOperationTime": 0, "Flags": 0, "Health": { "LastErrorCode": 0, "LastUpdateTime": 133537577613952682 }, "ID": "1D17B5CA-E12C-4A3F-B384-37BDB0CB2AF3", "PortOperationTime": 0, "State": 1, "SwitchOperationTime": 0, "VfpOperationTime": 0, "parentId": "98F4840F-C4F9-456F-8C2B-8B93F4FC1BDE" }, "LayeredOn": "dbdbe294-db05-4a40-bc1a-7674f972d1e3", "SwitchGuid": "790e58b4-7939-4434-9358-89ae7ddbe87e" } }, "SchemaVersion": { "Major": 2, "Minor": 0 } } time="2024-03-01T10:09:28+01:00" level=info msg="Removing old WSL network..." time="2024-03-01T10:09:29+01:00" level=info msg="Creating new WSL network..." time="2024-03-01T10:09:30+01:00" level=info msg="New WSL network created successfully" guid=b95d0c5e-57d4-412b-b571-18a81a16e005 ip=192.168.100.1 net=192.168.100.0/24 time="2024-03-01T10:09:30+01:00" level=info msg="Networks after action:" { "ID": "790e58b4-7939-4434-9358-89ae7ddbe87e", "Name": "WSL (Hyper-V firewall)", "Type": "ICS", "Policies": [ { "Type": "VSwitchExtension", "Settings": { "ExtensionID": "e7c3b2f0-f3c5-48df-af2b-10fed6d72e7a" } }, { "Type": "VSwitchExtension", "Settings": { "ExtensionID": "f74f241b-440f-4433-bb28-00f89ead20d8", "Enable": true } }, { "Type": "VSwitchExtension", "Settings": { "ExtensionID": "430bdadd-bab0-41ab-a369-94b67fa5be0a", "Enable": true } } ], "MacPool": { "Ranges": [ { "StartMacAddress": "00-15-5D-1B-B0-00", "EndMacAddress": "00-15-5D-1B-BF-FF" } ] }, "Dns": { "ServerList": [ "172.19.80.1" ] }, "Ipams": [ { "Subnets": [ { "IpAddressPrefix": "172.19.80.0/20", "Routes": [ { "NextHop": "172.19.80.1", "DestinationPrefix": "0.0.0.0/0" } ] } ] } ], "Flags": 41, "Health": { "Extra": { "Resources": { "AdditionalParams": {}, "AllocationOrder": 2, "Allocators": [ { "AdapterNetCfgInstanceId": "{5FB0EA28-0BBB-4A84-BD4C-BE3E3382DE48}", "AdditionalParams": {}, "AllocationOrder": 0, "CompartmendId": 0, "Connected": true, "DNSFirewallRules": true, "DeviceInstanceID": "", "DevicelessNic": true, "DhcpDisabled": true, "EndpointNicGuid": "790E58B4-7939-4434-9358-89AE7DDBE87F", "EndpointPortGuid": "790E58B4-7939-4434-9358-89AE7DDBE87F", "Flags": 0, "Health": { "LastErrorCode": 0, "LastUpdateTime": 133537577613952682 }, "ID": "7C830209-376B-497C-ACE4-7E714BF934B0", "InterfaceGuid": "5FB0EA28-0BBB-4A84-BD4C-BE3E3382DE48", "IsPolicy": false, "IsolationId": 0, "MacAddress": "00-15-5D-0A-FD-5A", "ManagementPort": true, "NcfHidden": false, "NetworkId": "790E58B4-7939-4434-9358-89AE7DDBE87E", "NicFriendlyName": "WSL (Hyper-V firewall)", "NlmHidden": true, "PortFriendlyNamePrefix": "Host Vnic", "PreferredPortFriendlyName": "Host Vnic 790E58B4-7939-4434-9358-89AE7DDBE87E", "State": 3, "SwitchId": "790E58B4-7939-4434-9358-89AE7DDBE87E", "Tag": "Host Vnic", "VmPort": false, "WaitForIpv6Interface": false, "nonPersistentPort": false }, { "AdditionalParams": {}, "AllocationOrder": 1, "Dhcp": false, "DisableSharing": false, "Dns": true, "ExternalInterfaceConstraint": 0, "Flags": 0, "Health": { "DHCPState": 1, "DNSState": 2, "ICSState": 2, "LastErrorCode": 0, "LastUpdateTime": 133537577616071428 }, "ICSDHCPFlags": 0, "ICSFlags": 0, "ID": "649D8CEB-89B3-4016-A09A-BF5CDCD2D3FA", "IsPolicy": false, "Prefix": 20, "PrivateInterfaceGUID": "5FB0EA28-0BBB-4A84-BD4C-BE3E3382DE48", "State": 3, "SubnetIPAddress": "172.19.80.0", "Tag": "ICS" } ], "CompartmentOperationTime": 0, "Flags": 0, "Health": { "LastErrorCode": 0, "LastUpdateTime": 133537577613952682 }, "ID": "1D17B5CA-E12C-4A3F-B384-37BDB0CB2AF3", "PortOperationTime": 0, "State": 1, "SwitchOperationTime": 0, "VfpOperationTime": 0, "parentId": "98F4840F-C4F9-456F-8C2B-8B93F4FC1BDE" }, "LayeredOn": "dbdbe294-db05-4a40-bc1a-7674f972d1e3", "SwitchGuid": "790e58b4-7939-4434-9358-89ae7ddbe87e" } }, "SchemaVersion": { "Major": 2, "Minor": 0 } } { "ID": "b95d0c5e-57d4-412b-b571-18a81a16e005", "Name": "WSL", "Type": "ICS", "Policies": [ { "Type": "VSwitchExtension", "Settings": { "ExtensionID": "e7c3b2f0-f3c5-48df-af2b-10fed6d72e7a" } }, { "Type": "VSwitchExtension", "Settings": { "ExtensionID": "f74f241b-440f-4433-bb28-00f89ead20d8" } }, { "Type": "VSwitchExtension", "Settings": { "ExtensionID": "430bdadd-bab0-41ab-a369-94b67fa5be0a", "Enable": true } } ], "MacPool": { "Ranges": [ { "StartMacAddress": "00-15-5D-45-50-00", "EndMacAddress": "00-15-5D-45-5F-FF" } ] }, "Dns": { "ServerList": [ "192.168.100.1" ] }, "Ipams": [ { "Subnets": [ { "IpAddressPrefix": "192.168.100.0/24", "Routes": [ { "NextHop": "192.168.100.1", "DestinationPrefix": "0.0.0.0/0" } ] } ] } ], "Flags": 41, "Health": { "Extra": { "Resources": { "AdditionalParams": {}, "AllocationOrder": 2, "Allocators": [ { "AdapterNetCfgInstanceId": "{18D71AE9-52DB-49B1-924B-C44EEDCF3D95}", "AdditionalParams": {}, "AllocationOrder": 0, "CompartmendId": 0, "Connected": true, "DNSFirewallRules": true, "DeviceInstanceID": "", "DevicelessNic": true, "DhcpDisabled": true, "EndpointNicGuid": "B95D0C5E-57D4-412B-B571-18A81A16E004", "EndpointPortGuid": "B95D0C5E-57D4-412B-B571-18A81A16E004", "Flags": 0, "Health": { "LastErrorCode": 0, "LastUpdateTime": 133537577698279378 }, "ID": "F547DDD4-0B1A-48AE-8914-96977777C678", "InterfaceGuid": "18D71AE9-52DB-49B1-924B-C44EEDCF3D95", "IsPolicy": false, "IsolationId": 0, "MacAddress": "00-15-5D-54-10-AB", "ManagementPort": true, "NcfHidden": false, "NetworkId": "B95D0C5E-57D4-412B-B571-18A81A16E005", "NicFriendlyName": "WSL", "NlmHidden": true, "PortFriendlyNamePrefix": "Host Vnic", "PreferredPortFriendlyName": "Host Vnic B95D0C5E-57D4-412B-B571-18A81A16E005", "State": 3, "SwitchId": "B95D0C5E-57D4-412B-B571-18A81A16E005", "Tag": "Host Vnic", "VmPort": false, "WaitForIpv6Interface": false, "nonPersistentPort": false }, { "AdditionalParams": {}, "AllocationOrder": 1, "Dhcp": false, "DisableSharing": false, "Dns": true, "ExternalInterfaceConstraint": 0, "Flags": 0, "Health": { "DHCPState": 1, "DNSState": 2, "ICSState": 2, "LastErrorCode": 0, "LastUpdateTime": 133537577700948382 }, "ICSDHCPFlags": 0, "ICSFlags": 0, "ID": "4BBCCB64-D85C-4A76-B15D-53891FB9741E", "IsPolicy": false, "Prefix": 24, "PrivateInterfaceGUID": "18D71AE9-52DB-49B1-924B-C44EEDCF3D95", "State": 3, "SubnetIPAddress": "192.168.100.0", "Tag": "ICS" } ], "CompartmentOperationTime": 0, "Flags": 0, "Health": { "LastErrorCode": 0, "LastUpdateTime": 133537577698279378 }, "ID": "C329AE9A-35D6-4B2F-9202-9DC1DD734E09", "PortOperationTime": 0, "State": 1, "SwitchOperationTime": 0, "VfpOperationTime": 0, "parentId": "5FBF7235-05AD-41B3-87CB-805CAEE61051" }, "LayeredOn": "e835bcd9-ca9c-4c56-9d95-23ba8239eb91", "SwitchGuid": "b95d0c5e-57d4-412b-b571-18a81a16e005" } }, "SchemaVersion": { "Major": 2, "Minor": 0 } } ```