在wsl中使用windows的代理 (已过时)

在wsl中使用windows的代理 (已过时)

参考:https://zhuanlan.zhihu.com/p/414627975

1. 在~/.bashrc中添加

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# add for proxy
export hostip=$(ip route | grep default | awk '{print $3}')
export hostport=10809
alias proxy='
export HTTPS_PROXY="http://${hostip}:${hostport}";
export HTTP_PROXY="http://${hostip}:${hostport}";
export ALL_PROXY="http://${hostip}:${hostport}";
echo -e "Acquire::http::Proxy \"http://${hostip}:${hostport}\";" | sudo tee -a /etc/apt/apt.conf.d/proxy.conf > /dev/null;
echo -e "Acquire::https::Proxy \"http://${hostip}:${hostport}\";" | sudo tee -a /etc/apt/apt.conf.d/proxy.conf > /dev/null;
'
alias unproxy='
unset HTTPS_PROXY;
unset HTTP_PROXY;
unset ALL_PROXY;
sudo sed -i -e '/Acquire::http::Proxy/d' /etc/apt/apt.conf.d/proxy.conf;
sudo sed -i -e '/Acquire::https::Proxy/d' /etc/apt/apt.conf.d/proxy.conf;
'

2. 开启并验证

1
proxy
1
curl https://www.google.com

在wsl中使用windows的代理 (已过时)
https://blog.fredbill.eu.org/programming/wsl-use-windows-proxy/
作者
FredBill
发布于
2023年11月11日
许可协议