apt 更新 debian 11 bullseye 时无法解析“deb.debian.org”

apt 更新 debian 11 bullseye 时无法解析“deb.debian.org”

我安装了 debian 11 Bullseye,这是我的 source.list 文件:

deb http://deb.debian.org/debian bullseye main contrib non-free
deb-src http://deb.debian.org/debian bullseye main contrib non-free

deb http://security.debian.org/debian-security bullseye-security main contrib non-free
deb-src http://security.debian.org/debian-security bullseye-security main contrib non-free

deb http://deb.debian.org/debian bullseye-updates main contrib non-free
deb-src http://deb.debian.org/debian bullseye-updates main contrib non-free

deb http://deb.debian.org/debian bullseye-backports main contrib non-free
deb-src http://deb.debian.org/debian bullseye-backports main contrib non-free

当我尝试使用 更新时apt update,出现以下错误:

Err:1 http://deb.debian.org/debian bullseye InRelease
Could not resolve 'deb.debian.org'
Err:2 http://security.debian.org.debian-security bullseye InRelease
Could not resolve 'deb.debian.org'
Err:3 http://deb.debian.org/debian bullseye-updates InRelease
Could not resolve 'deb.debian.org'
Err:4 http://security.debian.org.debian bullseye-backports InRelease
Could not resolve 'deb.debian.org'
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
All packages are up to date.
W: Failed to fetch http://deb.debian.org/debian/dists/bullseye/InRelease Could not resolve 'deb.debian.org'
W: Failed to fetch http://security.debian.org/debian-security/dists/bullseye-security/InRelease Could not resolve 'security.debian.org'
W: Failed to fetch http://deb.debian.org/debian/dists/bullseye-updates/InRelease Could not resolve 'deb.debian.org'
W: Failed to fetch http://deb.debian.org/debian/dists/bullseye-backports/InRelease Could not resolve 'deb.debian.org'
W: Some index files failed to download. They have been ignored, or old ones used instead.

我的 source.list 文件有什么问题?还有什么要设置的吗?

答案1

以 root 身份复制/etc/resolv.conf(CLI cp /etc/resolv.conf /etc/resolv.conf.orig)。然后运行以下命令。

# printf '%s\n' 'nameserver 1.1.1.1' 'nameserver 1.0.0.1' > /etc/resolv.conf
# ping -c 4 deb.debian.org; printf 'Return code: %s\n' "$?"

如果最后一行是Return code: 0apt update应该可以正常工作。

相关内容