WSL2配置proxychains
参考上面这个比较方便
除了用proxychains,还可以设置terminal直接走代理,手动修改ip地址比较麻烦, 因为ip地址总是会变,这里用一个脚本来实现:
proxy.sh
#!/bin/sh hostip=$(cat /etc/resolv.conf | grep nameserver | awk '{ print $2 }') wslip=$(hostname -I | awk '{print $1}') port=1080 PROXY_HTTP="http://${hostip}:${port}" set_proxy(){ export http_proxy="${PROXY_HTTP}" export HTTP_PROXY="${PROXY_HTTP}" export https_proxy="${PROXY_HTTP}" export HTTPS_proxy="${PROXY_HTTP}" } unset_proxy(){ unset http_proxy unset HTTP_PROXY unset https_proxy unset HTTPS_PROXY } test_setting(){ echo "Host ip:" ${hostip} echo "WSL ip:" ${wslip} echo "Current proxy:" $https_proxy } if [ "$1" = "set" ] then set_proxy elif [ "$1" = "unset" ] then unset_proxy elif [ "$1" = "test" ] then test_setting else echo "Unsupported arguments." fi
如果要设置terminal走代理,输入:
source ./proxy.sh
或者:
. ./proxy.sh
参考:https://zinglix.xyz/2020/04/18/wsl2-proxy/
------ 2021.9.21更新 ------
1. 安装proxychains
https://www.cnblogs.com/Jay-CFD/p/5713590.html
1. 安装proxychains4
https://zhuanlan.zhihu.com/p/124199138
2. 查看ip
和WSL1不同的是,WSL2有自己单独的ip,可以通过:
ip route | grep default | awk '{print $3}' # 或者 cat /etc/resolv.conf | grep nameserver | awk '{ print $2 }'
查看ip地址。
然后配置:
sudo vim /etc/proxychains.conf
change:
socks4 127.0.0.1 9095
to:
socks5 xxx.xxx.xxx.xxx 1080
中间的x是上面查出来的ip地址,1080是ssr监听的端口。
3. ssr允许来自局域网的连接
4. 设置防火墙
https://blog.csdn.net/qq_40846017/article/details/105351900
让ssr被allowed