Home / Operating System / Linux / Linux ping Command Options

Linux ping Command Options

Question 1. How to use ping command?

Begin with Ctrl + Alt + T for open command.

Exp: Ping 172.24.72.6

# ping 172.24.72.6


PING 172.24.72.6 (172.24.72.6) 56(84) bytes of data.
64 bytes from 172.24.72.6: icmp_seq=1 ttl=250 time=24.0 ms
64 bytes from 172.24.72.6: icmp_seq=2 ttl=250 time=23.6 ms

Question 2. How to change time interval between ping packets?

By default, there’s a gap of one second between ping packets. However, if you want, you can customize this delay using the -i command line option.

For example, the following command makes sure there’s a gap of 2 seconds or 0.1 second. Note that only super-user may set interval to values less 0.1 seconds

#ping -i 2 172.24.72.6

PING 172.24.72.6 (172.24.72.6) 56(84) bytes of data.
64 bytes from 172.24.72.6: icmp_seq=1 ttl=250 time=24.3 ms
64 bytes from 172.24.72.6: icmp_seq=2 ttl=250 time=23.3 ms

#ping -i 0.1 172.24.72.6

PING 172.24.72.6 (172.24.72.6) 56(84) bytes of data.
64 bytes from 172.24.72.6: icmp_seq=1 ttl=250 time=24.3 ms
64 bytes from 172.24.72.6: icmp_seq=2 ttl=250 time=24.3 ms

Question 3. How to change ping packet size?

By default, the number of bytes in a ping packet is 56 (64 if you include 8 bytes of ICMP header). However, if you want, you change this value, something which you can do using the -s command line option.

For example, to send an 1500 byte packet (1508 including ICMP header), use the following command:

# ping -s 1500 172.24.72.6

PING 172.24.72.6 (172.24.72.6) 1500(1528) bytes of data.

1508 bytes from 172.24.72.6: icmp_seq=1 ttl=250 time=25.6 ms

1508 bytes from 172.24.72.6: icmp_seq=2 ttl=250 time=26.1 ms

Question 4. How to make ping send set number of packets?

The default behavior of ping is to keep sending packets until interrupted by the user. However, if you want, you can force ping to stop executing after sending a set number of packets. This you can do using the -c command line option.

For example, the following command will send 10 packets and then stop.

# ping -c 10 172.24.72.6

PING 172.24.72.6 (172.24.72.6) 56(84) bytes of data. 64 bytes from 172.24.72.6: icmp_seq=1 ttl=250 time=24.1 ms Question 5. How to launch a flood of packets using ping?

Question 5. How to launch a flood of packets using ping?

Yes, the ping command also offers an option to launch a flood of packets. This you can do using the -f command line option.

# ping -f 172.24.72.6

PING 172.24.72.6 (172.24.72.6) 56(84) bytes of data.

..^C

— 172.24.72.6 ping statistics —

203 packets transmitted, 201 received, 0% packet loss, time 2690ms rtt min/avg/max/mdev = 23.393/23.874/25.318/0.275 ms, pipe 3, ipg/ewma 13.319/23.813 ms

Question 6. How to make ping print timestamp before each line?

There’s an option (-D) that lets you do this. The timestamp that’s printed is a combination of unix time and microseconds 

# ping -D 172.24.72.6

PING 172.24.72.6 (172.24.72.6) 56(84) bytes of data.

[1556937293.976274] 64 bytes from 172.24.72.6: icmp_seq=1 ttl=250 time=23.9 ms

[1556937294.977350] 64 bytes from 172.24.72.6: icmp_seq=2 ttl=250 time=23.7 ms

[1556937295.978095] 64 bytes from 172.24.72.6: icmp_seq=3 ttl=250 time=24.1 ms

[1556937296.977999] 64 bytes from 172.24.72.6: icmp_seq=4 ttl=250 time=23.7 ms

Question 7. How to set a hard timeout for ping?

You can specify a time deadline for ping to exit. This you can do using the -w command line option that requires a numeric value representing number of seconds.

For example, the following ping command will stop after 15 seconds:

# ping -w 15 172.24.72.6

PING 172.24.72.6 (172.24.72.6) 56(84) bytes of data.

64 bytes from 172.24.72.6: icmp_seq=1 ttl=250 time=23.3 ms

Question 8. How to set a soft timeout for ping?

While the -w option makes sure ping stops in any case after the deadline has expired, there’s another option (-W, in caps) that also makes ping stop but only when there’s no response from the destination side.

# ping -W 15 172.24.72.6

PING 172.24.72.6 (172.24.72.6) 56(84) bytes of data.

64 bytes from 172.24.72.6: icmp_seq=1 ttl=250 time=23.4 ms

64 bytes from 172.24.72.6: icmp_seq=2 ttl=250 time=23.7 ms

Many linux in here

About dongpolicex2

Check Also

How to active theme newspaper 9.8 wordpress

How to Active theme Newspaper 9.8 Install Theme NewspaperEdit Code in file td_api.phpRight Now, I …

0902 780 887