WSL2不能共享Windows的代理策略,需要WSL2配置代理
获取宿主机IP
1 2 3
|
export hostip=$(cat /etc/resolv.conf |grep -oP '(?<=nameserver ).*')
|
终端设置代理
1 2 3 4 5 6 7
| export https_proxy="http://${hostip}:7890"; export http_proxy="http://${hostip}:7890";
export http_proxy="socks5://${hostip}:7890" export https_proxy="socks5://${hostip}:7890"
export all_proxy="socks5://${hostip}:7890"
|
设置别名使用
1 2 3 4 5 6 7 8 9 10 11 12 13
| export hostip=$(ip route | grep default | awk '{print $3}') export hostport=7890 alias proxy=' export HTTPS_PROXY="http://${hostip}:${hostport}"; export HTTP_PROXY="http://${hostip}:${hostport}"; export ALL_PROXY="http://${hostip}:${hostport}"; ' alias unproxy=' unset HTTPS_PROXY; unset HTTP_PROXY; unset ALL_PROXY; '
|