Switch WSL2 Between NAT and Mirrored via Regedit

This guide explains how to toggle Windows Subsystem for Linux 2 (WSL2) between NAT and mirrored networking modes using the Windows Registry Editor (Regedit). By modifying the WSL registry configuration, you can enforce system-wide network modes to enable advanced features like IPv6 support and localhost binding in mirrored mode, or restore standard network isolation using default NAT mode.

Prerequisites


Step 1: Open the Registry Editor

  1. Press Win + R on your keyboard to open the Run dialog box.
  2. Type regedit and press Enter (or click OK).
  3. Select Yes if prompted by User Account Control (UAC).

Step 2: Navigate to the WSL Registry Key

  1. In the Registry Editor address bar, paste the following path and press Enter:

    HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WSL
  2. If the WSL key does not exist under Windows:

    • Right-click the Windows folder.
    • Select New > Key.
    • Name the new key WSL.

Step 3: Configure the Networking Mode Value

  1. Right-click on an empty space in the right pane of the WSL key.
  2. Select New > String Value (REG_SZ).
  3. Name the value networkingMode.
  4. Double-click the newly created networkingMode entry to edit its data.
  5. Set the Value data according to your requirement:
    • Enter mirrored to enable Mirrored Networking mode.
    • Enter nat to revert to default NAT Networking mode.
  6. Click OK to save the changes.

Step 4: Restart WSL to Apply Changes

Registry changes to WSL networking do not take effect until the WSL subsystem is fully restarted.

  1. Open Command Prompt or PowerShell as an Administrator.

  2. Shut down all running WSL instances by executing:

    wsl --shutdown
  3. Relaunch your preferred Linux distribution.


Step 5: Verify the Active Configuration

To ensure the new network mode is applied, launch your WSL distribution and inspect the network interfaces: