Because Windows randomly turns on the firewall without your acknowledge, enforce a cron job to disable it might be the only compromised solution. Partially from @sudoqux
# run as Admin and in windows powershell
$option = New-ScheduledJobOption -RunElevated -RequireNetwork
$atLogin = New-JobTrigger -AtLogOn -User *
$atInterval = New-JobTrigger -Once -RepeatIndefinitely -RepetitionInterval "00:10:00" -At "0am"
Register-ScheduledJob -Name "F wsl firewall" -ScheduledJobOption $option -Trigger $atLogin, $atInterval -ScriptBlock {
Set-NetFirewallProfile -Profile Public -DisabledInterfaceAliases "vEthernet (WSL)";
}
(I know basically nothing about windows powershell, so please let me know if I'm wrong.)
Also don't forget to enable inbound rules on the "Windows" host side.
(Anyway, I don't see any meaningful reasons to reject all of the outgoing connections on WSL to host, considering the host already had its inbound rules.)
New-NetFirewallRule -DisplayName "WSL_Inbound" -Direction Inbound -InterfaceAlias "vEthernet (WSL)" -Action Allow
just don't work.