Skip to content

Instantly share code, notes, and snippets.

@ik11235
Created August 15, 2020 08:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ik11235/8d423072d9a15ed8504a8f0f3d6917d9 to your computer and use it in GitHub Desktop.
Save ik11235/8d423072d9a15ed8504a8f0f3d6917d9 to your computer and use it in GitHub Desktop.
wsl2→windowsホストマシンへのアクセスをすべて許可するやーつ
# 過去に作成したルールを削除する
Remove-NetFirewallRule -DisplayName "WSL-access-approval"
# 現在のwslマシンのIPアドレスを取得、そのアドレスからのアクセスはすべて許可する
$wsl_ip_accress = wsl bash -c "ip addr show dev eth0 | grep -v inet6 |grep inet |cut -d / -f 1 | sed 's/^ *\| *$//' |cut -d ' ' -f 2"
New-NetFirewallRule -DisplayName "WSL-access-approval" -Direction Inbound -RemoteAddress ${wsl_ip_accress} -Action Allow
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment