# 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
```

