内网服务器连不上源站,给 yum 和 apt 配代理

yum 和 dnf 只认配置文件里的 proxy 项,环境变量不生效。

在 yum.conf 的 main 段加一行 proxy=http://代理IP:3128。

apt 在 apt.conf.d 下新建文件,写 Acquire 的 http 代理项。

配完先用 curl 走代理试拉一个源站,通了再清缓存同步元数据。

# yum / dnf:在 /etc/yum.conf 或 /etc/dnf/dnf.conf 的 [main] 段
proxy=http://PROXY_IP:3128

# apt:新建 /etc/apt/apt.conf.d/95proxy
Acquire::http::Proxy "http://PROXY_IP:3128";
Acquire::https::Proxy "http://PROXY_IP:3128";

# 验证与刷新
curl -I -x http://PROXY_IP:3128 http://mirrors.aliyun.com
yum clean all && yum makecache
apt-get clean && apt-get update
THE END
喜欢就支持一下吧
点赞12 分享
评论 抢沙发

请登录后发表评论

    暂无评论内容