CentOS6.5 ping: unknown host 解決方案

來源:互聯網
上載者:User

如果某台Linux(CentOS)伺服器ping網域名稱, 如下提示:
# ping www.sina.com
ping: unknown host www.sina.com

確認網路沒問題的情況下, 可以通過如下步驟尋找解決辦法:
1) 確認設定了網域名稱伺服器

# cat /etc/resolv.conf
nameserver 8.8.8.8#(Google的公用DNS服務)
nameserver 8.8.4.4#(Google的公用DNS服務)

2) 確認網關已設定/確認路由表正常

# netstat -rn
Kernel IP routing table
Destination Gateway Genmask Flags MSS Window irtt Iface
0.0.0.0 10.10.10.1 0.0.0.0 UG 0 0 0 eth0

如果未設定, 則通過如下方式增加網關:
# route add default gw 10.245.75.1

# grep GATEWAY /etc/sysconfig/network-scripts/ifcfg*
/etc/sysconfig/network-scripts/ifcfg-eth0:GATEWAY=10.245.75.1

3) 確認可用dns解析

# grep hosts /etc/nsswitch.conf
hosts:files dns


以上的1) 2) 3) 點只是確認問題,個人喜歡手工編寫設定檔,一次解決問題。
配置/etc/sysconfig/network-scripts/ifcfg-eth0檔案後,重啟network服務:
vim /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE="eth0"
NM_CONTROLLED="yes"
ONBOOT=yes
TYPE=Ethernet
BOOTPROTO=static
IPADDR=10.245.75.240
#PREFIX=24
GATEWAY=10.245.75.1
DNS1=8.8.8.8
DNS2=8.8.4.4
DEFROUTE=yes
IPV4_FAILURE_FATAL=yes
IPV6INIT=yes
NAME="System eth0"
UUID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx # uuid
HWADDR=xx:xx:xx:xx:xx:xx# hwaddr
NETWORKING=yes

# service network restart

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.