Running Linux, 5th Edition - Matthias Kalle Dalheimer [266]
Finally, if specifying the hostname does not work, but you know its IP address (maybe from an earlier attempt), and specifying the hostname works:
kalle@tigger:~/projects/rl5> ping 208.201.239.36
PING 208.201.239.36 (208.201.239.36) 56(84) bytes of data.
64 bytes from 208.201.239.36: icmp_seq=1 ttl=46 time=249 ms
--- 208.201.239.36 ping statistics ---
2 packets transmitted, 1 received, 50% packet loss, time 1001ms
rtt min/avg/max/mdev = 249.698/249.698/249.698/0.000 ms
then you know that you have a problem with DNS name resolution and can continue to look further in that area.
traceroute
The traceroute command goes a step further than ping. It not only shows you whether you can reach a host on the Internet (or in your own network), but also which route the packets take on their way to get there. That can be useful to diagnose problems that are beyond your reach, such as with central routers on the Internet—not that you could do much about that, but then at least you know that you do not need to debug your own setup.
Here is an example of using traceroute. Notice that here we specify the full path to the command. It is usually in a directory that only root has in its PATH. traceroute can be executed just fine as a normal user, however).
kalle@officespace:~> /usr/sbin/traceroute www.oreilly.com
traceroute to www.oreilly.com (208.201.239.36), 30 hops max, 40 byte packets
1 81.169.166.1 0.204 ms 0.174 ms 0.174 ms
2 81.169.160.157 0.247 ms 0.196 ms 0.195 ms
3 81.169.160.37 0.351 ms 0.263 ms 0.320 ms
4 PC1.bln2-g.mcbone.net (194.97.172.145) 0.256 ms 0.273 ms 0.217 ms
5 L0.bln2-g2.mcbone.net (62.104.191.140) 0.417 ms 0.315 ms 0.272 ms
6 lo0-0.hnv2-j2.mcbone.net (62.104.191.206) 4.092 ms 4.109 ms 4.048 ms
7 lo0-0.hnv2-j.mcbone.net (62.104.191.205) 4.145 ms 4.184 ms 4.266 ms
8 L0.dus1-g.mcbone.net (62.104.191.141) 8.206 ms 8.044 ms 8.015 ms
9 c00.ny2.g6-0.wvfiber.net (198.32.160.137) 92.477 ms 92.522 ms 92.488 ms
10 b0-00.nyc.pos1-35-1.wvfiber.net (63.223.28.9) 166.932 ms 167.323 ms 166.356
ms
11 b00.chi.pos1-6-1.wvfiber.net (63.223.0.214) 167.921 ms 166.610 ms 166.735 ms
12 63.223.20.53 166.543 ms 166.773 ms 166.429 ms
13 unknown63223030025.wvfiber.net (63.223.30.25) 166.182 ms 165.941 ms 166.042
ms
14 unknown63223030022.wvfiber.net (63.223.30.22) 165.873 ms 165.918 ms 165.919
ms
15 unknown63223030134.wvfiber.net (63.223.30.134) 165.909 ms 165.919 ms 165.832
ms
16 ge7-br02-200p-sfo.unitedlayer.com (209.237.224.17) 165.987 ms 165.881 ms
166.022 ms
17 pos-demarc.sf.sonic.net (209.237.229.26) 168.849 ms 168.753 ms 168.986 ms
18 0.at-0-0-0.gw4.200p-sf.sonic.net (64.142.0.182) 169.628 ms 0.at-1-0-0.
gw4.200p-sf.sonic.net (64.142.0.186) 169.632 ms 169.605 ms
19 0.ge-0-1-0.gw.sr.sonic.net (64.142.0.197) 173.582 ms 173.877 ms 174.144 ms
20 gig49.dist1-1.sr.sonic.net (209.204.191.30) 176.822 ms 177.680 ms 178.777 ms
21 www.oreillynet.com (208.201.239.36) 173.932 ms 174.439 ms 173.326 ms
Here, the trace was successful, and you can also see how much time the packets took from hop to hop. With some geographical knowledge and some fantasy, you can guess the route along which the packets went. For example, the computer on which this command was executed was located in Berlin, Germany,[*] so it stands to reason that bln2 in lines 4 and 5 is some