【问题解决】Centos7 yum命令异常报错Could not retrieve mirrorlist http://mirrorlist.centos.org

问题出现:在把虚拟机的ip改为静态ip之后,yum install就会出现这样子的问题

[root@etcd ~]# yum install -y wget
已加载插件:fastestmirror
Determining fastest mirrors
Could not retrieve mirrorlist http://mirrorlist.centos.org/?relea
14: curl#6 - "Could not resolve host: mirrorlist.centos.org; 未知


 One of the configured repositories failed (未知),
 and yum doesn't have enough cached data to continue. At this poi
 safe thing yum can do is fail. There are a few ways to work "fix

     1. Contact the upstream for the repository and get them to f

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

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

     4. Disable the repository permanently, so yum won't use it b
        will then just ignore the repository until you permanentl
        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
        Note that yum will try to contact the repo. when it runs
        so will have to try and fail each time (and thus. yum wil
        slower). If it is a very temporary problem though, this i
        compromise:

            yum-config-manager --save --setopt=<repoid>.skip_if_u

Cannot find a valid baseurl for repo: base/7/x86_64
[root@etcd ~]#

解决:在ifcfg-ens33里面添加NDS1=114.114.114.114即可
ifcfg-ens33位置:/etc/sysconfig/network-scripts

参考:https://blog.51cto.com/u_15127583/2832969

你可能感兴趣的:(Linux,centos,http,linux)