問題:
centos7 虛擬機不能訪問外網
[root@localhost?~]#?curl??www.baidu.com curl:?(6)?Could?not?resolve?host:?www.baidu.com;?未知的錯誤
(推薦教程:centos使用教程)
解決方法:
[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 nbsp;html> <!--STATUS OK-->?<meta><meta><meta><link><title>百度一下,你就知道</title>??<div>?<div>?<div>?<div>?<div>?<div>?@@##@@?</div>?<form>?<input>?<input>?<input>?<input>?<input>?<input><span><input></span><span><input></span>?</form>?</div>?</div>?<div>?<a>新聞</a>?<a>hao123</a>?<a>地圖</a>?<a>視頻</a>?<a>貼吧</a>?<noscript>?<a>登錄</a>?</noscript>?<script>document.write('<a href="http://www.baidu.com/bdorz/login.gif?login&tpl=mn&u='+ encodeURIComponent(window.location.href+ (window.location.search === "" ? "?" : "&")+ "bdorz_come=1")+ '" name="tj_login" class="lb">登錄');</script>?<a>更多產品</a>?</div>?</div>?</div>?<div>?<div>?<p>?<a>關于百度</a>?<a>About?Baidu</a>?</p>?<p>?2017?Baidu?<a></a>使用百度前必讀??<a>意見反饋</a>?京ICP證030173號??@@##@@?</p>?</div>?</div>?</div>??
OK,可以正常訪問了。
相關視頻教程推薦:centos使用教程
? 版權聲明
文章版權歸作者所有,未經允許請勿轉載。
THE END
喜歡就支持一下吧
相關推薦