Ping and ping6 command on Linux (tests ICMP connection)
The ping and ping6 command in Linux uses the ICMP protocol to send ECHO REQUEST messages and receive ECHO RESPONSE to test the connection between the system and another machine on the network.
It returns the response time it takes for a network packet to go back and forth. Very useful for diagnosing a connection. The ping will test indefinitely until the crtl-C is pressed.
Ping also has a version for IPv6, called ping6. Its operation is similar to the IPv4 ping.
The most common options are:
- -c num: This option causes the ping to test the connection a certain number of times.
- -q: This option causes the ping to only display the final statistics of the connection test.
Example:
Ping is widely used to test whether a machine is connected to the local network or whether it is reachable on the remote network. For the ping to work correctly, the network in question must not have any ICMP filters, especially the ECHO REQUEST and ECHO RESPONSE types.
The ping command may indicate the following possible network problems:
Problem with Name Resolution:
If when pinging a particular host using a network name (host.certificacaolinux.com.br) the ping takes a long time to respond and is unable to resolve the name for the IP, it means that:
- The DNS server may be wrong (check the /etc/resolv.conf file);
- The DNS server cannot be accessed (ping with the DNS server IP);
- There is a UDP 53 port filter between the computer and the DNS server (check the iptables);
Connectivity Problem:
If a particular host does not respond when pinging, it may mean that:
- The destination host is down;
- There is no route between the computer network and the destination host (check the route table);
- The default gateway is wrong (check the route table);
- The Network Address Translation is having trouble forwarding or translating addresses (check the firewall); - There is an ICMP ECHO and ECHO-REPLY filter on the network;
Learn much more about Linux in our online course. You can register here. If you already have an account, or want to create one, just log in or create your user here.
Did you like it?
Share