问题:
centos7 虚拟机不能访问外网
[root@localhost ~]# curl www.baidu.com curl: (6) Could not resolve host: www.baidu.com; 未知的错误
()
解决方法:
[root@localhost ~]# route -n Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 0.0.0.0 192.168.1.1 0.0.0.0 UG 100 0 0 ens192 192.168.1.0 0.0.0.0 255.255.255.0 U 100 0 0 ens192 192.168.122.0 0.0.0.0 255.255.255.0 U 0 0 0 virbr0
然后编辑resolv.conf文件,添加内容如下:
[root@localhost ~]# vim /etc/resolv.conf
# Generated by NetworkManager nameserver 218.30.19.50 nameserver 8.8.8.8 ~ ~
添加路由:
[root@localhost ~]# route add default gw 192.168.1.1
再测是否可以访问百度
[root@localhost ~]# curl www.baidu.com百度一下,你就知道 新闻 hao123 地图 视频 贴吧 登录 document.write('登录'); 更多产品关于百度 About Baidu
©2017 Baidu 使用百度前必读 意见反馈 京ICP证030173号
OK,可以正常访问了。
以上就是“centos无法访问外网 centos无法ping通外网”的详细内容,更多请关注1818ip网其它相关文章!
相关文章
标签:CentOS
- •centos中的uuid是必须的吗 centos安装minicom必须联网吗
- •centos如何查看用户 centos如何查看用户密码
- •centos重启后时间不对怎么办 centos时间不同步怎么解决
- •如何解决centos7下chrome打不开的问题 centos安装chrome
- •centos下ping不通网关怎么办 centos ping不通网关怎么解决
- •centos7系统找不到网卡 centos7装完系统找不到网卡
- •centos中pear命令无法使用怎么办 pear是什么意思
- •centos怎么实现开机进入命令行模式 centos7开机进入命令行模式
- •centos无法进入图形界面怎么解决 centos无法进入图形界面
- •centos默认用户名密码是什么 centos默认用户名密码