Add boot check for ipv6 disabled via registry in mirrored mode (#40235)

* Fallback to NAT when IPv6 is disabled via registry for mirrored networking When the registry key HKLM\SYSTEM\CurrentControlSet\Services\Tcpip6\Parameters has DisabledComponents set to 0xFF (all IPv6 components disabled), mirrored networking mode cannot mirror host interfaces. This adds a check in ValidateNetworkingMode() that detects this condition and falls back to NAT networking mode with a user-facing warning. Only mirrored networking mode is affected by this registry key; other networking modes (NAT, Bridged, VirtioProxy) are not checked. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * add registry check * pr review * remove shutdown * re-add shutdown --------- Co-authored-by: Catalin-Emil Fetoiu <cfetoiu@microsoft.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

FetoiuCatalin committed Apr 20, 2026 at 18:30 UTC 8e6584385b4aee064c9b506d94c7713abb61cbd4
3 files changed +38
localization/strings/en-US/Resources.resw
+4
@@ -879,6 +879,10 @@ Falling back to NAT networking.</value>
879 <value>Windows version {}.{} does not have the required features</value>
880 <comment>{FixedPlaceholder="{}"}Command line arguments, file names and string inserts should not be translated</comment>
881 </data>
882 + <data name="MessageMirroredNetworkingNotSupportedIpv6Disabled" xml:space="preserve">
883 + <value>IPv6 is disabled on the host in an unsupported way (HKLM\SYSTEM\CurrentControlSet\Services\Tcpip6\Parameters DisabledComponents=0xff)</value>
884 + <comment>{Locked="HKLM\SYSTEM\CurrentControlSet\Services\Tcpip6\Parameters"}{Locked="DisabledComponents"}{Locked="0xff"}</comment>
885 + </data>
886 <data name="MessageHyperVFirewallNotSupported" xml:space="preserve">
887 <value>Hyper-V firewall is not supported</value>
888 </data>
src/windows/service/exe/WslCoreVm.cpp
+18
@@ -2830,6 +2830,24 @@ void WslCoreVm::ValidateNetworkingMode()
2830 }
2831 }
2832
2833 + // If mirrored networking was requested, ensure IPv6 is not disabled on the host using registry,
2834 + // as this is not supported by mirrored networking.
2835 + // Note: Disabling IPv6 using Set-NetAdapterBinding is supported.
2836 + if (m_vmConfig.NetworkingMode == NetworkingMode::Mirrored)
2837 + {
2838 + constexpr DWORD c_ipv6Disabled = 0xFF;
2839 + DWORD disabledComponents = 0;
2840 + wil::reg::get_value_dword_nothrow(
2841 + HKEY_LOCAL_MACHINE, L"SYSTEM\\CurrentControlSet\\Services\\Tcpip6\\Parameters", L"DisabledComponents", &disabledComponents);
2842 +
2843 + if (disabledComponents == c_ipv6Disabled)
2844 + {
2845 + m_vmConfig.NetworkingMode = NetworkingMode::Nat;
2846 + EMIT_USER_WARNING(Localization::MessageMirroredNetworkingNotSupportedReason(
2847 + Localization::MessageMirroredNetworkingNotSupportedIpv6Disabled()));
2848 + }
2849 + }
2850 +
2851 // If mirrored networking was requested, ensure it is supported by the OS and guest kernel.
2852 if (m_vmConfig.NetworkingMode == NetworkingMode::Mirrored)
2853 {
test/windows/NetworkTests.cpp
+16
@@ -4549,6 +4549,22 @@ class MirroredTests
4549
4550 NetworkTests::VerifyDnsResolutionRecordTypes();
4551 }
4552 +
4553 + WSL2_TEST_METHOD(MirroredFallbackToNatWhenIpv6Disabled)
4554 + {
4555 + MIRRORED_NETWORKING_TEST_ONLY();
4556 +
4557 + // Set the registry key to disable IPv6 globally on the host.
4558 + RegistryKeyChange<DWORD> disableIpv6(
4559 + HKEY_LOCAL_MACHINE, L"SYSTEM\\CurrentControlSet\\Services\\Tcpip6\\Parameters", L"DisabledComponents", 0xFF);
4560 +
4561 + m_config->Update(LxssGenerateTestConfig({.networkingMode = wsl::core::NetworkingMode::Mirrored}));
4562 + // Force a restart so we re-evaluate the networking mode with the regkey set.
4563 + WslShutdown();
4564 +
4565 + // Verify WSL is actually running in NAT mode.
4566 + VERIFY_ARE_EQUAL(LxsstuLaunchWsl(L"wslinfo --networking-mode | grep -iF 'nat'"), 0u);
4567 + }
4568 };
4569
4570 class BridgedTests