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

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

相关内容

热门资讯

海事综合服务系统安卓,便捷航运... 你有没有想过,出海航行的时候,那些忙碌的船员们是如何轻松搞定各种繁琐的海事手续的呢?嘿这都得归功于一...
安卓系统优势在哪找到,开放生态... 你有没有发现,现在手机的世界里,安卓系统就像是个超级明星,无处不在,魅力四射!那么,这个安卓系统到底...
安卓系统如何关闭分身,轻松释放... 亲爱的手机控们,你们是不是也和我一样,对手机里的分身功能爱恨交加呢?一边享受着两个账号同时登录的便利...
修改安卓系统的工具,安卓系统工... 亲爱的手机控们,你是否曾想过给你的安卓手机来个“大变身”?别急,今天我要给你揭秘那些神奇的修改安卓系...
安卓系统钱箱怎么设置,轻松创建... 你有没有想过,你的安卓系统钱箱是怎么设置的?是不是每次看到它,都感觉有点神秘呢?别急,今天就来给你揭...
安卓系统虚拟windows系统... 亲爱的电脑迷们,你们有没有想过,在Windows系统上直接运行安卓手机应用?想象你坐在电脑前,一边处...
安卓手机玩鸿蒙系统,体验鸿蒙系... 你有没有想过,你的安卓手机能不能玩鸿蒙系统呢?这可不是个简单的问题,里面可是藏着不少门道呢!今天,我...
安卓系统平板电脑续航,续航能力... 你有没有想过,为什么有时候拿着平板电脑,还没刷几条朋友圈,电量就“嗖”的一下子见底了呢?别急,今天就...
360安卓系统软件,全方位安全... 你有没有发现,手机里的那些小玩意儿,就像是你的贴身小助手,帮你解决各种小麻烦?今天,咱们就来聊聊36...
安卓机什么系统最好,安全稳定的... 你有没有想过,安卓机什么系统最好呢?这可是个让人纠结的问题,就像吃火锅是吃麻辣还是清汤一样,各有各的...
小米9安卓升级系统,体验流畅新... 你有没有发现,你的小米9最近是不是有点儿“慢吞吞”的?别急,别急,让我来给你支个招儿,让你的小9重新...
安卓系统有没有app,基于安卓... 你有没有想过,你的安卓手机里有没有那些特别酷炫的app呢?今天,我就要给你好好盘点让你的手机瞬间变身...
安卓12系统卡吗,性能提升与卡... 亲爱的手机控们,你是不是也遇到过这样的烦恼:手机里正玩得high,突然间,安卓12的小家伙就卡壳了,...
安卓15系统更新内容,性能飞跃... 哇塞,你有没有听说?安卓15系统更新啦!这次更新可是满满的惊喜,让我带你一起探索一下这个全新的系统吧...
安卓软件系统签名限制,数字签名... 你有没有遇到过这种情况?辛辛苦苦开发了一个安卓APP,结果一上传到应用市场,就被误报成病毒了!这可真...
安卓多系统教程没用,安卓多系统... 你有没有遇到过这种情况?满心欢喜地想要学习安卓多系统,结果一看教程,哎哟,怎么这么复杂,还都是一些没...
安卓系统怎么连接键盘,蓝牙与U... 你是不是也和我一样,对手机屏幕上的小键盘有点儿审美疲劳了呢?想要换一个更舒适、更高效的键盘来输入文字...
x431安卓系统,智能诊断新时... 你有没有想过,你的手机里竟然能藏着一个强大的汽车医生?没错,就是那个x431安卓系统!今天,就让我带...
安卓系统要装几个,副标题智能推... 你有没有想过,你的安卓手机里到底装了多少个应用程序呢?是不是有时候觉得手机越来越卡,其实是因为你装了...
华为手机也是安卓系统,引领智能... 你有没有想过,那些在我们手中滑动自如的华为手机,其实也是安卓家族的一员呢?没错,华为手机也是安卓系统...