跳到主要内容

WSL2代理设置

获取Windows主机IP地址

cat /etc/resolv.conf | grep nameserver

输出的IP地址即是Windows主机的IP地址。

这里win的ip一般是172.26.208.1

设置代理

代理应为:

export https_proxy=http://172.26.208.1:7890
export http_proxy=http://172.26.208.1:7890
export all_proxy=socks5://172.26.208.1:7890
# 测试代理可用性
source ~/.bashrc

sudo apt update

curl -I http://www.google.com

ping github.com

自动设置代理

vim ~/.bashrc

将上面的代理设置添加到文件的最后

source ~/.bashrc

补充WSL的ip

WSL的IP需要在WSL中使用ifconfig查看

WSL的ip一般为172.26.209.126

这个ip可以使用win的powershell直接pin到