Published on

WSL2 关防火墙

Authors

Add "allow" rule to Windows firewall for WSL2 network · Issue #4585 · microsoft/WSL · GitHub

1. 关闭防火墙

好像重启就不行了,又要重新设置

#Requires -RunAsAdministrator

Set-NetFirewallProfile -Profile Private -DisabledInterfaceAliases "vEthernet (WSL)"
Set-NetFirewallProfile -Profile Public -DisabledInterfaceAliases "vEthernet (WSL)"

2.设置防火墙规则

New-NetFirewallRule -DisplayName "WSL" -Direction Inbound  -InterfaceAlias "vEthernet (WSL)"  -Action Allow