Ubuntu 22.04‘Temporary failure resolving‘ 解决方案

在这里插入图片描述

终极解决方案

  1. 首先安装resolvconf
sudo apt-get install resolvconf 
  1. 使用
    cd /etc/resolvconf/resolv.conf.d/ 进入文件夹,使用 ls 查看目录,会显示 base head tail

  2. 使用 sudo vim base 编辑base文件,

    进入时为空,点击 i 添加

	nameserver 114.114.114.114
	nameserver 114.114.114.115
:wq 保存退出。
  1. 使用 sudo resolvconf -u 更新配置。

至此大功告成!

可以重启一下试试拉

root@6527d9173397:/# apt update Ign:1 http://archive.ubuntu.com/ubuntu jammy InRelease Ign:2 http://security.ubuntu.com/ubuntu jammy-security InRelease Ign:2 http://security.ubuntu.com/ubuntu jammy-security InRelease Ign:3 http://archive.ubuntu.com/ubuntu jammy-updates InRelease Ign:4 http://archive.ubuntu.com/ubuntu jammy-backports InRelease Ign:2 http://security.ubuntu.com/ubuntu jammy-security InRelease Ign:1 http://archive.ubuntu.com/ubuntu jammy InRelease Err:2 http://security.ubuntu.com/ubuntu jammy-security InRelease Temporary failure resolving 'security.ubuntu.com' Ign:3 http://archive.ubuntu.com/ubuntu jammy-updates InRelease Ign:4 http://archive.ubuntu.com/ubuntu jammy-backports InRelease Ign:1 http://archive.ubuntu.com/ubuntu jammy InRelease Ign:3 http://archive.ubuntu.com/ubuntu jammy-updates InRelease Ign:4 http://archive.ubuntu.com/ubuntu jammy-backports InRelease Err:1 http://archive.ubuntu.com/ubuntu jammy InRelease Temporary failure resolving 'archive.ubuntu.com' Err:3 http://archive.ubuntu.com/ubuntu jammy-updates InRelease Temporary failure resolving 'archive.ubuntu.com' Err:4 http://archive.ubuntu.com/ubuntu jammy-backports InRelease Temporary failure resolving 'archive.ubuntu.com' Reading package lists... Done Building dependency tree... Done Reading state information... Done All packages are up to date. W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/jammy/InRelease Temporary failure resolving 'archive.ubuntu.com' W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/jammy-updates/InRelease Temporary failure resolving 'archive.ubuntu.com' W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/jammy-backports/InRelease Temporary failure resolving 'archive.ubuntu.com' W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/jammy-security/InRelease Temporary failure resolving 'security.ubuntu.com' W: Some index files failed to download. They have been ignored, or old ones used instead.
06-12
### 解决方案 在处理 `Ign` 错误时,通常是因为系统未能成功解析指定的镜像地址或者网络配置存在问题。以下是针对该问题的具体分析和解决方案。 #### 1. 修改APT源列表 如果遇到类似于 `Temporary failure resolving 'mirrors.aliyun.com'` 的错误,可以尝试更换其他可用的国内镜像源。编辑 `/etc/apt/sources.list` 文件并替换为清华大学或其他稳定镜像站点的内容: ```bash sudo nano /etc/apt/sources.list ``` 将原有的阿里云源替换成清华源,例如对于 Ubuntu 22.04 (Jammy),可使用以下内容[^1]: ```plaintext deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy main restricted universe multiverse deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy main restricted universe multiverse deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-updates main restricted universe multiverse deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-updates main restricted universe multiverse deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-backports main restricted universe multiverse deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-backports main restricted universe multiverse deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-security main restricted universe multiverse deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-security main restricted universe multiverse ``` 保存文件后运行以下命令刷新软件包索引: ```bash sudo apt update ``` #### 2. 配置DNS设置 有时 DNS 设置可能导致域名解析失败。可以通过修改 `/etc/resolv.conf` 来添加 Google 的公共 DNS 地址作为备用选项[^3]: ```bash sudo nano /etc/resolv.conf ``` 在文件顶部添加以下两行内容: ```plaintext nameserver 8.8.8.8 nameserver 8.8.4.4 ``` 完成后再次执行更新操作验证效果: ```bash sudo apt update ``` #### 3. 安装特定版本的 Vim-Runtime 当某些依赖项缺失或未正确安装时,可能会引发类似的警告消息。为了确保所需组件已就绪,请先确认当前系统的发行版代号是否匹配目标仓库的要求。接着按照官方指南完成 Git LFS 和相关工具链部署过程中的每一步骤[^2]。 例如,在基于 Ubuntu 的发行版上自动检测适合自己的 dist 参数值的方法如下所示: ```bash (. /etc/lsb-release && curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | sudo env os=ubuntu dist="${DISTRIB_CODENAME}" bash) ``` 最后重新加载环境变量以应用更改,并测试新安装的功能模块是否正常工作。 --- ###
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

一休哥※

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值