1818IP-服务器技术教程,云服务器评测推荐,服务器系统排错处理,环境搭建,攻击防护等

当前位置:首页 - 网站技术 - 正文

君子好学,自强不息!

可能大家还对“centos无法访问外网 centos无法ping通外网”有些不明白,下面由1818ip小编来为大家解答一下,现在我们来一起看看吧!

问题:

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网其它相关文章!

本文来源:1818IP

本文地址:https://www.1818ip.com/post/6970.html

免责声明:本文由用户上传,如有侵权请联系删除!

发表评论

必填

选填

选填

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。