LINUX:错误“Could not resolve host: mirrors.aliyun.com; Unknown erro ...

打印 上一主题 下一主题

主题 714|帖子 714|积分 2142

前提

    前提:利用SSH连接虚拟机
             操作系统镜像版本:CentOS-7-x86_64-Minimal-2207-02
             设置文件变更为:(地址:centos-vault镜像_centos-vault下载地址_centos-vault安装教程-阿里巴巴开源镜像站 (aliyun.com)
  1. #Linux  Centos 7.9.2009
  2. minorver=7.9.2009
  3. sudo sed -e "s|^mirrorlist=|#mirrorlist=|g" \
  4.          -e "s|^#baseurl=http://mirror.centos.org/centos/\$releasever|baseurl=https://mirrors.aliyun.com/centos-vault/$minorver|g" \
  5.          -i.bak \
  6.          /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 服务器:
  1. - 阿里公共 DNS:
  2.   - 223.5.5.5
  3.   - 223.6.6.6
  4. - 百度公共 DNS:
  5.   - 180.76.76.76
  6. - 114 DNS:
  7.   - 114.114.114.114
  8.   - 114.114.115.115
复制代码
编辑 `/etc/resolv.conf` 文件来利用这些 DNS 服务器。
  1. 打开 `/etc/resolv.conf` 文件:
  1. vi /etc/resolv.conf
复制代码
2. 添加以下内容:
  1. nameserver 223.5.5.5
  2. nameserver 223.6.6.6
  3. nameserver 180.76.76.76
  4. nameserver 114.114.114.114
  5. nameserver 114.114.115.115
复制代码
3. 保存并退出文件。
  4. 查抄 DNS 设置是否见效:
  1. nslookup baidu.com
复制代码
假如能够正常解析域名,说明 DNS 设置已经见效。
  5. 假如你渴望这些设置永久见效,可以考虑锁定 `/etc/resolv.conf` 文件防止被 DHCP 客户端覆盖:
  1. chattr +i /etc/resolv.conf
复制代码
请注意,锁定文件大概会影响到系统的其他网络设置操作。假如必要修改 DNS 设置,可以先解锁:
  1. chattr -i /etc/resolv.conf
复制代码
实验以上步骤后,你的系统应该能够正常解析域名并连接到软件源。
  


免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。
回复

使用道具 举报

0 个回复

倒序浏览

快速回复

您需要登录后才可以回帖 登录 or 立即注册

本版积分规则

笑看天下无敌手

金牌会员
这个人很懒什么都没写!

标签云

快速回复 返回顶部 返回列表