WSL2 网络代理

wsl2 本地网络代理配置

WSL2 获取 win10 IP

1
cat /etc/resolv.conf

WSL2 设置环境变量

1
export ALL_PROXY=socks5://$windows_host:10808

git 也可以设置为使用代理

1
2
git config --list
git config --global https.proxy socks5://$windows_host:10808

每次生效

~/.bashrc

1
2
3
4
5
6
7
8
9
10
export windows_host=`cat /etc/resolv.conf|grep nameserver|awk '{print $2}'`
export ALL_PROXY=socks5://$windows_host:10808
export HTTP_PROXY=$ALL_PROXY
export http_proxy=$ALL_PROXY
export HTTPS_PROXY=$ALL_PROXY
export https_proxy=$ALL_PROXY

if [ "`git config --global --get https.proxy`" != "socks5://$windows_host:10808" ]; then
git config --global https.proxy socks5://$windows_host:10808
fi

代理设置 允许局域网连接

Win10 防火墙

名称 xray