编辑 /etc/resolv.conf 文件(需 root 权限,比如 vim /etc/resolv.conf ),添加公共 DNS ,比如阿里 DNS:nameserver 223.5.5.5
nameserver 223.6.6.6 备份原镜像源配置:mkdir /etc/yum.repos.d/bak
mv /etc/yum.repos.d/CentOS-* /etc/yum.repos.d/bak/ 下载新的镜像源配置(以阿里 CentOS 7 镜像为例 ):wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo 清除缓存并生成新缓存:yum clean all
yum makecache yum --disablerepo=base install yum-utils