对于windows系统来说,配置终端代理确实可以通过小猫(clash)等软件来实现全局代理模式,非常方便。然而,当涉及到windows子系统(wsl)时,由于它是一个独立的linux环境,我们需要额外的步骤来确保它也能使用windows主机的代理设置。
首先,让我们看看Mac终端代理的配置方法:
在Mac上,使用小猫(Clash)配置终端代理非常简单。打开小猫,进入
General
Allow LAN

然而,动态IP每次都需要手动修改,这显然不是一个好的解决方案。为了解决这个问题,我们可以在Mac的代理脚本中进行一些修改,动态获取IP。具体来说,我们可以编辑
~/.bash_profile
function proxy_off(){
unset http_proxy
unset https_proxy
unset ftp_proxy
unset rsync_proxy
echo -e "已关闭代理"
}
<p>function proxy_on() {
export no_proxy="localhost,127.0.0.1,localaddress,.localdomain.com"
host_ip=$(cat /etc/resolv.conf |grep "nameserver" |cut -f 2 -d " ")
export http_proxy="<a href="https://www.php.cn/link/fed34d7c05dcbb596142516748ac52ef">https://www.php.cn/link/fed34d7c05dcbb596142516748ac52ef</a>"
export https_proxy=$http_proxy
export ftp_proxy=$http_proxy
export rsync_proxy=$http_proxy
export HTTP_PROXY=$http_proxy
export HTTPS_PROXY=$http_proxy
export FTP_PROXY=$http_proxy
export RSYNC_PROXY=$http_proxy
echo -e "已开启代理"
}最后,我们需要使环境变量生效,并启用或关闭代理:
# 环境变量生效 source ~/.bash_profile</p><h1>打开 代理</h1><p>proxy_on</p><h1>关闭 代理</h1><p>proxy_off
这样配置后,WSL就可以轻松使用Windows主机的代理设置了,各种
apt-get install
以上就是Windows 终端代理的详细内容,更多请关注php中文网其它相关文章!
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号