Configuring Mirrored Networking Mode in WSL2 on Windows 11 with Kali Linux
In this article, we will cover how to configure mirrored networking mode in WSL2 (Windows Subsystem for Linux version 2) on Windows 11, specifically for the Kali Linux distribution. Mirrored networking mode allows the Linux distribution running in WSL2 to share the IP address of the host Windows machine, enabling seamless networking between the two environments.
Prerequisites
Before we begin, make sure you have the following installed and configured:
- Windows 11
- WSL2 enabled
- Kali Linux distribution installed in WSL2
Configuring Mirrored Networking Mode
To configure mirrored networking mode, follow these steps:
-
Open an elevated PowerShell prompt on your Windows 11 machine.
PowerShell -ExecutionPolicy Bypass -Command "& {Invoke-Expression (& 'ms-settings:windowssecurity' ); Invoke-Expression (& 'ms-settings:network' ); Invoke-Expression (& 'ms-settings:wsl' )}" -
Switch your WSL2 distribution to use the 'localhost' IP address:
wsl --set-default-ipv4-forwarding true wsl --set-hostnamewsl --shutdown -
Configure the firewall rules:
New-NetFirewallRule -DisplayName "WSL-Allow-Localhost" -Direction Inbound -Protocol TCP -LocalPort 127.0.0.1 -Action Allow New-NetFirewallRule -DisplayName "WSL-Allow-WSL-Interface" -Direction Inbound -Protocol TCP -LocalPort-Action Allow -
Restart your Windows 11 machine to apply the changes.
Testing the Configuration
To test the configuration, open a terminal in your Kali Linux distribution and try the following commands:
curl https://ifconfig.co
ping -c 4 google.com
References
-
Microsoft Documentation: Configure the WSL 2 virtual machine settings
-
Microsoft Documentation: WSL 2 networking overview
-
Kali Linux Documentation: Windows Subsystem for Linux (WSL) Networking
This article covers the key concepts and steps required to configure mirrored networking mode in WSL2 on Windows 11 with Kali Linux. By following the instructions provided, you can seamlessly network between your Windows 11 host and Kali Linux distribution.