banner
Tenifs

Tenifs

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

Accessing Windows host in WSL2

Environment Introduction#

WSL2: Ubuntu 22.04
Windows Host: Win11 Professional Edition

image

image

Windows Host IP Address#

In WSL2, use the following command:

cat /etc/resolv.conf

image

Accessing Windows Host from WSL2#

By default, the Windows host firewall will block WSL2 applications 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: You can use the ipconfig command to check the InterfaceAlias

image

image

Test if the firewall rule is successfully added.
Ping the Windows host from WSL2, if you can ping successfully, 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.