S
S
Sergei Iamskoi2021-12-27 16:21:26
Computer networks
Sergei Iamskoi, 2021-12-27 16:21:26

How to throw WSL2 out?

This question was asked a couple of years ago: https://qna.habr.com/q/906041 and received an answer. Now it was necessary to repeat this, but the method is no longer working, it seems that something has changed during this time.

So there is WSL2 with Debian. Ip: 172.28.45.56, I run it for the test

php -S 0.0.0.0:80

At 127.0.0.1 and 172.28.45.56 from Windows the server responds. OK. For the purity of the experiment, I disable the Windows firewall, although the rule is configured for the 80th port.
I do:
netsh interface portproxy add v4tov4 listenport=80 listenaddress=0.0.0.0 connectport=80 connectaddress=172.28.45.56


But there is no connection from the outside (while I'm testing within the local area). How to set up this thing?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexey Dmitriev, 2021-12-27
@syamskoy

In Hyper-V Manager - Virtual Switch Manager for virtual switch WSL - set External - then WSL will have to get an external ip address from the same DHCP server as the network card in Windows.
If in WSL it is worth obtaining an address not via DHCP, then
sudo ip addr flush dev eth0
sudo dhclient eth0
If you need to configure it manually, then sudo ip addr
add 192.168.0.116/24 dev eth0 ://github.com/CzBiX/WSLHostPatcher

R
rPman, 2021-12-27
@rPman

wsl2 is a normal virtual machine with hardware virtualization and very strange crooked mapping of the file system to the host (which causes a lot of oddities and problems) and network problems.
to raise a full-fledged virtual machine (standard hiperv or virtualbox) is a matter of ten minutes (debootstrap or deploy a regular installation on a ram disk), so why suffer and solve almost specially created problems from Microsoft?
moreover, later, transferring linux from a virtual machine to new hardware is a couple of gestures, when it’s not so easy as from wsl.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question