How To Ping In Linux?
Monday, Aug 5, 2024 | 2 minutes read | Update at Monday, Aug 5, 2024
Ping is a term, command and action used to check network connectivity. We can use the ping command in order to check Linux network connecvity.Pinging a host in Linux is a simple way to check the connectivity between your system and another network device. Here’s how you can do it:
-
Open a Terminal: You can open the terminal from your applications menu, or by using a shortcut like
Ctrl+Alt+T
. -
Use the
ping
command: The basic syntax for theping
command is:destination
can be a hostname, domain name or IP address. Generally IP address is used with the ping command.ping [options] destination
For example, to ping Google’s DNS server, you can use:
ping 8.8.8.8
Or to ping a website by its domain name. Keep in mind that before pinging the hostname is resolved into IP address. If the domain name is not resolved properly the ping command will fail:
ping google.com
-
Stop the ping command: By default, the
ping
command will continue to send packets until you stop it manually. To stop it, you can pressCtrl+C
.
Here are some useful options you can use with the ping
command:
-
-c count: Send a specific number of packets and then stop. For example, to send 10 packets:
ping -c 10 google.com
-
-i interval: Set the interval between sending each packet (in seconds). For example, to send a packet every 5 seconds:
ping -i 2 google.com
-
-s packetsize: Specify the number of data bytes to be sent. For example, to send packets with 100 bytes of data. Keep in mind that some firewalls may block and drop big ping packets this will result failure:
ping -s 100 google.com
-
-t ttl: Set the Time to Live (TTL) value for packets. For example, to set TTL to 64:
ping -t 64 google.com
Using these commands and options, you can effectively use ping
to troubleshoot network issues and verify connectivity in Linux.