Environment Introduction#
WSL2: Ubuntu 22.04
Windows Host: Win11 Professional Edition
IP Address of Windows Host#
In WSL2, use the following command:
cat /etc/resolv.conf
Accessing Windows Host from WSL2#
By default, the Windows host firewall will block applications in WSL2 from accessing the Windows network.
Solution: Add a firewall rule to allow WSL2 to access Windows.
Run PowerShell as an administrator and enter the following command:
New-NetFirewallRule -DisplayName "WSL" -Direction Inbound -InterfaceAlias "vEthernet (WSL)" -Action Allow
Note: InterfaceAlias can be checked using the ipconfig command
Test if the firewall rule is added successfully.
Ping the Windows host from WSL2, if successful, it means the rule was added successfully.