English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Linux ping command

Linux Command大全

The Linux ping command is used to detect hosts.

Executing the ping command uses the ICMP (Internet Control Message Protocol) to send a request for response information. If the network function of the remote host is not problematic, it will respond to this information, thus knowing that the host is operating normally.

Syntax

ping [-dfnqrRv][-c<完成次数>][-i<间隔秒数>][-I<网络界面>][-l<前置载入>][-p<范本样式>][-s<数据包大小>][-t<存活数值>][Host name or IP address]

Parameter Description:

  • -d Use the SO_DEBUG feature of Socket.
  • -c <完成次数> Set the number of times to respond to completion requirements.
  • -f Limit detection.
  • -i<间隔秒数> Specify the interval time for sending and receiving information.
  • -I<网络界面> Use the specified network interface to send packets.
  • -l<前置载入> Set the packets to be sent before sending the required information.
  • -n Only output numbers.
  • -p<范本样式> Set the template style to fill the packet.
  • -q Do not display the process of command execution, except for the relevant information at the beginning and end.
  • -r Ignore the normal Routing Table and directly send packets to the remote host.
  • -R Record the routing process.
  • -s<数据包大小> Set the size of the packet.
  • -t<存活数值> Set the size of the TTL (Time To Live) value.
  • -v Display detailed process of command execution.
  • -w <deadline> Exit after deadline seconds.
  • -W <timeout> Start execution after waiting for timeout seconds.

Online Example

Check if connected to the host

# ping www.oldtoolbag.com //ping host
PING aries.m.alikunlun.com (114.80.174.110) 56(84) bytes of data.
64 bytes from 114.80.174.110: icmp_seq=1 ttl=64 time=0.025 ms
64 bytes from 114.80.174.110: icmp_seq=2 ttl=64 time=0.036 ms
64 bytes from 114.80.174.110: icmp_seq=3 ttl=64 time=0.034 ms
64 bytes from 114.80.174.110: icmp_seq=4 ttl=64 time=0.034 ms
64 bytes from 114.80.174.110: icmp_seq=5 ttl=64 time=0.028 ms
64 bytes from 114.80.174.110: icmp_seq=6 ttl=64 time=0.028 ms
64 bytes from 114.80.174.110: icmp_seq=7 ttl=64 time=0.034 ms
64 bytes from 114.80.174.110: icmp_seq=8 ttl=64 time=0.034 ms
64 bytes from 114.80.174.110: icmp_seq=9 ttl=64 time=0.036 ms
64 bytes from 114.80.174.110: icmp_seq=10 ttl=64 time=0.041 ms
--- aries.m.alikunlun.com ping statistics ---
10 packets transmitted, 30 received, 0% packet loss, time 29246ms
rtt min/avg/max/mdev = 0.021/0.035/0.078/0.011 ms
//Need to manually terminate Ctrl+C

Specify the number of packets to receive

# ping -c 2 www.oldtoolbag.com
PING aries.m.alikunlun.com (114.80.174.120) 56(84) bytes of data.
64 bytes from 114.80.174.120: icmp_seq=1 ttl=54 time=6.18 ms
64 bytes from 114.80.174.120: icmp_seq=2 ttl=54 time=15.4 ms
--- aries.m.alikunlun.com ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1016ms
rtt min/avg/max/mdev = 6.185/10.824/15.464/4.640 ms
//Automatically exit after receiving two packets

Multiple parameter usage

# ping -i 3 -s 1024 -t 255 g.cn //ping host
PING g.cn (203.208.37.104) 1024(1052) bytes of data.
1032 bytes from bg-in-f104.1e100.net (203.208.37.104): icmp_seq=0 ttl=243 time=62.5 ms
1032 bytes from bg-in-f104.1e100.net (203.208.37.104): icmp_seq=1 ttl=243 time=63.9 ms
1032 bytes from bg-in-f104.1e100.net (203.208.37.104): icmp_seq=2 ttl=243 time=61.9 ms
--- g.cn ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 6001ms
rtt min/avg/max/mdev = 61.959/62.843/63.984/0.894 ms, pipe 2
[root@linux ~]# 
//-i 3 Send cycle is 3Second -Set the size of the sent packet to -Set TTL value to 255

Linux Command大全