#WSL2に外部からアクセスする
ひとまず備忘録後で編集する
基本的にはpowershell管理者権限実行
やること
ファイアーウォールの設定
開放
$ New-NetFireWallRule -DisplayName 'WSL 2 Firewall Unlock' -Direction Outbound -LocalPort 22 -Action Allow -Protocol TCP
$ New-NetFireWallRule -DisplayName 'WSL 2 Firewall Unlock' -Direction Inbound -LocalPort 22 -Action Allow -Protocol TCP
設定削除
$ Remove-NetFireWallRule -DisplayName 'WSL 2 Firewall Unlock'
ポートフォワード設定
ここでは22番
$ netsh interface portproxy add v4tov4 listenport=22 connectport=22 connectaddres=(wsl hostname -I).trimend()
確認方法
$ netsh.exe interface portproxy show v4tov4
設定削除
$ netsh.exe interface portproxy delete v4tov4 listenport=22