LinuxCommandLibrary

ping.py

Test network connectivity

TLDR

Ping a host from a specified source IPv4 address

$ ping.py [source_ipv4] [destination_ipv4]
copy

Ping 192.168.1.100 from 192.168.1.10
$ ping.py 192.168.1.10 192.168.1.100
copy

SYNOPSIS

ping [options] host

PARAMETERS

-c count
    Stop after sending count ECHO_REQUEST packets.

-i interval
    Wait interval seconds between sending each packet. The default is one second.

-I interface_address
    Set source address to specified interface address.

-s packetsize
    Specifies the number of data bytes to be sent. The default is 56, which translates into 64 ICMP data bytes when combined with the 8 bytes of ICMP header data.

-t ttl
    Set the IP Time To Live for outgoing packets.

-v
    Verbose output. List ICMP response packets that were dropped.

host
    The hostname or IP address to ping.

DESCRIPTION

The ping command is a fundamental network utility used to test the reachability of a host on an Internet Protocol (IP) network. It works by sending Internet Control Message Protocol (ICMP) echo request packets to a target host and waiting for ICMP echo reply packets. The command reports round-trip times, packet loss, and other statistics, providing insights into network latency and connectivity problems.

ping is invaluable for network troubleshooting, diagnosing routing issues, and verifying that a server or device is online and responsive. Its simplicity and wide availability make it a core tool for network administrators and developers alike. It also helps to determine if a remote host is reachable and measure the quality of the connection between two hosts.

It is commonly used by providing IP address or Fully Qualified Domain Name of the host.

CAVEATS

Requires root privileges for some options, like setting the source address on certain systems. Excessive use can be seen as a denial-of-service attack.

INTERPRETING RESULTS

The output shows the round-trip time (RTT) in milliseconds, which is the time it takes for a packet to reach the destination and return. Lower RTT values indicate better network performance. Packet loss indicates connectivity problems. High packet loss may indicate routing issues or network congestion.

SECURITY CONSIDERATIONS

While primarily a diagnostic tool, ping can be used maliciously to flood a target with ICMP requests, leading to a denial-of-service (DoS) attack. Firewalls and other security measures often block or rate-limit ICMP traffic to mitigate this risk.

HISTORY

ping was originally written by Mike Muuss in December 1983 to troubleshoot IP network problems. Its name comes from the sonar terminology used by submarines, referring to sending out a pulse and listening for a return signal. It has since been widely adopted across various operating systems and remains a core networking tool.

SEE ALSO

Copied to clipboard