wsl使用windows11的代理连接github

这就表示连接成功了

 

export hostip=$(cat /etc/resolv.conf |grep -oP '(?<=nameserver\ ).*') #获得网关地址
export proxyPort=1080 #端口
alias proxy='
export https_proxy="http://${hostip}:${proxyPort}";
export http_proxy="http://${hostip}:${proxyPort}";
export all_proxy="http://${hostip}:${proxyPort}";
echo -e "Acquire::http::Proxy \"http://${hostip}:${proxyPort}\";" | sudo tee -a /etc/apt/apt.conf.d/proxy.conf > /dev/null;
echo -e "Acquire::https::Proxy \"http://${hostip}:${proxyPort}\";" | 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;
'

在~/.profile文件中加入上述代码,并将端口修改,保存后>source ~/.profile
then
>proxy
then
>curl https://wwww.google.com

if it display as follows then it's ok

 

 

『WSL』在 WSL 中使用主机的代理(以 Clash 为例) | NX の 博客 (nickxu.top)

 

posted on 2023-05-12 13:58  风中狂笑  阅读(634)  评论(0编辑  收藏  举报

导航