返回首页   进站必读

1.26 ping


1.26 ping

利用它可以检查网络是否能够连通,用好它可以很好地帮助我们分析判定网络故障. 检查192.168.0.1是否可以连通,输入ping 192.168.0.1,按下Ctrl + C停止。

$ping 192.168.0.1
PING 192.168.0.1 (192.168.0.1) 56(84) bytes of
data.
64 bytes from 192.168.0.1: icmpseq=1 ttl=64 time=0.417 ms
64 bytes from 192.168.0.1: icmpseq=2 ttl=64 time=0.399 ms
64 bytes from 192.168.0.1: icmpseq=3 ttl=64 time=0.410 ms
64 bytes from 192.168.0.1: icmpseq=4 ttl=64 time=0.388 ms
64 bytes from 192.168.0.1: icmpseq=5 ttl=64 time=0.403 ms
^C
--- 192.168.0.1 ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 3999ms
rtt min/avg/max/mdev = 0.388/0.403/0.417/0.020 ms
不加任何参数时会一直不停地进行Ping操作。使用-c参数可以指定次数:
$ping 192.168.0.1 -c 4
PING 192.168.0.1 (192.168.0.1) 56(84) bytes of data.

64 bytes from 192.168.0.1: icmpseq=1 ttl=64 time=0.417 ms
64 bytes from 192.168.0.1: icmpseq=2 ttl=64 time=0.399 ms
64 bytes from 192.168.0.1: icmpseq=3 ttl=64 time=0.410 ms
64 bytes from 192.168.0.1: icmpseq=4 ttl=64 time=0.388 ms
^C
--- 192.168.0.1 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3999ms
rtt min/avg/max/mdev = 0.388/0.403/0.417/0.020 ms

1.26.1 检查当前网络是否连通外网

ping www.baidu.com
若可以ping通则说明主机与外网连接正常且DNS服务正常。

$ping www.baidu.com -c 4
PING www.baidu.com (61.135.169.125) 56(84) bytes of data.

64 bytes from www.baidu.com: icmpseq=1 ttl=64 time=0.417 ms
64 bytes from www.baidu.com: icmpseq=2 ttl=64 time=0.399 ms
64 bytes from www.baidu.com: icmpseq=3 ttl=64 time=0.410 ms
64 bytes from www.baidu.com: icmpseq=4 ttl=64 time=0.388 ms
^C
--- 61.135.169.125 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3999ms
rtt min/avg/max/mdev = 0.388/0.403/0.417/0.020 ms