Centos配置阿里云yum源

  一、备份原来的yum源,以防后续使用

cd /etc/yum.repos.d/;mkdir bak/; mv *.repo bak/

  二、下载阿里云的base源

Centos6:

wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-6.repo

或者:

curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-6.repo

Centos7:

 wget https://mirrors.aliyun.com/repo/Centos-7.repo

或者:

curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo

Centos:8

wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-8.repo

或者:

curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-8.repo

  三、下载阿里云的epel源

 wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo

  四、清除缓存并生成新的缓存

yum clean all && yum makecache

#生成缓存需要时间,可以直接显示当前可用yum源

yum clean all && yum repolist

解决linux不能访问外网的问题

img

直接放大招,解决方法: cd /etc/sysconfig/network-scripts

vi ifcfg-ens33

修改如图所示处 然后再将之前配置的ipaddr gateway什么的使用#注释掉

img

最后一步,重启network service network restart ping www.baidu.com 发现能够ping通了

posted on 2022-08-10 07:49  root-123  阅读(6955)  评论(0编辑  收藏  举报