Home »
Linux
Explain ping in Linux - How to ping an IP address in Linux?
By IncludeHelp Last updated : October 19, 2024
Linux ping Command
Ping stands for Packet Internet Groper. This is a Linux terminal command, which is used to check network connectivity.
It will work for all networks like: LAN, MAN, WAN etc.
Ping command uses ICMP protocol to check particular node is reachable or not.
Linux Ping Command Syntax
$ping -<options> <hostname>
Linux Ping Command Example
$ping 192.168.10.105
or
$ping www.google.com
If network is reachable, then output of ping command:
linux~# ping 192.168.10.105
PING 192.168.10.105 (192.168.10.105 ) 56(84) bytes of data.
64 bytes from 192.168.10.105 : icmp_req=1 ttl=64 time=0.477 ms
64 bytes from 192.168.10.105 : icmp_req=2 ttl=64 time=0.157 ms
64 bytes from 192.168.10.105 : icmp_req=3 ttl=64 time=0.284 ms
64 bytes from 192.168.10.105 : icmp_req=4 ttl=64 time=0.285 ms
64 bytes from 192.168.10.105 : icmp_req=5 ttl=64 time=0.288 ms
If network is not reachable, then output of ping command:
linux~# ping 192.168.10.105
PING 192.168.10.105 (192.168.10.105) 56(84) bytes of data.
From 192.168.10.17 icmp_seq=1 Destination Host Unreachable
From 192.168.10.17 icmp_seq=2 Destination Host Unreachable
From 192.168.10.17 icmp_seq=3 Destination Host Unreachable
Options of Linux ping Command
These are some of the important options, which is used with ping command:
- -d
This option is used to set socket option SO_DEBUG
- -l
When source route was lost then we use this option in our IP header to send the packet to the given host.
- -n
It shows network addresses as numbers. Normally when we use ping command, it displays addresses as host names.
- -I (interval)
It specifies the interval between two transmissions. By default, it is one second.