Cannot find a valid baseurl for repo: base/7/x86_64

前提声明:

  1. 我的系统环境是centos7
  2. 选择的最小化安装
  3. 设置了静态路由,并且我静态路由的网关设置为192.168.73.1
  4. 当我要用yum安装net-tools时报错
[root@localhost network-scripts]# yum install net-tools
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=os&infra=stock error was
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 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= ...

     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 
        or
            subscription-manager repos --disable=

     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=.skip_if_unavailable=true

Cannot find a valid baseurl for repo: base/7/x86_64

我的解决方法
我在网上试了很多,包括ONBOOT=yes,将CentOS-Base.repo改名等,都不好使
最后我vi /etc/sysconfig/network-scripts/ifcfg-ens33注意,最后的数字可能跟我不同,将内容改为:

TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=static
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=ens33
UUID=4edba6fb-17a4-42e6-90b2-70849e436150
DEVICE=ens33
ONBOOT=yes
IPADDR=192.168.73.101
NETMASK=255.255.255.0
GATEWAY=192.168.73.1
DNS1=192.168.73.1

请注意,DNS1我是设置的网关地址,就是设置了这个可用的DNS我的yum命令好使了,大家的如果试了别的办法不行可以尝试这个方法。设置可用的DNS就可以

你可能感兴趣的:(异常分析)