【問題描述】
已經(jīng)在 /etc/profile 中配置了代理了宽档,wget 也能訪問外網(wǎng),可是使用 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 和 端口號需要按照實際情況修改嘴纺。如果沒有該配置文件,則重新創(chuàng)建一個浓冒。
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/";