banner
Tenifs

Tenifs

雄关漫道真如铁,而今迈步从头越。
github
follow
zhihu
email

Accessing Windows host from WSL2

Environment Introduction#

WSL2: Ubuntu 22.04
Windows Host: Win11 Professional Edition

image

image

IP Address of Windows Host#

In WSL2, use the following command:

cat /etc/resolv.conf

image

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

image

image

Test if the firewall rule is added successfully.
Ping the Windows host from WSL2, if successful, it means the rule was added successfully.

image

References#

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.