Differences
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
| windows:wsl [2021/09/02 10:58] – [WSL2 port forwarding] admin | windows:wsl [2022/12/27 17:56] (current) – [WSL2 port forwarding high cpu] admin | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ====== wsl vhdx compact, method ====== | + | ====== wsl vhdx compact, method, reclaim |
| - | * https:// | + | * diskpart |
| + | ++++ Diskpart | | ||
| + | <code BASH> | ||
| + | select vdisk File=”I: | ||
| + | attach vdisk readonly | ||
| + | compact vdisk | ||
| + | detach vdisk | ||
| + | </ | ||
| + | ++++ | ||
| + | |||
| + | ====== WSL2 high cpu ====== | ||
| + | < | ||
| + | taskkill -IM " | ||
| + | wsl --shutdown | ||
| + | </ | ||
| ====== WSL2 port forwarding ====== | ====== WSL2 port forwarding ====== | ||
| - | <code BASH> netsh interface portproxy add v4tov4 listenport=$PORT listenaddress=0.0.0.0 connectport=$PORT connectaddress=127.0.0.1 </ | ||
| + | * https:// | ||
| + | * https:// | ||
| + | |||
| + | <code BASH> netsh interface portproxy add v4tov4 listenport=$PORT listenaddress=0.0.0.0 connectport=$PORT connectaddress=127.0.0.1 </ | ||
| + | :!: | ||
| + | ++++ PowerShell Script for tcp port forward| | ||
| <code bash> | <code bash> | ||
| - | # on unprivileged user | + | # Run on unprivileged user with WSL2 |
| $remoteport = bash.exe -c "ip a s eth0 | grep 'inet '" | $remoteport = bash.exe -c "ip a s eth0 | grep 'inet '" | ||
| $found = $remoteport -match ' | $found = $remoteport -match ' | ||
| Line 22: | Line 41: | ||
| - | # on privileged user | + | # !!!! On privileged user !!!! |
| #[Ports] | #[Ports] | ||
| - | |||
| #All the ports you want to forward separated by coma | #All the ports you want to forward separated by coma | ||
| $ports=@(1433, | $ports=@(1433, | ||
| - | + | ||
| + | # from previous step | ||
| + | $remoteport=' | ||
| #[Static ip] | #[Static ip] | ||
| Line 33: | Line 53: | ||
| $addr=' | $addr=' | ||
| $ports_a = $ports -join ","; | $ports_a = $ports -join ","; | ||
| + | |||
| + | #Remove Firewall Exception Rules | ||
| + | iex " | ||
| + | |||
| + | #adding Exception Rules for inbound and outbound Rules | ||
| + | iex " | ||
| + | iex " | ||
| for( $i = 0; $i -lt $ports.length; | for( $i = 0; $i -lt $ports.length; | ||
| $port = $ports[$i]; | $port = $ports[$i]; | ||
| + | |||
| iex "netsh interface portproxy delete v4tov4 listenport=$port listenaddress=$addr"; | iex "netsh interface portproxy delete v4tov4 listenport=$port listenaddress=$addr"; | ||
| - | iex "netsh interface portproxy add v4tov4 listenport=$port listenaddress=$addr connectport=$port connectaddress=172.31.28.155"; | + | iex "netsh interface portproxy add v4tov4 listenport=$port listenaddress=$addr connectport=$port connectaddress=$remoteport"; |
| } | } | ||
| Line 43: | Line 71: | ||
| # Show rules | # Show rules | ||
| netsh interface portproxy show all | netsh interface portproxy show all | ||
| - | < | ||
| - | * https://www.tune-it.ru/web/alenet/blog/-/blogs/windows-wsl2-docker-zizn-posle-linux | + | # Reset all |
| - | | + | netsh interface portproxy reset |
| + | |||
| + | </ | ||
| + | ++++ | ||
| + | ++++ PowerShell Script for udp port forward socat| | ||
| + | <code bash> | ||
| + | # https://serverfault.com/questions/1051667/forward-incoming-udp-packets-on-windows-server-to-client-on-different-interface | ||
| + | # udp forward | ||
| + | # distr https:// | ||
| + | socat UDP4-RECVFROM: | ||
| + | </ | ||
| + | ++++ | ||
| + | |||
| ====== Windows system linux ====== | ====== Windows system linux ====== | ||
| * Шрифты git clone https:// | * Шрифты git clone https:// | ||