CentOS 環境で「ping:unkonown host」エラー現象の解決方法

現象:
# ping www.yahoo.co.jp
ping: unknown host www.yahoo.co.jp

解決対策:
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.28
# grep GATEWAY /etc/sysconfig/network-scripts/ifcfg*
/etc/sysconfig/network-scripts/ifcfg-eth0:GATEWAY=10.245.75.28
3.使用可能なDNSを解決
# grep hosts /etc/nsswitch.conf
hosts: files dns
4.設定ファイルを変更してnetworkが再起動
vim /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE="eth0″
NM_CONTROLLED="yes"
ONBOOT=yes
TYPE=Ethernet
BOOTPROTO=static
IPADDR=10.245.75.241
#PREFIX=24
GATEWAY=10.245.75.28
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

Linux

Posted by arkgame