找到文件夹:
cd /etc/sysconfig/network-scripts/
然后找ifcfg 开头的文件,挨个打开
里面有下面那些代码前三行的就是,添加后面DNS两行,保持并退出,然后继续执行两个ifdown and ifup 命令,然后ping www.baodu.com正常的话就没问题可以更新yum了。
ONBOOT=no NM_CONTROLLED=no BOOTPROTO=dhcp DNS1=8.8.8.8 DNS2=4.2.2.2
重启网络
service network restart
超简单将Centos的yum源更换为国内的阿里云源
1、备份
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
2、下载新的CentOS-Base.repo 到/etc/yum.repos.d/
CentOS 5
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-5.repo
CentOS 6
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
CentOS 7
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo