美文网首页
ubuntu 18.04 配置代理

ubuntu 18.04 配置代理

作者: Weizhuo_Zhang | 来源:发表于2020-06-07 13:48 被阅读0次

【问题描述】
已经在 /etc/profile 中配置了代理了,wget 也能访问外网,可是使用 apt-get update 时却失败了。

报错信息:

root@ubuntu:~$ sudo apt-get update
Err:4 http://ports.ubuntu.com/ubuntu-ports bionic-security InRelease
  Temporary failure resolving 'ports.ubuntu.com'
Err:5 http://cn.ports.ubuntu.com/ubuntu-ports bionic InRelease
  Temporary failure resolving 'cn.ports.ubuntu.com'
Err:6 http://cn.ports.ubuntu.com/ubuntu-ports bionic-updates InRelease
  Temporary failure resolving 'cn.ports.ubuntu.com'
Err:7 http://cn.ports.ubuntu.com/ubuntu-ports bionic-backports InRelease
  Temporary failure resolving 'cn.ports.ubuntu.com'
Reading package lists... Done
W: Failed to fetch http://cn.ports.ubuntu.com/ubuntu-ports/dists/bionic/InRelease  Temporary failure resolving 'cn.ports.ubuntu.com'
W: Failed to fetch http://cn.ports.ubuntu.com/ubuntu-ports/dists/bionic-updates/InRelease  Temporary failure resolving 'cn.ports.ubuntu.com'
W: Failed to fetch http://cn.ports.ubuntu.com/ubuntu-ports/dists/bionic-backports/InRelease  Temporary failure resolving 'cn.ports.ubuntu.com'
W: Failed to fetch http://ports.ubuntu.com/ubuntu-ports/dists/bionic-security/InRelease  Temporary failure resolving 'ports.ubuntu.com'
W: Some index files failed to download. They have been ignored, or old ones used instead.

【解决办法】
通过修改 apt 的配置文件来配置代理。
修改 /etc/apt/apt.conf ,增加以下几行,具体代理 ip 和 端口号需要按照实际情况修改。如果没有该配置文件,则重新创建一个。

Acquire::http::proxy "http://127.0.0.1:1080/";
Acquire::https::proxy "https://127.0.0.1:1080/";
Acquire::ftp::proxy "ftp://127.0.0.1:1080/";

相关文章

网友评论

      本文标题:ubuntu 18.04 配置代理

      本文链接:https://www.haomeiwen.com/subject/jxlctktx.html