traceroute, and mtr
If all worked properly in the preceding section, you should now be able to use
the ping command to check that the interface is responding properly like this
(using either localhost or its IP address):
Click here to view code image
matthew@seymour:~$ ping -c 3 localhost
PING localhost (127.0.0.1) 56(84) bytes of data.
64 bytes from localhost (127.0.0.1): icmp_seq=1 ttl=64 time=0.047 ms
64 bytes from localhost (127.0.0.1): icmp_seq=2 ttl=64 time=0.060 ms
64 bytes from localhost (127.0.0.1): icmp_seq=3 ttl=64 time=0.045 ms
--- localhost ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2030ms
rtt min/avg/max/mdev = 0.045/0.050/0.060/0.010 ms
You use the -c option to set the number of pings, and the command, if
successful (as it was here), returns information regarding the round-trip speed
of sending a test packet to the specified host.
The second line in the /etc/hosts file uses the actual hostname of the
computer and assigns it to a similar private IP address that is unique to that
computer. In the earlier code example, you can see that 127.0.1.1 is
assigned to seymour, which is the name of the computer on which that
hosts file resides.
The remaining lines are used for IPv6 and can be ignored—with the exception
of the line that begins ::1. This is used to define the localhost
connection for IPv6, which you can test with the ping6 command at the
terminal, as follows:
Click here to view code image
matthew@seymour:~$ ping6 -c 3 ::1
PING ::1(::1) 56 data bytes
64 bytes from ::1: icmp_seq=1 ttl=64 time=0.072 ms
64 bytes from ::1: icmp_seq=2 ttl=64 time=0.065 ms
64 bytes from ::1: icmp_seq=3 ttl=64 time=0.061 ms
--- ::1 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2060ms
rtt min/avg/max/mdev = 0.061/0.066/0.072/0.004 ms
This is a good place to pause and discuss three tools that are useful for
checking a network: ping/ping6, traceroute/traceroute6, and
mtr. A network timeout while you’re using any of these tools indicates that
there is a connectivity problem. If you get a response, then your network is