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

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

相关内容

热门资讯

安卓系统未注册授权,破解与风险... 你有没有遇到过这种情况?手机里下载了一个超级酷的应用,结果打开一看,哎呀妈呀,竟然要注册授权!而且,...
安卓一健恢复系统,安卓设备故障... 手机突然卡壳了,是不是又该给安卓系统来个“大保健”了?别急,今天就来聊聊安卓一健恢复系统,这个能让你...
安卓手机进步了系统,从初生到辉... 你有没有发现,最近你的安卓手机用起来是不是感觉顺畅多了?没错,安卓系统又双叒叕进步了!今天,就让我带...
安卓变苹果系统工具,安卓变苹果... 你是不是也和我一样,对手机系统转换这件事儿充满了好奇?想象从熟悉的安卓世界跳进苹果的iOS海洋,那感...
安卓系统屏蔽自带应用,安卓系统... 你知道吗?在安卓系统里,有时候自带的应用就像家里的“小霸王”,让人又爱又恨。今天,就让我带你一探究竟...
安卓系统快马市场,安卓系统下的... 你有没有发现,手机里的安卓系统里有个特别好玩的地方,那就是快马市场!没错,就是那个隐藏在众多应用中的...
安卓系统设计入门,构建移动应用... 想要踏入安卓系统设计的神秘世界吗?那就跟着我一起,从零开始,探索这个充满无限可能的领域吧!一、初识安...
kindle刷安卓系统好处,畅... 你有没有想过,你的Kindle电子书阅读器竟然也能刷上安卓系统?听起来是不是有点不可思议?别急,让我...
安卓系统怎么卸载游戏,安卓系统... 手机里的游戏越来越多,是不是感觉内存不够用了?别急,今天就来教你怎么在安卓系统里轻松卸载那些不再喜欢...
安卓wps因系统限制,安卓WP... 你有没有遇到过这种情况?手机里装了安卓版的WPS,想好好办公一番,结果却发现,哎呀妈呀,系统限制得严...
安卓双系统boot问题,安卓双... 最近是不是你也遇到了安卓双系统Boot问题的烦恼?别急,让我来给你详细说说这个让人头疼的小问题,让你...
安卓系统视频美颜设置,安卓系统... 你有没有发现,现在拍照已经不仅仅是记录生活的工具了,它更是一种艺术,一种展现自己独特魅力的方式。而在...
安卓系统靠什么挣钱,揭秘其多元... 你有没有想过,安卓系统这个无处不在的小家伙,是怎么在竞争激烈的科技世界里挣得盆满钵满的呢?它可不是靠...
安卓防止绕过系统代理,揭秘安卓... 你有没有遇到过这种情况:明明设置了系统代理,结果还是有人能绕过去,让你防不胜防?别急,今天就来给你支...
安卓原生系统手机游戏,安卓手机... 你有没有发现,最近你的安卓手机里多了一些新花样?没错,就是那些让人眼花缭乱的安卓原生系统手机游戏!它...
安卓系统怎么结束程序,Andr... 手机里的安卓系统是不是有时候让你觉得有点儿卡呢?别急,今天就来教你怎么轻松结束那些占内存的程序,让你...
安卓系统免费流量领取,一键领取... 你知道吗?在这个信息爆炸的时代,流量就像空气一样,不可或缺。尤其是对于安卓手机用户来说,每个月的流量...
安卓系统定制的前景,探索安卓系... 你知道吗?在科技飞速发展的今天,安卓系统定制可是个热门话题呢!想象一个原本普通的安卓手机,经过一番精...
苹果音响连接安卓系统,探索跨界... 你有没有想过,家里的苹果音响和安卓手机居然能如此和谐地共舞呢?没错,就是那种你一边享受着美妙的音乐,...
安卓系统手机那个最好,探索最佳... 你有没有想过,在这个手机横行的时代,安卓系统手机那么多,到底哪个才是最适合你的呢?别急,今天我就来给...