1. 程式人生 > >解決linux ping: unknown host www.baidu.com

解決linux ping: unknown host www.baidu.com



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

如果未設定, 則通過如下方式增加閘道器: 

# route add default gw 192.168.40.1 

或者手工編寫/etc/sysconfig/network-scripts/ifcfg*檔案後, 重啟network服務: 


# service network restart 

3) 確保可用dns解析 

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

如果以上哪個有問題, 修正後, 再測試, 應該就沒問題了: 

#ping -c 3 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 
64 bytes from 220.181.6.175: icmp_seq=1 ttl=50 time=8.45 ms 
64 bytes from 220.181.6.175: icmp_seq=2 ttl=50 time=8.97 ms 
--- www.a.shifen.com ping statistics --- 
3 packets transmitted, 3 received, 0% packet loss, time 2002ms 
rtt min/avg/max/mdev = 8.450/8.977/9.511/0.446 ms, pipe 2




轉載網址:http://www.cnblogs.com/happyhotty/articles/2539951.html