From 344e6b3d72ce9bdec7c5c268e74ba4c5f1eeb4c4 Mon Sep 17 00:00:00 2001 From: YIk Teng Hie Date: Mon, 24 May 2021 09:43:29 +0800 Subject: [PATCH] enable WSL to HyperV networking --- wsl-vm/README.md | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 wsl-vm/README.md diff --git a/wsl-vm/README.md b/wsl-vm/README.md new file mode 100644 index 0000000..9f4ebfe --- /dev/null +++ b/wsl-vm/README.md @@ -0,0 +1,25 @@ +# WSL VM Networking + +* Powershell (run as administrator) +* [Steps](https://automatingops.com/allowing-windows-subsystem-for-linux-to-communicate-with-hyper-v-vms) to enable networking between WSL & HyperV + +```powershell +// show switches +$ Get-VMSwitch + +// show networking interfaces +$ Get-NetIPInterface + +// enable forwarding of wsl +$ Get-NetIPInterface | ` +where {$_.InterfaceAlias -eq 'vEthernet (WSL)'} | ` +Set-NetIPInterface -Forwarding Enabled -Verbose + +// verify forwarding enabled +$ Get-NetIPInterface | where {$_.InterfaceAlias -eq 'vEthernet (WSL)'} | Select-Object ifIndex,InterfaceAlias,ConnectionState,Forwarding + + +// enble on both WSL & Default switch +$ Get-NetIPInterface | where {$_.InterfaceAlias -eq 'vEthernet (WSL)' -or $_.InterfaceAlias -eq 'vEthernet (Default Switch)'} | Set-NetIPInterface -Forwarding Enabled -Verbose +``` +