From 0a9f004dc98458f78500191131466aa35ded7fdf Mon Sep 17 00:00:00 2001 From: "Kenneth Benzie (Benie)" Date: Thu, 12 May 2022 21:07:06 +0100 Subject: [PATCH] Add command to let WSL2 access Hyper-V VM IPs https://github.com/microsoft/WSL/issues/6433#issuecomment-762770527 --- profile.ps1 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/profile.ps1 b/profile.ps1 index a79fd37..16da369 100644 --- a/profile.ps1 +++ b/profile.ps1 @@ -41,3 +41,6 @@ Remove-Item alias:wget # Allow the VM running WSL2 to access Windows host, setting is not persistent over reboots New-NetFirewallRule -DisplayName "WSL" -Direction Inbound -InterfaceAlias "vEthernet (WSL)" -Action Allow > $null + +# Allow the VM running WSL2 to access Hyper-V virtual machines, setting is not persistent over reboots +Get-NetIPInterface | where {$_.InterfaceAlias -eq 'vEthernet (WSL)' -or $_.InterfaceAlias -eq 'vEthernet (Default Switch)'} | Set-NetIPInterface -Forwarding Enabled