s-blog

Linux 命令行设置代理

ssssmy · 2026-06-05 · 1 min · CentOS

命令行程序或 shell 脚本不一定遵循系统代理设置,需单独设置环境变量。注意 ping 不支持代理,测试外网请用 curl

设置代理

export http_proxy="http://127.0.0.1:7890"
export https_proxy="http://127.0.0.1:7890"

取消代理

unset http_proxy
unset https_proxy

以上只对当前终端窗口有效。要永久生效,把命令加到 .bashrc 中。

原文链接:https://www.ssssmy.com/notes/linux-ming-ling-xing-she-zhi-dai-li