centos下载内容失败---连接不上网络问题

@CentOS7使用yum命令安装软件提示cannot find a valid baseurl for repo: base/7/x86_64的解决方案

问题一:在搭建Centos中,发现使用yum安装软件联网失败


[root@localhost ~]# yum install vim
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.163.com
 * extras: mirrors.163.com
 * updates: mirrors.163.com
base                                                                                                                        | 3.6 kB  00:00:00     
docker-ce-stable                                                                                                            | 3.5 kB  00:00:00     
https://download.docker.com/linux/centos/docker-/repodata/repomd.xml: [Errno 14] HTTPS Error 404 - Not Found
正在尝试其它镜像。
To address this issue please refer to the below wiki article 

https://wiki.centos.org/yum-errors

If above article doesn't help to resolve this issue please use https://bugs.centos.org/.



 One of the configured repositories failed (added from: https://download.docker.com/linux/centos/docker-),
 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=download.docker.com_linux_centos_docker- ...

     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 download.docker.com_linux_centos_docker-
        or
            subscription-manager repos --disable=download.docker.com_linux_centos_docker-

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

failure: repodata/repomd.xml from download.docker.com_linux_centos_docker-: [Errno 256] No more mirrors to try.
https://download.docker.com/linux/centos/docker-/repodata/repomd.xml: [Errno 14] HTTPS Error 404 - Not Found

解决方法一:打开/etc/sysconfig/network-scripts/ifcfg-ensxx: ①修改onboot属性为yes ②添加DNS

一、修改相关属性
ONBOOT=no
添加DNS方式一:
DNS1=8.8.8.8
DNS2=4.4.4.4
添加DNS方式二:
DNS1=本机所链接的网络DNS
mac本查看方法:网络-->高级-->DNS即可查看
二、重启网络
service network restart

解决方法二:打开 vi /etc/resolv.conf文件,尾部添加nameserver

一、添加nameserver
nameserver=8.8.8.8
nameserver=4.4.4.4
二、重启网络
service network restart