Can't Ping Ubuntu VM from WSL2 Ubuntu

Viewed 1963

I am trying to ping my Ubuntu VM from my WSL2 Ubuntu. And same ping issue happening for vice versa. Both ubuntu version are 20.04.1. But I can ping Ubuntu VM from my Local Windows.

From Windows To Ubuntu VM

WUVM

From WSL2 Ubuntu To Ubuntu VM

WSLUVM

2 Answers

We need to set Forwarding to be enabled across the two v-Switches. Using this command (with admin rights) based on my v-Switch names works.

Get-NetIPInterface | where {$_.InterfaceAlias -eq 'vEthernet (WSL)' -or $_.InterfaceAlias -eq 'vEthernet (Default Switch)'} | Set-NetIPInterface -Forwarding Enabled

Below is my network connection

enter image description here

That's a great command line ! Minor improvment that would product less logs, invoke Enabled only if state is Disabled.

Get-NetIPInterface | select ifIndex,InterfaceAlias,AddressFamily,ConnectionState,Forwarding| where {$_.InterfaceAlias -eq 'vEthernet (WSL)' -or $_.InterfaceAlias -eq 'vEthernet (Default Switch)'} | where {$_.Forwarding -eq 'Disabled'} | Set-NetIPInterface -Forwarding 'Enabled'
Related