Linux ping packet size

Ping Command in Linux

Ping Command is the most used command in networking world. Maybe it is the first command that every network engineer has used firstly. During network integration, network operation and troubleshooting activities, we use Ping. There are different Linux Ping Commands used on Linux devices. So, here, we will focus on these commands in Linux. We will learn Linux Ping Command Options with different Examples.

Ping is the abbreviation of “Packet Internet Groper”.Mainly, we use Ping Command to check the connectivity of the peers in networking. In the network world, there are many Linux Servers or Linux based devices. On these devices, Ping is used too much. So, Ping Command in Linux is one of the important command with its Command Options.

To learn Windows Ping Commands, you can also check other Ping Command.

Pinging is the activity to send ICMP (Internet Control Message Protocol) messages between peers. In other words one peer sends ICMP Echo Request and the other replies with ICMP Echo Reply. So, the Ping process is completed. If there is a connectivity between peers, it is successfull. Or, it is unsuccessful.

The options of this command are very important during your network operations or troubleshooting activiries. So, knowing these Options, will provide you a better performance on your network.

Now, let’s focus Linux Ping and learn the Command Options detailly.

You can also access Top Linux Commands and Download Linux Command Cheat Sheet!

How to use Ping on Linux?

Using Ping Command in Linux, is similar to Windows. Simply, we use “ping” keyword and then we write the Ping Option. Lastly we write IP Address or hostname of the destination or ho that we would like to check.

ping [Option] Destination IP Address / Hostname

Below, you can find an example without options.

$ ping 10.10.10.10

$ ping www.ipcisco.com

This is the pure usage of this connectivity checker command. To perform a better performance on our network operations and troubeshooting activities, we need more options of the Linux Ping command.

Ping command reply will include the below fields:

Linux Ping Command Options

There are many Options in Linux for this command like Options in Windows or in network equipments like routers. Here, we will learn all these Linux Ping Options one by one.You can use these Options, one by one or together with different combinations.

linux-ping-ipcisco.com

Specifying the IP Version

ping -4

If you would like to use it only for IPv4 Address, you can use “-4”. Below, we can force to ping www.ipcisco.com with IPv4.

Читайте также:  Ноутбук для установки линукс

$ ping -4 www.ipcisco.com

ping -6

If you would like to use it only for IPv6 Address, you can use “-6”. Below, we can force to ping www.ipcisco.com with IPv6.

$ ping -6 www.ipcisco.com

Ping With Sound

ping -a

If you would like to hear a beep sound, you can use “-a” option with Ping command in Linux.

$ ping -a 10.10.10.10

Pinging Broadcast

If you would like to allow pinging Broadcast addresses, you can use “-b” option. To use this command with 10.10.10.10 we will use the below Linux command.

$ ping -b 10.10.10.10

Preventing Source Change

ping -B

To prevent source change, we use “-B” option with this Command. We will use destination address 10.10.10.10 with this option.

$ ping -B 10.10.10.10

Changing the Number of Ping Packets

ping -c

“c” stands for “count”. If you use ping with “-c” and “a number” after it, it means that send ping with this number of times. For example, to send 10 ping to destination www.ipcisco.com or 10.10.10.10, we can use the below command:

$ ping -c 10 www.ipcisco.com

$ ping -c 10 10.10.10.10

Ping Debug Option

ping -d

Option “-d” stands for Debug. To enable Debug IP Packet like below, we use this Linux command option.

$ ping -d 10.10.10.10

Flooding Ping

ping -f

“f” stands for “flood”. If you use ping with “-f”, it sends hundreds of pings per second. To send flood 10.10.10.10 address, we can use thebelow command:

$ ping -f 10.10.10.10

Changing Successfull Ping Interval

ping -i

There is a default interval between successfull ping packets. This default value is 1 second. To change this default interval we can use“-i” option. It stands for “interval”. For example, if we change this interval to 3 second, we can sue the below Linux ping command. For pinging www.ipcisco.com.

$ ping -i 3 www.ipcisco.com

Determinind Ping Source Interface

ping -I

Source Interface. “-I” Option is used to set the source of Ping packets. There can be multiple interface in your device. You can set a specific interface as the ping source. For example, below we set our ping source as fa1 for pinging www.ipcisco.com0

$ ping -I fa1 www.ipcisco.com

Sending Ping Packets Without Response

ping -l

To send ping packet without waiting for a reply, we use “-l” option. If you would like to set this a value more than 3, you should be a root user. To send multiple packets without response to destination 10.10.10.10 we use the below Linux Ping command.

$ ping -l 7 10.10.10.10

If you are not a root user, you can use the below command to set this value:

$ sudoping -l 7 10.10.10.10

Displaying Network Address Numbers

ping -n

To display network addresses as numbers not as host names.

$ ping -n www.ipcisco.com

Summary Ping Response

ping -q

To display only summary lines at the startup and the finish time, we use “-q” option.

$ ping -q www.ipcisco.com

Pinging a Local Host Only

ping -r

To ping a local host and bypass the routing table records, “-r” option is used.

$ ping -r 10.10.10.10

Record Route Option

ping -R

“R” option is used for Record Route. It recordss the route of the packet inside IP Header.

$ ping -R www.ipcisco.com

Setting Ping Packet Size

ping -s

Ping “-s” option give us an opportunity to change the default ping packet size. The default ping packet is 56 bytes long. It is trantlated 64 bytes ICMP data. Below, we will change this packet size as 200 bytes for pinging 10.10.10.10.

$ ping -s 200 10.10.10.10

Читайте также:  Linux вывод командной строки

Changing TTL Value

ping -t

With “-t” option, we can change TTL (Time to Live) Value of Linux Ping.

$ ping -t 300 10.10.10.10

Ping Timestamp

ping -T

We use option “-T” to print timestamp with ping responses.

$ ping -T 10.10.10.10

We can also use some more additional options together with “-T” options. These are given below:

  • tsonly(timestamp)
  • tsandaddr(timestamp + address)
  • tsprespec(pre specified timestamp)

Enabling Verbose Mode

ping -v

With “-v” option, we can enable Verbose mode.

$ ping -v 10.10.10.10

Displayin Version Number

ping -V

To display version number “-V” option is used.

$ ping -V 10.10.10.10

Changing Ping Timeout

ping -w

With “-w” option, we can set the time that ping will exits independent of the number of the send packets. To set this time to 2 seconds, we will use the below command:

Changing Ping Response Time

ping -W

With “-W” option, we can set the time that we will wait for a ping response. For example to set this interval to 5 seconds, we can use the below command.

Linux Ping Examples

Example 1

Sending 10 packets with 100 Bytes Sized to 1.1.1.1

$ ping -s 100 -c 10 1.1.1.1

Example 2

Setting Interval to 5 seconds with ping debug option towards 1.1.1.1

$ ping -i 5 -d 10 1.1.1.1

Example 3

Checking connectivity to www.ipcisco.com from interface fa1 and with TTL 350, with verbose mode.

$ ping -I fa1 5 -t 350 -v

Example 4

Checking connectivity to www.ipcisco.com with setting response time to 10 seconds with timestamps.

$ ping -W 10 -T

Example 5

To send 12 packet without waiting any response from www.ipcisco.com with 200 bytes packets.

$ ping -l 12 -s 200

linux-ping-ipcisco.com

To learn Windows Ping Commands, you can also check other Ping Command.

You can also access Top Linux Commands and Download Linux Command Cheat Sheet!

Источник

The Linux Ping Command

The Linux Ping Command

Ping or Packet Internet Groper is a network management utility that can check the connection status between a source and destination computer/device over an IP network. It also helps you estimate the time it takes to send and receive a response from the network.

We all have our favorite websites that we visit frequently; if one of them doesn’t load, we really want to know why. Is it because we don’t have an Internet connection, or is it problems with our Internet service provider that are preventing us from accessing the website? Another reason could be the unavailability of the website itself. Whatever the reason, the Linux Ping command can give you all the answers.

Ping uses the Internet Control Message Protocol (ICMP) to send and receive echo messages to and from the host or target computers to keep us informed of network performance. An ICMP request message is sent to the target computer; if the target IP address is available, it sends an ICMP message response to the host computer. This informs us about the connectivity status of the network, such as the round-trip time – the time it takes to send and receive an information packet.

Using the Ping command

In the Linux terminal type the following command:

This is the output you will get:

Linux ping command

Let us describe(in alphabetic order) the commonly used options that you can see above:

Option Description
a Use this option for a beep sound when the peer is reachable
b Use this option to allow pinging a broadcast address
B Use this option if you do not want to allow the ping to change the source address of the probe
c (count) Use this option to set the number of times to send the ping request
d Use this option to set the SO-DEBUG option on the socket being used
f Use this option to flood the network by sending hundred or more packets per second
i (interval) Use this option to specify an interval between successive packet transmissions. The default value of interval is 1 second
I (interface address) Use this option to set source address to the specified interface address. This option is required when pinging IPv6 link local address. Its argument can be an IP address or name of the device.
l (preload) Use this option to set the number of packets to send without waiting for a reply. For selecting a value more than 3, you need to be a super user.
n Use this option to display network addresses as numbers rather than as hostnames
q Use this option to display a quiet output. It means that only the summary is displayed at startup and finish time
T (ttl) Use this option to set the Time To Live
v Use this option for verbose output
V Use this option to display the version and exit
w (deadline) Use this option to specify a timeout, in seconds, before ping exits, regardless of how many packets have been sent or received.
W (timeout) Use this option to set the time(seconds) to wait for a response
Читайте также:  Arch linux настройка терминала

Some Basic Ping functions

Here are some basic ping functions that you will be used to check the performance of your network:

Pinging the host for availability

You can check if a host is alive or not through the following ping command:

Press Ctrl+C for breaking the command

Pinging the host for availability

Increase/Decrease interval between ping packets

The default time interval between sending each packet is 1 second in Linux. You can increase the time interval by setting a value greater than 1 and decrease it by setting a value less than 1.

Here is an example to increase the time interval between two pings:

Here is an example to decrease the time interval between two pings:

As you can see in the following image, you need to be a superuser in order to set this time interval lesser than 0.2 seconds:

Increasing/Decreasing interval between ping packets

Therefore, the command should be executed with sudo. It should look like the following,

Enter the password when you are prompted and the command should work.

Change ping packet size

The default ping packet size is 56 bytes. You can change it through the following command:

$ ping -s packetsize hostname/IP

Here we are setting the packet size to 100; you can see the value set to 100 in the first line of output:

Change ping packet size

Set ping to send a desired number of packets

You can set ping to send a desired number of packets as follows:

$ ping -c NumberOfPackets IP/hostname

In the following example, we are setting the number of packets as 5; after that, the results will end:

Set ping to send a desired number of packets

Flooding the network

Ping command allows super users to send 100 or more packets per second through the following command:

Flooding the network

Ping prints a “.” when sending a ping and “/” when receiving one.

Set ping timeout

You can set a time limit after which ping will exit; no matter how many ping packets are sent or received:

$ ping -w timeinseconds hostname/ip

Here we are using 3 seconds as timeout:

Set ping timeout

Audible ping

The ping command can be set to play a beep to check whether the host is available as follows:

Practicing around with this tutorial will enable you to run ping commands to check your network performance in an optimal way. You can also use advanced switches to customize your requests and responses in ping.

About This Site

Vitux.com aims to become a Linux compendium with lots of unique and up to date tutorials.

Latest Tutorials

Источник

Оцените статью
Adblock
detector