wsl2的网络和windows不在一起,所以先获取windows的ip地址:

export windows_host=`ipconfig.exe | grep -n4 WSL | tail -n 1 | awk -F":" '{ print $2 }' | sed 's/^[ \r\n\t]*//;s/[ \r\n\t]*$//'`

然后设置http代理

export ALL_PROXY=http://$windows_host:1087

export HTTP_PROXY=$ALL_PROXY

export http_proxy=$ALL_PROXY

export HTTPS_PROXY=$ALL_PROXY

export https_proxy=$ALL_PROXY

以上可以放置到~/.bashrc文件里面,安装了zsh可以放到~/.zshrc

Last modification:June 9th, 2021 at 04:30 am
If you think my article is useful to you, please feel free to appreciate