Solution#
Different proxy software may have different operations, but not explained in detail here... Here is an example using Clash.
As shown in the figure, the proxy service port number is "7890", remember to enable ALLOW LAN.
Open the bash file of WSL, using the .bashrc
file as an example:
Add the following
# proxy list
# Note that if not exported, other bash scripts cannot access this variable. In order to access it in .ssh/config, you must export it
# https://unix.stackexchange.com/a/495163
export host_ip=$(cat /etc/resolv.conf |grep "nameserver" |cut -f 2 -d " ")
# wget is special, it does not recognize all_proxy, only http_proxy and https_proxy
alias proxy="export all_proxy=http://$host_ip:7890 http_proxy=http://$host_ip:7890 https_proxy=http://$host_ip:7890"
alias unproxy='unset all_proxy http_proxy https_proxy'
proxy
Now let's check the proxy software again, as shown in the figure, the WSL proxy is successful!