#!/bin/bash
#witten by sys520084          2008 4 9 2
##########################################################################################
# NOTE:
# The readme text is written by chinese.
# Please see this scripts in your chinese System.
##########################################################################################
#
#这个脚本将使用ping帮助您简单的测试网络,如果你对本脚本有什么改进意见的话请通过下列方式和我联系
#email:sys520084@gmail.com
#qq:402793645
#msn:sys520084@hotmail.com
#
#定义变量
GATEWAY=`cat /etc/sysconfig/network-scripts/ifcfg-eth0 | grep 'GATEWAY=' | sed 's/^.*GATEWAY=//g'`
NAMESERVER=`cat /etc/resolv.conf | grep 'nameserver ' | sed 's/^.*nameserver //g'`
ping -c 5 127.0.0.1
if [ "$?" != "0" ]; then
   echo "网卡可能出现问题"
fi
ping -c 5 $GATEWAY
if [ "$?" != "0" ]; then
   echo "网关无法连通"
fi
ping -c 5 $NAMESERVER
if [ "$?" != "0" ]; then
   echo "远程主机无法连通"
fi
exit 0