]> git.saurik.com Git - apple/network_cmds.git/blame - traceroute.tproj/traceroute.8
network_cmds-543.tar.gz
[apple/network_cmds.git] / traceroute.tproj / traceroute.8
CommitLineData
2b484d24 1.\" Copyright (c) 1989, 1995, 1996, 1997, 1999, 2000
b7080c8e
A
2.\" The Regents of the University of California. All rights reserved.
3.\"
2b484d24
A
4.\" Redistribution and use in source and binary forms are permitted
5.\" provided that the above copyright notice and this paragraph are
6.\" duplicated in all such forms and that any documentation,
7.\" advertising materials, and other materials related to such
8.\" distribution and use acknowledge that the software was developed
9.\" by the University of California, Berkeley. The name of the
10.\" University may not be used to endorse or promote products derived
11.\" from this software without specific prior written permission.
12.\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
13.\" IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
14.\" WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
b7080c8e 15.\"
9c859447 16.Dd May 29, 2008
b7080c8e
A
17.Dt TRACEROUTE 8
18.Os BSD 4.3
19.Sh NAME
20.Nm traceroute
21.Nd print the route packets take to network host
22.Sh SYNOPSIS
23.Nm traceroute
9c859447
A
24.Op Fl adeFISdNnrvx
25.Op Fl A Ar as_server
2b484d24
A
26.Op Fl f Ar first_ttl
27.Op Fl g Ar gateway
28.Op Fl i Ar iface
29.Op Fl M Ar first_ttl
b7080c8e 30.Op Fl m Ar max_ttl
2b484d24 31.Op Fl P Ar proto
b7080c8e
A
32.Op Fl p Ar port
33.Op Fl q Ar nqueries
b7080c8e 34.Op Fl s Ar src_addr
b7080c8e
A
35.Op Fl t Ar tos
36.Op Fl w Ar waittime
2b484d24 37.Op Fl z Ar pausemsecs
b7080c8e
A
38.Ar host
39.Op Ar packetsize
40.Sh DESCRIPTION
41The Internet is a large and complex aggregation of
42network hardware, connected together by gateways.
43Tracking the route one's packets follow (or finding the miscreant
44gateway that's discarding your packets) can be difficult.
9c859447 45.Nm
b7080c8e
A
46utilizes the IP protocol `time to live' field and attempts to elicit an
47.Tn ICMP
48.Dv TIME_EXCEEDED
49response from each gateway along the path to some
50host.
51.Pp
52The only mandatory parameter is the destination host name or IP number.
2b484d24 53The default probe datagram length is 40 bytes, but this may be increased
b7080c8e
A
54by specifying a packet size (in bytes) after the destination host
55name.
56.Pp
57Other options are:
58.Bl -tag -width Ds
9c859447
A
59.It Fl a
60Turn on AS# lookups for each hop encountered.
61.It Fl A Ar as_server
62Turn on AS# lookups and use the given server instead of the
63default.
64.It Fl d
65Enable socket level debugging.
66.It Fl D
67When an ICMP response to our probe datagram is received,
68print the differences between the transmitted packet and
69the packet quoted by the ICMP response.
70A key showing the location of fields within the transmitted packet is printed,
71followed by the original packet in hex,
72followed by the quoted packet in hex.
73Bytes that are unchanged in the quoted packet are shown as underscores.
74Note,
75the IP checksum and the TTL of the quoted packet are not expected to match.
76By default, only one probe per hop is sent with this option.
77.It Fl e
78Firewall evasion mode.
79Use fixed destination ports for UDP and TCP probes.
80The destination port does NOT increment with each packet sent.
2b484d24
A
81.It Fl f Ar first_ttl
82Set the initial time-to-live used in the first outgoing probe packet.
83.It Fl F
84Set the "don't fragment" bit.
2b484d24
A
85.It Fl g Ar gateway
86Specify a loose source route gateway (8 maximum).
87.It Fl i Ar iface
88Specify a network interface to obtain the source IP address for
89outgoing probe packets. This is normally only useful on a multi-homed
90host. (See the
91.Fl s
92flag for another way to do this.)
93.It Fl I
94Use
95.Tn ICMP
96ECHO instead of
97.Tn UDP
98datagrams. (A synonym for "-P icmp").
99.It Fl M Ar first_ttl
100Set the initial time-to-live value used in outgoing probe packets.
101The default is 1, i.e., start with the first hop.
b7080c8e
A
102.It Fl m Ar max_ttl
103Set the max time-to-live (max number of hops) used in outgoing probe
2b484d24
A
104packets. The default is
105.Em net.inet.ip.ttl
106hops (the same default used for
b7080c8e
A
107.Tn TCP
108connections).
109.It Fl n
110Print hop addresses numerically rather than symbolically and numerically
111(saves a nameserver address-to-name lookup for each gateway found on the
112path).
2b484d24
A
113.It Fl P Ar proto
114Send packets of specified IP protocol. The currently supported protocols
115are:
116.Tn UDP
117,
118.Tn TCP
119,
120.Tn GRE
121and
122.Tn ICMP
123Other protocols may also be specified (either by name or by number), though
9c859447 124.Nm
2b484d24
A
125does not implement any special knowledge of their packet formats. This
126option is useful for determining which router along a path may be
127blocking packets based on IP protocol number. But see BUGS below.
b7080c8e 128.It Fl p Ar port
2b484d24 129Protocol specific. For
b7080c8e 130.Tn UDP
2b484d24
A
131and
132.Tn TCP,
133sets the base
b7080c8e
A
134.Ar port
135number used in probes (default is 33434).
9c859447 136.Nm
b7080c8e
A
137hopes that nothing is listening on
138.Tn UDP
139ports
140.Em base
141to
142.Em base+nhops-1
143at the destination host (so an
144.Tn ICMP
145.Dv PORT_UNREACHABLE
146message will
147be returned to terminate the route tracing). If something is
148listening on a port in the default range, this option can be used
149to pick an unused port range.
150.It Fl q Ar nqueries
151Set the number of probes per ``ttl'' to
152.Ar nqueries
153(default is three probes).
154.It Fl r
155Bypass the normal routing tables and send directly to a host on an attached
156network.
157If the host is not on a directly-attached network,
158an error is returned.
159This option can be used to ping a local host through an interface
160that has no route through it (e.g., after the interface was dropped by
161.Xr routed 8 ) .
162.It Fl s Ar src_addr
163Use the following IP address
164(which must be given as an IP number, not
165a hostname) as the source address in outgoing probe packets. On
166hosts with more than one IP address, this option can be used to
167force the source address to be something other than the IP address
168of the interface the probe packet is sent on. If the IP address
169is not one of this machine's interface addresses, an error is
170returned and nothing is sent.
2b484d24
A
171(See the
172.Fl i
173flag for another way to do this.)
174.It Fl S
175Print a summary of how many probes were not answered for each hop.
b7080c8e
A
176.It Fl t Ar tos
177Set the
178.Em type-of-service
179in probe packets to the following value (default zero). The value must be
180a decimal integer in the range 0 to 255. This option can be used to
181see if different types-of-service result in different paths. (If you
182are not running a
2b484d24 183.Bx 4.4
b7080c8e
A
184or later system, this may be academic since the normal network
185services like telnet and ftp don't let you control the
186.Dv TOS ) .
187Not all values of
188.Dv TOS
189are legal or
190meaningful \- see the IP spec for definitions. Useful values are
191probably
192.Ql \-t 16
193(low delay) and
194.Ql \-t 8
195(high throughput).
196.It Fl v
197Verbose output. Received
198.Tn ICMP
199packets other than
200.Dv TIME_EXCEEDED
201and
202.Dv UNREACHABLE Ns s
203are listed.
204.It Fl w
2b484d24
A
205Set the time (in seconds) to wait for a response to a probe (default 5 sec.).
206.It Fl x
9c859447
A
207Toggle IP checksums. Normally, this prevents
208.Nm
209from calculating
2b484d24
A
210IP checksums. In some cases, the operating system can overwrite parts of
211the outgoing packet but not recalculate the checksum (so in some cases
212the default is to not calculate checksums and using
213.Fl x
214causes them to be calculated). Note that checksums are usually required
215for the last hop when using
216.Tn ICMP
217ECHO probes (
218.Fl I
219). So they are always calculated when using ICMP.
220.It Fl z Ar pausemsecs
221Set the time (in milliseconds) to pause between probes (default 0).
222Some systems such as Solaris and routers such as Ciscos rate limit
223ICMP messages. A good value to use with this this is 500 (e.g. 1/2 second).
b7080c8e
A
224.El
225.Pp
226This program attempts to trace the route an IP packet would follow to some
227internet host by launching
228.Tn UDP
229probe
230packets with a small ttl (time to live) then listening for an
231.Tn ICMP
232"time exceeded" reply from a gateway. We start our probes
233with a ttl of one and increase by one until we get an
234.Tn ICMP
235"port unreachable"
236(which means we got to "host") or hit a max (which
2b484d24
A
237defaults to
238.Em net.inet.ip.ttl
239hops & can be changed with the
b7080c8e
A
240.Fl m
241flag). Three
242probes (changed with
243.Fl q
244flag) are sent at each ttl setting and a
245line is printed showing the ttl, address of the gateway and
246round trip time of each probe. If the probe answers come from
247different gateways, the address of each responding system will
2b484d24 248be printed. If there is no response within a 5 sec. timeout
b7080c8e
A
249interval (changed with the
250.Fl w
251flag), a "*" is printed for that
252probe.
253.Pp
254We don't want the destination
255host to process the
256.Tn UDP
257probe packets so the destination port is set to an
258unlikely value (if some clod on the destination is using that
259value, it can be changed with the
260.Fl p
261flag).
262.Pp
263A sample use and output might be:
264.Bd -literal
265[yak 71]% traceroute nis.nsf.net.
2b484d24 266traceroute to nis.nsf.net (35.1.1.48), 64 hops max, 38 byte packet
b7080c8e
A
2671 helios.ee.lbl.gov (128.3.112.1) 19 ms 19 ms 0 ms
2682 lilac-dmc.Berkeley.EDU (128.32.216.1) 39 ms 39 ms 19 ms
2693 lilac-dmc.Berkeley.EDU (128.32.216.1) 39 ms 39 ms 19 ms
2704 ccngw-ner-cc.Berkeley.EDU (128.32.136.23) 39 ms 40 ms 39 ms
2715 ccn-nerif22.Berkeley.EDU (128.32.168.22) 39 ms 39 ms 39 ms
2726 128.32.197.4 (128.32.197.4) 40 ms 59 ms 59 ms
2737 131.119.2.5 (131.119.2.5) 59 ms 59 ms 59 ms
2748 129.140.70.13 (129.140.70.13) 99 ms 99 ms 80 ms
2759 129.140.71.6 (129.140.71.6) 139 ms 239 ms 319 ms
27610 129.140.81.7 (129.140.81.7) 220 ms 199 ms 199 ms
27711 nic.merit.edu (35.1.1.48) 239 ms 239 ms 239 ms
278
279.Ed
280Note that lines 2 & 3 are the same. This is due to a buggy
281kernel on the 2nd hop system \- lbl-csam.arpa \- that forwards
282packets with a zero ttl (a bug in the distributed version
283of 4.3
284.Tn BSD ) .
285Note that you have to guess what path
286the packets are taking cross-country since the
287.Tn NSFNet
288(129.140)
289doesn't supply address-to-name translations for its
290.Tn NSS Ns es .
291.Pp
292A more interesting example is:
293.Bd -literal
294[yak 72]% traceroute allspice.lcs.mit.edu.
2b484d24 295traceroute to allspice.lcs.mit.edu (18.26.0.115), 64 hops max
b7080c8e
A
2961 helios.ee.lbl.gov (128.3.112.1) 0 ms 0 ms 0 ms
2972 lilac-dmc.Berkeley.EDU (128.32.216.1) 19 ms 19 ms 19 ms
2983 lilac-dmc.Berkeley.EDU (128.32.216.1) 39 ms 19 ms 19 ms
2994 ccngw-ner-cc.Berkeley.EDU (128.32.136.23) 19 ms 39 ms 39 ms
3005 ccn-nerif22.Berkeley.EDU (128.32.168.22) 20 ms 39 ms 39 ms
3016 128.32.197.4 (128.32.197.4) 59 ms 119 ms 39 ms
3027 131.119.2.5 (131.119.2.5) 59 ms 59 ms 39 ms
3038 129.140.70.13 (129.140.70.13) 80 ms 79 ms 99 ms
3049 129.140.71.6 (129.140.71.6) 139 ms 139 ms 159 ms
30510 129.140.81.7 (129.140.81.7) 199 ms 180 ms 300 ms
30611 129.140.72.17 (129.140.72.17) 300 ms 239 ms 239 ms
30712 * * *
30813 128.121.54.72 (128.121.54.72) 259 ms 499 ms 279 ms
30914 * * *
31015 * * *
31116 * * *
31217 * * *
31318 ALLSPICE.LCS.MIT.EDU (18.26.0.115) 339 ms 279 ms 279 ms
314
315.Ed
316Note that the gateways 12, 14, 15, 16 & 17 hops away
317either don't send
318.Tn ICMP
319"time exceeded" messages or send them
320with a ttl too small to reach us. 14 \- 17 are running the
321.Tn MIT
322C Gateway code that doesn't send "time exceeded"s. God
323only knows what's going on with 12.
324.Pp
325The silent gateway 12 in the above may be the result of a bug in
326the 4.[23]
327.Tn BSD
328network code (and its derivatives): 4.x (x <= 3)
329sends an unreachable message using whatever ttl remains in the
330original datagram. Since, for gateways, the remaining ttl is
331zero, the
332.Tn ICMP
333"time exceeded" is guaranteed to not make it back
334to us. The behavior of this bug is slightly more interesting
335when it appears on the destination system:
336.Bd -literal
3371 helios.ee.lbl.gov (128.3.112.1) 0 ms 0 ms 0 ms
3382 lilac-dmc.Berkeley.EDU (128.32.216.1) 39 ms 19 ms 39 ms
3393 lilac-dmc.Berkeley.EDU (128.32.216.1) 19 ms 39 ms 19 ms
3404 ccngw-ner-cc.Berkeley.EDU (128.32.136.23) 39 ms 40 ms 19 ms
3415 ccn-nerif35.Berkeley.EDU (128.32.168.35) 39 ms 39 ms 39 ms
3426 csgw.Berkeley.EDU (128.32.133.254) 39 ms 59 ms 39 ms
3437 * * *
3448 * * *
3459 * * *
34610 * * *
34711 * * *
34812 * * *
34913 rip.Berkeley.EDU (128.32.131.22) 59 ms ! 39 ms ! 39 ms !
350
351.Ed
352Notice that there are 12 "gateways" (13 is the final
353destination) and exactly the last half of them are "missing".
354What's really happening is that rip (a Sun-3 running Sun OS3.5)
355is using the ttl from our arriving datagram as the ttl in its
356.Tn ICMP
357reply. So, the reply will time out on the return path
358(with no notice sent to anyone since
359.Tn ICMP's
360aren't sent for
361.Tn ICMP's )
362until we probe with a ttl that's at least twice the path
363length. I.e., rip is really only 7 hops away. A reply that
364returns with a ttl of 1 is a clue this problem exists.
9c859447 365.Nm
b7080c8e
A
366prints a "!" after the time if the ttl is <= 1.
367Since vendors ship a lot of obsolete
368.Pf ( Tn DEC Ns \'s
369Ultrix, Sun 3.x) or
370non-standard
371.Pq Tn HPUX
372software, expect to see this problem
373frequently and/or take care picking the target host of your
374probes.
2b484d24 375.Pp
b7080c8e
A
376Other possible annotations after the time are
377.Sy !H ,
378.Sy !N ,
2b484d24 379or
b7080c8e 380.Sy !P
2b484d24 381(host, network or protocol unreachable),
b7080c8e 382.Sy !S
2b484d24 383(source route failed),
9c859447 384.B !F\-<pmtu>
2b484d24 385(fragmentation needed \- the RFC1191 Path MTU Discovery value is displayed),
9c859447
A
386.Sy !U
387or
388.Sy !W
389(destination network/host unknown),
390.Sy !I
391(source host is isolated),
392.Sy !A
393(communication with destination network administratively prohibited),
394.Sy !Z
395(communication with destination host administratively prohibited),
396.Sy !Q
397(for this ToS the destination network is unreachable),
398.Sy !T
399(for this ToS the destination host is unreachable),
2b484d24
A
400.Sy !X
401(communication administratively prohibited),
402.Sy !V
403(host precedence violation),
404.Sy !C
405(precedence cutoff in effect), or
406.Sy !<num>
407(ICMP unreachable code <num>).
408These are defined by RFC1812 (which supersedes RFC1716).
9c859447
A
409If almost all the probes result in some kind of unreachable,
410.Nm
b7080c8e
A
411will give up and exit.
412.Pp
413This program is intended for use in network testing, measurement
414and management.
415It should be used primarily for manual fault isolation.
416Because of the load it could impose on the network, it is unwise to use
9c859447 417.Nm
b7080c8e
A
418during normal operations or from automated scripts.
419.Sh AUTHOR
420Implemented by Van Jacobson from a suggestion by Steve Deering. Debugged
421by a cast of thousands with particularly cogent suggestions or fixes from
422C. Philip Wood, Tim Seaver and Ken Adelman.
423.Sh SEE ALSO
424.Xr netstat 1 ,
fdfd5971
A
425.Xr ping 8 ,
426.Xr traceroute6 8
2b484d24
A
427.Sh BUGS
428When using protocols other than UDP, functionality is reduced.
429In particular, the last packet will often appear to be lost, because
430even though it reaches the destination host, there's no way to know
431that because no ICMP message is sent back.
432In the TCP case,
b7080c8e 433.Nm
2b484d24
A
434should listen for a RST from the destination host (or an intermediate
435router that's filtering packets), but this is not implemented yet.
9c859447
A
436.Pp
437The AS number capability reports information that may sometimes be
438inaccurate due to discrepancies between the contents of the
439routing database server and the current state of the Internet.