Ref: - [https://learn.microsoft.com/en-us/windows/wsl/networking](https://learn.microsoft.com/en-us/windows/wsl/networking) - [https://superuser.com/questions/1679757/how-to-access-windows-localhost-from-wsl2](https://superuser.com/questions/1679757/how-to-access-windows-localhost-from-wsl2) ### WSL2 to Windows 1. Obtain the IP address of your host machine (Windows) by running this command from your Linux distribution: ```bash cat /etc/resolv.conf ``` 2. Copy the IP address following the term: nameserver. 3. Add rule to Firewall so that incoming connections to the target Windows port is allowed. ```powershell New-NetFirewallRule -DisplayName "" -InterfaceAlias "vEthernet (WSL)" -Direction Inbound -Protocol TCP -LocalPort -Action Allow ``` 5. Connect to any Windows server using the copied IP address Alternatively Windows server can be accessed with the host/domain: `"$(hostname).local"` Alternatively IP of the Windows server may be accessed from ```bash ip route show | grep -i default | awk '{ print $3}' ``` ### Port forward from Windows to WSL2 Powershell command: ```Powershell netsh interface portproxy add v4tov4 listenport= listenaddress=0.0.0.0 connectport= connectaddress= ``` Obtain from ```powershell wsl hostname -I ``` To see existing port-forwardings: ```Powershell netsh interface portproxy show all ``` To delete a particular port-forwarding: ```Powershell netsh interface portproxy delete v4tov4 listenport= listenaddress= ```