Learn a Linux command every day (62): Ping

Time:2021-7-30

Learn a Linux command every day (62): Ping

Yesterday’s recommendation:Learn a Linux command every day (61): WGet

Command introduction

The ping command is used to test the network connectivity between hosts.

Ping is a simple way to send network data to and receive network data from another computer on the network. It is usually used to test whether it can be accessed through the network with another system, and if so, how long it will take to exchange the data.

Syntax format

ping [options] destination
ping -6 [options] destination

Option description

-C < completion times >   # Specify the number of times to request a response
-f   # Maximum limit detection
-I < interval seconds >   # Specify the interval between sending and receiving messages
-n   # Output only values
-P < template style >   # Sets the template style for filling packets
-q   # The execution process information is not output, except the relevant information at the beginning and end
-r   # Ignore normal   Routing   Table, which directly sends the data packet to the remote host
-R   # Record routing process
-S < packet size >   # Set packet size
-T < survival value >    # Sets the size of the survival value TTL
-v    # Detailed output of execution process information

Application examples

Common examples

[[email protected] ~]# ping www.baidu.com
PING www.a.shifen.com (36.152.44.95) 56(84) bytes of data.
64 bytes from 36.152.44.95 (36.152.44.95): icmp_seq=1 ttl=56 time=10.5 ms
64 bytes from 36.152.44.95 (36.152.44.95): icmp_seq=2 ttl=56 time=11.8 ms
64 bytes from 36.152.44.95 (36.152.44.95): icmp_seq=3 ttl=56 time=10.7 ms
^C
--- www.a.shifen.com ping statistics ---
7 packets transmitted, 7 received, 0% packet loss, time 6095ms
rtt min/avg/max/mdev = 10.588/11.512/12.007/0.546 ms
[[email protected] ~]# ping -n www.baidu.com
PING www.a.shifen.com (36.152.44.96) 56(84) bytes of data.
64 bytes from 36.152.44.96: icmp_seq=1 ttl=56 time=13.6 ms
64 bytes from 36.152.44.96: icmp_seq=2 ttl=56 time=14.0 ms
^C
--- www.a.shifen.com ping statistics ---
6 packets transmitted, 6 received, 0% packet loss, time 5032ms
rtt min/avg/max/mdev = 13.616/14.373/14.933/0.442 ms

Only Ping twice

[[email protected] ~]# ping -c 2 www.baidu.com
PING www.a.shifen.com (36.152.44.96) 56(84) bytes of data.
64 bytes from 36.152.44.96 (36.152.44.96): icmp_seq=1 ttl=56 time=14.0 ms
64 bytes from 36.152.44.96 (36.152.44.96): icmp_seq=2 ttl=56 time=14.4 ms
--- www.a.shifen.com ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1013ms
rtt min/avg/max/mdev = 14.086/14.257/14.428/0.171 ms

Limit Ping test

[[email protected] ~]# ping -c 10 -f www.baidu.com
PING www.a.shifen.com (36.152.44.96) 56(84) bytes of data.
  
--- www.a.shifen.com ping statistics ---
10 packets transmitted, 10 received, 0% packet loss, time 110ms
rtt min/avg/max/mdev = 13.368/13.587/13.871/0.142 ms, pipe 2, ipg/ewma 12.279/13.609 ms

Learn a Linux command every day (58): telnet

Learn a Linux command every day (59): SSH

Learn a Linux command every day (60): SCP