The ping and traceroute or tracert commands
The ping and traceroute commands allow you to test and troubleshoot network connectivity-related issues. Both commands support various options. This tutorial explains how to read the output of both commands and use the supported options for network testing and troubleshooting.
The ping and traceroute commands
The ping and traceroute commands are universal. All operating systems include these commands. You can use these commands on any platform and operating system. However, there is a slight difference between the term used to refer to the traceroute command. Windows-based systems use the truncated term (tracert) while Linux-based systems use the complete word (traceroute). This difference does not affect the command's functionality. It works similarly on both platforms.

The ping command
The ping command allows you to test connectivity between two network devices. It accepts the destination computer's name or IP address as the argument. It sends dummy data packets to the destination device. These dummy data packets are known as payloads, and the messages they carry are known as echo messages. If the destination device is up, it replies to echo messages. The source device receives these echo messages and verifies the connectivity. If not, it indicates a connectivity issue. This issue can occur at any point along the path.

A path typically includes the four components: the loopback interface, the default gateway, the DNS service, and the remote host.
Testing connectivity with the loopback interface
Open a terminal or the command prompt if you are on a Windows system. Run the ping command. Specify the IP address 127.0.0.1 as the argument. If it receives replies, it verifies that the TCP/IP protocol suite is functional on the system. The TCP/IP protocol suite provides all the protocols and things systems need to communicate on a network. A system can communicate with another system only if it has a functional TCP/IP suite. The ICMP protocol is part of this suite. It provides many tools and commands for testing and troubleshooting, including ping and traceroute. It reserves a range of IP addresses for testing the protocol suite on the host system. These addresses are called loopback addresses. Loopback addresses allow you to test and verify the TCP/IP suite on the host system.

Testing connectivity with the gateway device
If the source and destination devices are in different IP subnets, the default gateway becomes an essential point in the communication path. It takes data from the source device and forwards it to the destination device or the device connected to the destination device. When you purchase an Internet connection, the ISP gives you a modem or router. This router contains an IP address that serves as the default gateway for all hosts connected to it. You can use the ipconfig command on a Windows system. On a Linux system, you need two commands: the ip address show and the ip route show. The ip address show command shows the IP address. The ip route show command shows the gateway IP address.

Send ping requests to the gateway's IP. If the system gets a reply from the gateway IP address, it verifies connectivity between the system and the gateway device.

Testing connectivity with the DNS service
The third important use of the ping command is testing the DNS service. The DNS service translates names into IP addresses and IP addresses into names. Humans prefer names while computers use numbers. The DNS service maps names to IP addresses, allowing you to access resources by name instead of their corresponding numerical IP addresses. If this service is down or not configured, you can not access a network host by its name. Linux saves the DNS server's IP address in the /etc/resolv.conf file. To know the status of this service, you can send ping requests to the DNS server's IP address.

Alternatively, you can ping a network host by its name. For example, to know whether the DNS server of your ISP is working, you can ping Google or Microsoft by its name. The ping command uses the DNS service to translate a name into its corresponding IP address and sends echo messages to that address. If the DNS service is down or not configured, it fails to resolve the name into an IP address and returns an error.

If you know the IP address of a host, you can use it directly. It helps you identify whether the issue is related to the DNS service. If you can ping a host by its IP address but not by its name, the problem is related to the DNS service. If you can ping a host by its name and IP address, it verifies that the host is reachable and has the proper network connectivity.
Testing connectivity with the remote server
If you specify the remote server's IP address as an argument, it sends ping requests to the remote server. If you provide a name, it first connects to the DNS server and translates the name into the IP address, and then sends echo messages to the translated IP address. If the specified host is not available or the service is down, it returns an error indicating that the host or the service is unknown. If the host is available and up, it replies to the ping messages.

The output includes the following information.
- The host or service name at the remote system.
- The IP address of the remote system.
- The size of the data packets the host system sends.
- The size of the data packets the remote system uses to reply.
- The sequence number of the data packet. It allows you to track data packets exchanged between both systems.
- The time taken by the data packet in the path.
- The TTL value. It defines the maximum time a packet can live.
The ping command options
The ping command supports many options. The following command shows all options and their meanings.
#ping -help

Sending ping requests using a specific IP version
There are two versions of IP: IPv4 and IPv6. By default, it uses IPv6 to send echo requests. To send ping requests on IPv4, use the -4 option. It forces the ping command to use version 4 for testing. Similarly, you can use the -6 option to force the ping command to use IPv6.

Sending a specific number of packets
By default, it sends ping requests until you stop it. To send a specific number of packets, use the c option and specify the number of packets. For example, the following command sends four packets.
#ping -c 4 google.com

Using a custom size for data packets
The default size of data packets it sends is 56 bytes. The s option allows you to use a custom size for data packets. For example, the following command sends data packets of 100 bytes.
#ping -s 100 google.com

Sending data packets at a specific interval
You can define a custom interval between two consecutive packets. For example, the following command sets it to five seconds.
#ping -i 5 google.com

The traceroute command
The traceroute command works similarly to the ping command. However, instead of sending echo messages directly to the destination device, it sends them to each router between the source and destination.
#traceroute google.com

The output includes the following things.
- A sequentially increasing hop number. It indicates the sequence of routers the packet passes through, starting from 1.
- For each hop, traceroute sends three echo messages and displays the time it takes for each message to travel to that hop and back. These times are in milliseconds.
- The IP address or the hostname of the router.
- If you see asterisks for a hop, it means the router at that hop did not respond to the echo messages within the allotted time. Possible reasons include packet filtering and network congestion.
Responses of the ping command
In the output of the ping command, you can see four types of responses.
- A successful response indicates that the target host received the echo request and sent back an echo reply.
- A request timed out message means the host did not receive a reply to echo messages within the default timeout period. It indicates that either the target host is offline or a firewall is blocking the ICMP traffic.
- A destination host unreachable message indicates that the local system or an intermediate router cannot find a path to the destination host.
- An unknown host error means the hostname you entered could not be resolved to an IP address, indicating an issue with the DNS service.
Responses of the traceroute command
In the output of the traceroute command, you can see three types of responses.
- A complete path. It indicates the destination is up and reachable through the routers listed in the output.
- Request timed out. It indicates that the host did not receive a reply from a specific hop within the timeout period.
- Destination net unreachable. It indicates that the packets could not find a route to the destination, often due to a routing issue or an incorrect destination address.

Conclusion
Ping and traceroute are the two most popular network troubleshooting commands. These commands allow you to debug connectivity-related issues. This tutorial explained how to use these commands and identify the problem from the output.
Author Laxmi Goswami Updated on 2026-04-09