DEV Community

Yuil Tripathee
Yuil Tripathee

Posted on

Network interfacing issues faced using WSL 2 (and fixes)

#1 - Memory not releasing back

It becomes overload to the system and eventually leading to Blue Screen of Death if not treated on time.

# only termination (still VM is alive)
wsl -t kali-linux

# shutdown
wsl --shutdown kali-linux
Enter fullscreen mode Exit fullscreen mode

#2 - WSL2 network ports are virtual and cannot be accessed from LAN

# for port forwarding
netsh interface portproxy add v4tov4 listenport=8001 listenaddress=192.168.0.10 connectport=80 connectaddress=192.168.0.10

# for listing
netsh interface portproxy show all

# for cleanup
netsh interface portproxy reset

# or,
netsh interface portproxy delete

# ON and OFF
netsh interface portproxy add v4tov4 listenport=4422 listenaddress=192.168.1.111 connectport=80 connectaddress=192.168.0.33

netsh interface portproxy delete v4tov4 listenport=4422 listenaddress=192.168.1.111
Enter fullscreen mode Exit fullscreen mode

You need to get Linux IP (use ip route). Check official docs for more information. Also, you can use NGINX with the following configuration:

events {}

http {
     server {

        listen 192.168.1.111:4422;

        location / {
            proxy_pass http://192.168.2.33:80/;
        }
     }
}
Enter fullscreen mode Exit fullscreen mode

Top comments (0)