Skip to content

Instantly share code, notes, and snippets.

@wenlilearn
wenlilearn / wsl2-network.ps1
Last active August 5, 2021 18:31 — forked from xmeng1/wsl2-network.ps1
WSL2 Port forwarding port to linux
$remoteport = wsl hostname -I
$found = $remoteport -match '\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}';
if( $found ){
$remoteport = $matches[0];
} else{
echo "The Script Exited, the ip address of WSL 2 cannot be found";
exit;
}