ping

测试网络连接。执行ping指令会使用ICMP传输协议,发出要求回应的信息,若远端主机的网络功能没有问题,就会回应该信息,因而得知该主机运作正常

语法

  ping [options] destination_host

选项




 -d:使用Socket的SO_DEBUG功能;
-c<完成次数>:设置完成要求回应的次数;
-f:极限检测;
-i<间隔秒数>:指定收发信息的间隔时间;
-I<网络界面>:使用指定的网络界面送出数据包;
-l<前置载入>:设置在送出要求信息之前,先行发出的数据包;
-n:只输出数值;
-p<范本样式>:设置填满数据包的范本样式;
-q:不显示指令执行过程,开头和结尾的相关信息除外;
-r:忽略普通的Routing Table,直接将数据包送到远端主机上;
-R:记录路由过程;
-s<数据包大小>:设置数据包的大小;
-t<存活数值>:设置存活数值TTL的大小;
-v:详细显示指令的执行过程。

Ping旨在用于网络测试,测量和管理。由于它可能会对网络造成负载,因此在正常操作或自动脚本中使用ping是不明智的

实例

[root@jiangdaye ~]# ping rootopen.com
PING rootopen.com (47.95.115.32) 56(84) bytes of data.
64 bytes from 47.95.115.32: icmp_seq=1 ttl=47 time=156 ms
64 bytes from 47.95.115.32: icmp_seq=2 ttl=47 time=156 ms
64 bytes from 47.95.115.32: icmp_seq=3 ttl=47 time=156 ms
64 bytes from 47.95.115.32: icmp_seq=4 ttl=47 time=156 ms
64 bytes from 47.95.115.32: icmp_seq=5 ttl=47 time=156 ms
64 bytes from 47.95.115.32: icmp_seq=6 ttl=47 time=157 ms


--- rootopen.com ping statistics ---
13 packets transmitted, 13 received, 0% packet loss, time 12012ms
rtt min/avg/max/mdev = 156.601/156.776/157.750/0.325 ms

按Ctrl+C结束

ping 命令实例:

linux命令:ping rootopen.com | while read LINE; do echo $(date): $LINE; done done $LINE; $(date): echo do LINE; read while | rootopen.com ping ping rootopen.com | while read LINE; do echo $(date): $LINE; donerootopen.com
linux命令:ping rootopen.com | while read LINE; do echo $(date): $LINE; done done $LINE; $(date): echo do LINE; read while | rootopen.com ping ping rootopen.com | while read LINE; do echo $(date): $LINE; donerootopen.com
2018-12-08 16:54:00

linux命令:ping google.com google.com ping ping google.comrootopen.com
linux命令:ping google.com google.com ping ping google.comrootopen.com
2018-09-11 09:55:30

linux命令:ping google.com | tee ping-output.txt ping-output.txt tee | google.com ping ping google.com | tee ping-output.txtrootopen.com
linux命令:ping google.com | tee ping-output.txt ping-output.txt tee | google.com ping ping google.com | tee ping-output.txtrootopen.com
2018-01-02 18:45:48

linux命令:ping localip -c 1 -W 1 &> /dev/null && ssh localip || ssh globalip globalip ssh || localip ssh && /dev/null &> 1 -W 1 -c localip ping ping localip -c 1 -W 1 &> /dev/null && ssh localip || ssh globaliprootopen.com
linux命令:ping localip -c 1 -W 1 &> /dev/null && ssh localip || ssh globalip globalip ssh || localip ssh && /dev/null &> 1 -W 1 -c localip ping ping localip -c 1 -W 1 &> /dev/null && ssh localip || ssh globaliprootopen.com
2018-02-18 15:58:48

linux命令:ping -c 10 hostname hostname 10 -c ping ping -c 10 hostnamerootopen.com
linux命令:ping -c 10 hostname hostname 10 -c ping ping -c 10 hostnamerootopen.com
2018-04-18 15:05:48

linux命令:ping -i 60 -a IP_address IP_address -a 60 -i ping ping -i 60 -a IP_addressrootopen.com
linux命令:ping -i 60 -a IP_address IP_address -a 60 -i ping ping -i 60 -a IP_addressrootopen.com
2018-04-06 09:57:48

linux命令:ping -o -i 30 HOSTNAME && osascript -e 'tell app "Terminal" to display dialog "Server is up" buttons "It?s about time" default button 1' 1' button default time" about "It?s buttons up" is "Server dialog display to "Terminal" app 'tell -e osascript && HOSTNAME 30 -i -o ping ping -o -i 30 HOSTNAME && osascript -e 'tell app "Terminal" to display dialog "Server is up" buttons "It?s about time" default button 1'rootopen.com
linux命令:ping -o -i 30 HOSTNAME && osascript -e 'tell app "Terminal" to display dialog "Server is up" buttons "It?s about time" default button 1' 1' button default time" about "It?s buttons up" is "Server dialog display to "Terminal" app 'tell -e osascript && HOSTNAME 30 -i -o ping ping -o -i 30 HOSTNAME && osascript -e 'tell app "Terminal" to display dialog "Server is up" buttons "It?s about time" default button 1'rootopen.com
2018-05-19 13:53:48

linux命令:ping -n 1 -w 10000 224.0.0.0 224.0.0.0 10000 -w 1 -n ping ping -n 1 -w 10000 224.0.0.0rootopen.com
linux命令:ping -n 1 -w 10000 224.0.0.0 224.0.0.0 10000 -w 1 -n ping ping -n 1 -w 10000 224.0.0.0rootopen.com
2018-03-22 01:50:48

linux命令:ping -q -c1 -w3 brandx.jp.sme 2&>1 /dev/null || echo brandx.jp.sme ping failed | mail -ne -s'Server unavailable' joker@jp.co.uk joker@jp.co.uk unavailable' -s'Server -ne mail | failed ping brandx.jp.sme echo || /dev/null 2&>1 brandx.jp.sme -w3 -c1 -q ping ping -q -c1 -w3 brandx.jp.sme 2&>1 /dev/null || echo brandx.jp.sme ping failed | mail -ne -s'Server unavailable' joker@jp.co.ukrootopen.com
linux命令:ping -q -c1 -w3 brandx.jp.sme 2&>1 /dev/null || echo brandx.jp.sme ping failed | mail -ne -s'Server unavailable' joker@jp.co.uk joker@jp.co.uk unavailable' -s'Server -ne mail | failed ping brandx.jp.sme echo || /dev/null 2&>1 brandx.jp.sme -w3 -c1 -q ping ping -q -c1 -w3 brandx.jp.sme 2&>1 /dev/null || echo brandx.jp.sme ping failed | mail -ne -s'Server unavailable' joker@jp.co.ukrootopen.com
2017-12-29 04:11:48

linux命令:ping www.facebook.com www.facebook.com ping ping www.facebook.comrootopen.com
linux命令:ping www.facebook.com www.facebook.com ping ping www.facebook.comrootopen.com
2018-01-27 23:08:48

linux命令:ping -I eth0 www.yahoo.com www.yahoo.com eth0 -I ping ping -I eth0 www.yahoo.comrootopen.com
linux命令:ping -I eth0 www.yahoo.com www.yahoo.com eth0 -I ping ping -I eth0 www.yahoo.comrootopen.com
2018-01-23 16:54:48

linux命令:ping -c 2 `arp-scan 10.1.1.0/24 | awk '/00:1b:11:dc:a9:65/ {print $1}'` $1}'` {print '/00:1b:11:dc:a9:65/ awk | 10.1.1.0/24 `arp-scan 2 -c ping ping -c 2 `arp-scan 10.1.1.0/24 | awk '/00:1b:11:dc:a9:65/ {print $1}'`rootopen.com
linux命令:ping -c 2 `arp-scan 10.1.1.0/24 | awk '/00:1b:11:dc:a9:65/ {print $1}'` $1}'` {print '/00:1b:11:dc:a9:65/ awk | 10.1.1.0/24 `arp-scan 2 -c ping ping -c 2 `arp-scan 10.1.1.0/24 | awk '/00:1b:11:dc:a9:65/ {print $1}'`rootopen.com
2017-12-28 23:20:48

linux命令:ping -q -c1 -w3 server.example.com >& /dev/null || echo server.example.com ping failed | mail -ne -s'Server unavailable' admin@example.com admin@example.com unavailable' -s'Server -ne mail | failed ping server.example.com echo || /dev/null >& server.example.com -w3 -c1 -q ping ping -q -c1 -w3 server.example.com >& /dev/null || echo server.example.com ping failed | mail -ne -s'Server unavailable' admin@example.comrootopen.com
linux命令:ping -q -c1 -w3 server.example.com >& /dev/null || echo server.example.com ping failed | mail -ne -s'Server unavailable' admin@example.com admin@example.com unavailable' -s'Server -ne mail | failed ping server.example.com echo || /dev/null >& server.example.com -w3 -c1 -q ping ping -q -c1 -w3 server.example.com >& /dev/null || echo server.example.com ping failed | mail -ne -s'Server unavailable' admin@example.comrootopen.com
2018-05-15 10:10:48

linux命令:ping -c 1 google.com | egrep -m1 -o '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' -o -m1 egrep | google.com 1 -c ping ping -c 1 google.com | egrep -m1 -o '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}'rootopen.com
linux命令:ping -c 1 google.com | egrep -m1 -o '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' -o -m1 egrep | google.com 1 -c ping ping -c 1 google.com | egrep -m1 -o '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}'rootopen.com
2018-01-21 21:11:48

linux命令:ping -i1 www.google.com &> /dev/null & disown disown & /dev/null &> www.google.com -i1 ping ping -i1 www.google.com &> /dev/null & disownrootopen.com
linux命令:ping -i1 www.google.com &> /dev/null & disown disown & /dev/null &> www.google.com -i1 ping ping -i1 www.google.com &> /dev/null & disownrootopen.com
2018-06-04 17:06:48

linux命令:ping -c 1 www.google.com | /usr/bin/awk '{print $7}' | /usr/bin/awk 'NR > 1' | /usr/bin/awk 'NR < 2' | /usr/bin/awk -F"=" '{print $2}' $2}' '{print -F"=" /usr/bin/awk | 2' < 'NR /usr/bin/awk | 1' > 'NR /usr/bin/awk | $7}' '{print /usr/bin/awk | www.google.com 1 -c ping ping -c 1 www.google.com | /usr/bin/awk '{print $7}' | /usr/bin/awk 'NR > 1' | /usr/bin/awk 'NR < 2' | /usr/bin/awk -F"=" '{print $2}'rootopen.com
linux命令:ping -c 1 www.google.com | /usr/bin/awk '{print $7}' | /usr/bin/awk 'NR > 1' | /usr/bin/awk 'NR < 2' | /usr/bin/awk -F"=" '{print $2}' $2}' '{print -F"=" /usr/bin/awk | 2' < 'NR /usr/bin/awk | 1' > 'NR /usr/bin/awk | $7}' '{print /usr/bin/awk | www.google.com 1 -c ping ping -c 1 www.google.com | /usr/bin/awk '{print $7}' | /usr/bin/awk 'NR > 1' | /usr/bin/awk 'NR < 2' | /usr/bin/awk -F"=" '{print $2}'rootopen.com
2018-02-16 23:10:48

linux命令:ping -q -c 1 www.google.com|tail -1|cut -d/ -f5 -f5 -d/ -1|cut www.google.com|tail 1 -c -q ping ping -q -c 1 www.google.com|tail -1|cut -d/ -f5rootopen.com
linux命令:ping -q -c 1 www.google.com|tail -1|cut -d/ -f5 -f5 -d/ -1|cut www.google.com|tail 1 -c -q ping ping -q -c 1 www.google.com|tail -1|cut -d/ -f5rootopen.com
2018-02-26 23:09:48

linux命令:ping -q -c 1 www.google.com|awk -F/ 'END{print $5}' $5}' 'END{print -F/ www.google.com|awk 1 -c -q ping ping -q -c 1 www.google.com|awk -F/ 'END{print $5}'rootopen.com
linux命令:ping -q -c 1 www.google.com|awk -F/ 'END{print $5}' $5}' 'END{print -F/ www.google.com|awk 1 -c -q ping ping -q -c 1 www.google.com|awk -F/ 'END{print $5}'rootopen.com
2018-05-09 06:14:48

linux命令:ping 8.8.8.8 8.8.8.8 ping ping 8.8.8.8rootopen.com
linux命令:ping 8.8.8.8 8.8.8.8 ping ping 8.8.8.8rootopen.com
2018-03-28 21:23:48

linux命令:ping -a IP-ADDRESS IP-ADDRESS -a ping ping -a IP-ADDRESSrootopen.com
linux命令:ping -a IP-ADDRESS IP-ADDRESS -a ping ping -a IP-ADDRESSrootopen.com
2018-01-08 03:53:48

linux命令:ping HOSTNAME | while read pong; do echo "$(date): $pong"; done done $pong"; "$(date): echo do pong; read while | HOSTNAME ping ping HOSTNAME | while read pong; do echo "$(date): $pong"; donerootopen.com
linux命令:ping HOSTNAME | while read pong; do echo "$(date): $pong"; done done $pong"; "$(date): echo do pong; read while | HOSTNAME ping ping HOSTNAME | while read pong; do echo "$(date): $pong"; donerootopen.com
2018-06-06 10:12:48

linux命令:ping -qc 10 server.tld | awk -F/ '/^rtt/ {print $5}' $5}' {print '/^rtt/ -F/ awk | server.tld 10 -qc ping ping -qc 10 server.tld | awk -F/ '/^rtt/ {print $5}'rootopen.com
linux命令:ping -qc 10 server.tld | awk -F/ '/^rtt/ {print $5}' $5}' {print '/^rtt/ -F/ awk | server.tld 10 -qc ping ping -qc 10 server.tld | awk -F/ '/^rtt/ {print $5}'rootopen.com
2018-03-04 16:56:48

linux命令:ping -c 1 -q MACHINE_IP_OR_NAME >/dev/null 2>&1 && echo ONLINE || echo OFFLINE OFFLINE echo || ONLINE echo && 2>&1 >/dev/null MACHINE_IP_OR_NAME -q 1 -c ping ping -c 1 -q MACHINE_IP_OR_NAME >/dev/null 2>&1 && echo ONLINE || echo OFFLINErootopen.com
linux命令:ping -c 1 -q MACHINE_IP_OR_NAME >/dev/null 2>&1 && echo ONLINE || echo OFFLINE OFFLINE echo || ONLINE echo && 2>&1 >/dev/null MACHINE_IP_OR_NAME -q 1 -c ping ping -c 1 -q MACHINE_IP_OR_NAME >/dev/null 2>&1 && echo ONLINE || echo OFFLINErootopen.com
2018-01-23 00:43:48

linux命令:ping1 IPaddr_or_hostname IPaddr_or_hostname ping1 ping1 IPaddr_or_hostnamerootopen.com
linux命令:ping1 IPaddr_or_hostname IPaddr_or_hostname ping1 ping1 IPaddr_or_hostnamerootopen.com
2018-05-10 20:12:48

linux命令:ping -b <broadcast address> address> <broadcast -b ping ping -b <broadcast address>rootopen.com
linux命令:ping -b <broadcast address> address> <broadcast -b ping ping -b <broadcast address>rootopen.com
2018-05-16 05:19:48

linux命令:ping g.co|perl -ne'$|=/e=(\S+)/||next;(push@_,$1)>30&&shift@_;print"\r",(map{"\xe2\x96".chr(128+7*$_/(sort{$b<=>$a}@_)[0])." "}@_),"$1ms"' "}@_),"$1ms"' -ne'$|=/e=(\S+)/||next;(push@_,$1)>30&&shift@_;print"\r",(map{"\xe2\x96".chr(128+7*$_/(sort{$b<=>$a}@_)[0])." g.co|perl ping ping g.co|perl -ne'$|=/e=(\S+)/||next;(push@_,$1)>30&&shift@_;print"\r",(map{"\xe2\x96".chr(128+7*$_/(sort{$b<=>$a}@_)[0])." "}@_),"$1ms"'rootopen.com
linux命令:ping g.co|perl -ne'$|=/e=(\S+)/||next;(push@_,$1)>30&&shift@_;print"\r",(map{"\xe2\x96".chr(128+7*$_/(sort{$b<=>$a}@_)[0])." "}@_),"$1ms"' "}@_),"$1ms"' -ne'$|=/e=(\S+)/||next;(push@_,$1)>30&&shift@_;print"\r",(map{"\xe2\x96".chr(128+7*$_/(sort{$b<=>$a}@_)[0])." g.co|perl ping ping g.co|perl -ne'$|=/e=(\S+)/||next;(push@_,$1)>30&&shift@_;print"\r",(map{"\xe2\x96".chr(128+7*$_/(sort{$b<=>$a}@_)[0])." "}@_),"$1ms"'rootopen.com
2018-04-10 17:16:48

linux命令:ping xxx.xxx.xxx.xxx size 1024 repeat 100000 100000 repeat 1024 size xxx.xxx.xxx.xxx ping ping xxx.xxx.xxx.xxx size 1024 repeat 100000rootopen.com
linux命令:ping xxx.xxx.xxx.xxx size 1024 repeat 100000 100000 repeat 1024 size xxx.xxx.xxx.xxx ping ping xxx.xxx.xxx.xxx size 1024 repeat 100000rootopen.com
2018-01-10 23:10:48

linux命令:ping -c 3 google.com google.com 3 -c ping ping -c 3 google.comrootopen.com
linux命令:ping -c 3 google.com google.com 3 -c ping ping -c 3 google.comrootopen.com
2018-03-31 14:41:48

Linux的Bash命令行(A-Z排序)