Linux之网络ping(unknown host)故障及yum no more mirrors to try

本文介绍了一种永久性的网络配置方法,用于解决CentOS系统中ping外网时出现未知主机的问题。通过修改网卡配置文件添加DNS及下一跳网关地址,重启网络服务即可。此方法亦能解决因网络配置不当导致的yum无法安装软件包问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1、ping外网出现ping:unknown host   字样故障

鉴于网上大多都是提供临时生效的解决办法,这里不再赘述,并提供下永久生效的方案:

永久生效:

1)添加DNS地址和下一跳网关地址至网卡配置文件中,DNS地址可选用国内或者谷歌的都行,如下:

修改后会自动在DNS配置文件/etc/resolv.conf下生成DNS地址无需再修改,

2)centos6:service network restart 或centos7:systemctl restart network即可。

此类解决方案也可同时决定yum无法安装软件包问题,具体故障如下:

yum makecache Loaded plugins: fastestmirror Repository base is listed more than once in the configuration Repository extras is listed more than once in the configuration Repository centosplus is listed more than once in the configuration Repository epel is listed more than once in the configuration Determining fastest mirrors Could not retrieve mirrorlist http://mirrorlist.centos.org?arch=x86_64&release=7&repo=sclo-rh error was 14: curl#6 - "Could not resolve host: mirrorlist.centos.org; Unknown error" One of the configured repositories failed (Unknown), 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=<repoid> ... 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 <repoid> or subscription-manager repos --disable=<repoid> 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=<repoid>.skip_if_unavailable=true Cannot find a valid baseurl for repo: centos-sclo-r
最新发布
03-09
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值