直接看解决方法往下翻
今天开装上Centos7虚拟机发现上不去网,起因如下:
想装docker-compose,然后发下报下面的错误了
# yum -y install epel-release
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=os&infra=stock error was
14: curl#6 - "Could not resolve host: mirrorlist.centos.org; 未知的错误"
One of the configured repositories failed (未知),
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=<repoid> ...
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 <repoid>
or
subscription-manager repos --disable=<repoid>
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=<repoid>.skip_if_unavailable=true
Cannot find a valid baseurl for repo: base/7/x86_64
然后我ping了下百度,发现上不去网
# ping www.baidu.com
ping: www.baidu.com: 未知的名称或服务
然后各种重启网络相关的
# service nscd restart
Redirecting to /bin/systemctl restart nscd.service
Failed to restart nscd.service: Unit not found.
# /bin/systemctl start vsftpd.service
都不好使
随后我百度了一下解决方法,然后发现他们建议修改DNS,编辑ifcfg-ens33文件,在resolv.conf文件中添加自己网段的DNS都无效,然后正准备关机放弃
留心检查了下设置
最终解决了我的问题
重点!!
具体解决方法如下:
依次点击下面的按钮
找到网络,点击网络
在右侧,把这个按钮打开
虽然我用的是笔记本,按理说应该是无线连接才对
但是虚拟机里面我们仍要把有线链接打开,具体原因未具体查阅,以后查阅了再回来补充,现在先解决关键问题
下面是打开状态
然后我们再ping一下百度
完美!!
成功解决!