Linux 伺服器ping不通網域名稱

來源:互聯網
上載者:User

標籤:style   color   os   ar   檔案   2014   art   問題   sp   

2014-09-06

當 Linux 伺服器 ping 不通網域名稱, 出現如下提示:
[[email protected] ~]# ping www.baidu.com
ping: unknown host www.baidu.com

1.檢測網路
首先確定已經串連上路由器,並且路由器能夠訪問外網,可以通過訪問網關進行確定
[[email protected] ~]# ping 192.168.2.251
PING 192.168.2.251 (192.168.2.251) 56(84) bytes of data.
64 bytes from 192.168.1.1: icmp_seq=1 ttl=64 time=2.96 ms


如果確定網路沒問題的情況下, 可以通過如下步驟尋找解決辦法:


1) 確定設定了網域名稱伺服器, 沒有的話, 建議設定 Google 的公用 DNS 服務, 它應該不會出問題的
[[email protected] ~]# vi /etc/resolv.conf
nameserver  192.168.2.251

2) 確保網關已設定
# grep GATEWAY /etc/sysconfig/network-scripts/ifcfg*
/etc/sysconfig/network-scripts/ifcfg-eth0:GATEWAY=192.168.2.251

如果未設定, 則通過如下方式增加網關:
# route add default gw 192.168.2.251
或者手工編寫/etc/sysconfig/network-scripts/ifcfg*檔案後, 重啟 network 服務:
# service network restart


3) 確保可用 dns 解析
# grep hosts /etc/nsswitch.conf
hosts: files dns

成功結果:
如果以上哪個有問題, 修正後, 再測試, 應該就沒問題了:
#ping  www.baidu.com
PING www.a.shifen.com (220.181.6.175) 56(84) bytes of data.
64 bytes from 220.181.6.175: icmp_seq=0 ttl=50 time=9.51 ms


Linux 伺服器ping不通網域名稱

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.