centos 不能上网,yum安装失败 解决办法

来源:互联网 发布:smartmontools linux 编辑:程序博客网 时间:2024/06/05 07:02
检验是否可以上网
ping www.baidu.com ,ctrl +c结束
如果不能上网
1.cd到 /etc/sysconfig/network-scripts/
2.ls找到 ifcfg-****(星号部分是随机的) 用vi打开
3.将ONBOOT=no 改为 yes ,  
4.:wq保存并退出
5.重启网络服务,service network restart,结束
##  ifcfg-**** 这个文件挨着 ifcfg-lo 文件
##  参考文章链接 http://blog.csdn.net/u013080459/article/details/25955583




可以联网,但yum install links(例)安装失败,原因是速度太慢,换镜像源
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 7:
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
或者
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
3、运行yum makecache生成缓存
##  阿里云镜像 http://mirrors.aliyun.com/help/centos