LINUX:错误“Could not resolve host: mirrors.aliyun.com; Unknown error“
创始人
2024-09-26 14:25:55
0

前提

前提:使用SSH连接虚拟机

           操作系统镜像版本:CentOS-7-x86_64-Minimal-2207-02

           配置文件变更为:(地址:centos-vault镜像_centos-vault下载地址_centos-vault安装教程-阿里巴巴开源镜像站 (aliyun.com)

#Linux  Centos 7.9.2009 minorver=7.9.2009 sudo sed -e "s|^mirrorlist=|#mirrorlist=|g" \          -e "s|^#baseurl=http://mirror.centos.org/centos/\$releasever|baseurl=https://mirrors.aliyun.com/centos-vault/$minorver|g" \          -i.bak \          /etc/yum.repos.d/CentOS-*.repo

       

错误

该错误产生的原因:DNS 服务器配置

                                 系统无法解析域名
[root@localhost ~]# yum -y install wget
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
https://mirrors.aliyun.com/centos-vault/7.9.2009/os/x86_64/repodata/repomd.xml: [Errno 14] curl#6 - "Could not resolve host: mirrors.aliyun.com; Unknown error"
Trying other mirror.


 One of the configured repositories failed (CentOS-7 - Base),
 and yum doesn't have enough cached data to continue. At this point the only
 safe thing yum can do is fail. There are a few ways to work "fix" this:

     1. Contact the upstream for the repository and get them to fix the problem.

     2. Reconfigure the baseurl/etc. for the repository, to point to a working
        upstream. This is most often useful if you are using a newer
        distribution release than is supported by the repository (and the
        packages for the previous distribution release still work).

     3. Run the command with the repository temporarily disabled
            yum --disablerepo=base ...

     4. Disable the repository permanently, so yum won't use it by default. Yum
        will then just ignore the repository until you permanently enable it
        again or use --enablerepo for temporary usage:

            yum-config-manager --disable base
        or
            subscription-manager repos --disable=base

     5. Configure the failing repository to be skipped, if it is unavailable.
        Note that yum will try to contact the repo. when it runs most commands,
        so will have to try and fail each time (and thus. yum will be be much
        slower). If it is a very temporary problem though, this is often a nice
        compromise:

            yum-config-manager --save --setopt=base.skip_if_unavailable=true

failure: repodata/repomd.xml from base: [Errno 256] No more mirrors to try.
https://mirrors.aliyun.com/centos-vault/7.9.2009/os/x86_64/repodata/repomd.xml: [Errno 14] curl#6 - "Could not resolve host: mirrors.aliyun.com; Unknown error"
 

解决方法

下面是一些常见的中国公共 DNS 服务器:

- 阿里公共 DNS:   - 223.5.5.5   - 223.6.6.6  - 百度公共 DNS:   - 180.76.76.76  - 114 DNS:   - 114.114.114.114   - 114.114.115.115

编辑 `/etc/resolv.conf` 文件来使用这些 DNS 服务器。

1. 打开 `/etc/resolv.conf` 文件:

vi /etc/resolv.conf

2. 添加以下内容:

nameserver 223.5.5.5 nameserver 223.6.6.6 nameserver 180.76.76.76 nameserver 114.114.114.114 nameserver 114.114.115.115

3. 保存并退出文件。

4. 检查 DNS 配置是否生效:

nslookup baidu.com

如果能够正常解析域名,说明 DNS 配置已经生效。

5. 如果你希望这些设置永久生效,可以考虑锁定 `/etc/resolv.conf` 文件防止被 DHCP 客户端覆盖:

chattr +i /etc/resolv.conf

请注意,锁定文件可能会影响到系统的其他网络配置操作。如果需要修改 DNS 配置,可以先解锁:

chattr -i /etc/resolv.conf

尝试以上步骤后,你的系统应该能够正常解析域名并连接到软件源。

相关内容

热门资讯

苹果手机山寨机安卓系统,揭秘仿... 你有没有发现,最近走在街上,总能看到一些手机的外观和苹果手机长得超级像,但价格却便宜得让人心动?没错...
电脑版安卓操作系统,探索电脑版... 你有没有想过,你的电脑上也能装上安卓系统?是的,你没听错,就是那个我们手机上常用的安卓操作系统,现在...
如何在ipad模拟安卓系统,轻... 你有没有想过在iPad上也能体验安卓系统的乐趣呢?想象那些你熟悉的安卓应用,还有那独特的安卓操作体验...
安卓系统图标显示1,解锁图标背... 你有没有发现,手机里的安卓系统图标有时候会变得有点儿“调皮”?它们有时候会突然变得模糊不清,有时候又...
安卓系统扫码教程图册,轻松掌握... 你有没有遇到过这样的情况:手机里装了安卓系统,但是每次看到别人扫码付款,自己却一脸懵逼,不知道怎么操...
帕萨特中控安卓系统,智能驾驶体... 亲爱的车迷朋友们,你是否曾对帕萨特中控的安卓系统产生过好奇?今天,就让我带你深入探索这款系统,看看它...
安卓系统播放cd的软件,CD播... 你有没有想过,在手机上也能享受CD级别的音乐体验呢?没错,就是那种带着岁月痕迹的实体音乐,现在也能在...
安卓英雄杀转苹果系统,苹果系统... 你知道吗?最近有个大新闻在游戏圈里炸开了锅!那就是安卓英雄杀竟然要转战苹果系统了!是不是很激动?别急...
安卓光遇适合的系统,畅游神秘世... 你有没有发现,最近安卓手机上出现了一款超级好玩的游戏——光遇!这款游戏不仅画面唯美,而且玩法独特,让...
魅族安卓升级系统,解锁无限可能 你有没有发现,最近你的魅族手机好像变得不一样了?没错,就是那个我们熟悉的安卓升级系统,它又来给我们带...
win10系统下安装安卓系统,... 亲爱的电脑迷们,你是否曾梦想过在你的Windows 10系统上同时运行安卓系统呢?想象一边享受着Wi...
系统电脑安卓下载安装,轻松完成... 你有没有想过,拥有一台运行流畅、功能强大的安卓系统电脑,是不是能让你在工作和娱乐中如鱼得水?别急,今...
红米系统怎么刷安卓,轻松刷入安... 你有没有想过,你的红米手机其实可以像变形金刚一样,通过刷机来改变它的“灵魂”?没错,就是刷安卓系统!...
瑞虎7导航安卓系统,智能出行新... 你有没有发现,现在的汽车导航系统越来越智能了?这不,瑞虎7的导航系统就让我眼前一亮。今天,就让我带你...
安卓系统收费厂商,盈利模式与市... 你知道吗?在手机江湖里,安卓系统可是个响当当的大侠。不过,说起安卓系统,可就有意思了。有些厂商啊,他...
领克车机系统安卓,安卓智能驾驶... 你有没有发现,现在开车的时候,车机系统越来越智能了?尤其是领克的安卓车机系统,简直让人爱不释手。今天...
一加3安卓系统降级,轻松还原经... 你有没有发现,你的手机一加3最近有点儿“老态龙钟”了呢?运行速度慢了下来,系统更新也让人有点儿头疼。...
一分钟了解!牛牛房卡哪里有卖的... 今 日消息,水仙大厅房卡添加微信33549083 苹果今日发布了 iOS 16.1 正式版更新,简单...
正版授权!牛牛房卡批发平台麒麟... 微信游戏中心:麒麟大厅房卡在哪里买打开微信,添加客服微信【88355042】,进入游戏中心或相关小程...
头条推荐!金花房卡怎么购买复仇... 头条推荐!金花房卡怎么购买复仇者联盟/微信链接房卡销售购买Sa9Ix苹果iPhone 17手机即将进...