如果你是指 Debian 官方域名(如 debian.org、ftp.debian.org、security.debian.org 等)在国内访问受限,这是比较常见的情况,通常不是你本地的问题。下面给你几种可行、常用的解决方案,从简单到进阶。
编辑源列表:
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
sudo nano /etc/apt/sources.list
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm main contrib non-free non-free-firmware
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-updates main contrib non-free non-free-firmware
deb https://mirrors.tuna.tsinghua.edu.cn/debian-security bookworm-security main contrib non-free non-free-firmware
deb https://mirrors.ustc.edu.cn/debian/ bookworm main contrib non-free non-free-firmware
deb https://mirrors.ustc.edu.cn/debian/ bookworm-updates main contrib non-free non-free-firmware
deb https://mirrors.ustc.edu.cn/debian-security bookworm-security main contrib non-free non-free-firmware
如果你是 bullseye / sid,把
bookworm换成对应版本名即可。
然后执行:
sudo apt update
sudo apt upgrade
如果你有:
可以临时设置:
export https_proxy=http://127.0.0.1:7890
sudo -E apt update
或 apt 专用代理:
sudo nano /etc/apt/apt.conf.d/95proxies
Acquire::http::Proxy "http://127.0.0.1:7890/";
Acquire::https::Proxy "http://127.0.0.1:7890/";
如果你怀疑是 DNS:
nslookup debian.org
可尝试更换 DNS:
sudo nano /etc/resolv.conf
nameserver 223.5.5.5
nameserver 8.8.8.8
| 错误 | 说明 |
|---|---|
| Connection timed out | 域名被墙或网络不通 |
| 403 / 404 | 镜像路径错误 |
| Unable to connect | 网络或代理问题 |
| Certificate error | 时间不对 / 镜像问题 |
apt update 卡住security.debian.org)你可以把 完整报错贴出来,我可以帮你精确定位 ✅