WSL2中使用代理

8,304 阅读1分钟

WSL2 和 Windows 不共用网络栈,所以需要每一次获取到宿主机的ip地址,比较麻烦,采取一劳永逸的办法,在 ~/.bashrc写入

export hostip=$(cat /etc/resolv.conf |grep -oP '(?<=nameserver\ ).*')
export https_proxy="http://${hostip}:Port"
export http_proxy="http://${hostip}:Port"
export all_proxy="socks5://${hostip}:Port"

可以使用w3m进行测试

sudo apt install w3m
w3m www.google.com