📄 traceroute.8
字号:
.\" Copyright (c) 2006 Dmitry Butskoy (dmitry@butskoy.name).\" License: GPL v2 or any later version.\" See COPYING for the status of this software.TH TRACEROUTE 8 "11 October 2006" "Traceroute" "Traceroute For Linux".\" .UC 6.SH NAMEtraceroute \- print the route packets trace to network host.SH SYNOPSIS.na.BR traceroute " [" \-46dFITUnreAV "] [" "\-f first_ttl" "] [" "\-g gate,..." ].br.ti +8.BR "" [ "-i device" "] [" "-m max_ttl" "] [" "-p port" "] [" "-s src_addr" ].br.ti +8.BR "" [ "-q nqueries" "] [" "-N squeries" "] [" "-t tos" ].br.ti +8.BR "" [ "-l flow_label" "] [" "-w waittime" "] [" "-z sendwait" ].br.ti +8.BR "" [ "-UL" "] [" "-P proto" "] [" "--sport=port" "] [" "-M method" "] [" "-O mod_options" ].br.ti +8.BR "" [ "--mtu" "] [" "--back" ].br.ti +8.BR host " [" "packet_len" "]".br.BR traceroute6.RI " [" options ].ad.SH DESCRIPTION.I traceroutetracks the route packets taken from an IP network on theirway to a given host. It utilizes the IP protocol's time to live (TTL) fieldand attempts to elicit an ICMP TIME_EXCEEDED response from each gatewayalong the path to the host..P.I traceroute6is equivalent to.I traceroute.B \-6.PPThe only required parameter is the name or IP address of thedestination.BR host \ .The optional.B packet_len\fR`gthis the total size of the probing packet (default 60 bytesfor IPv4 and 80 for IPv6). The specified size can be ignoredin some situations or increased up to a minimal value..PPThis program attempts to trace the route an IP packet would follow to someinternet host by launching probepackets with a small ttl (time to live) then listening for anICMP "time exceeded" reply from a gateway. We start our probeswith a ttl of one and increase by one until we get an ICMP "portunreachable" (or TCP reset), which means we got to the "host", or hit a max (whichdefaults to 30 hops). Three probes (by default) are sent at each ttl settingand a line is printed showing the ttl, address of the gateway andround trip time of each probe. The address can be followed by additionalinformation when requested. If the probe answers come fromdifferent gateways, the address of each responding system willbe printed. If there is no response within a 5.0 seconds (default),an "*" is printed for that probe..PPAfter the trip time, some additional annotation can be printed:.BR !H ,.BR !N ,or.B !P(host, network or protocol unreachable),.B !S(source route failed),.B !F(fragmentation needed),.B !X(communication administratively prohibited),.B !V(host precedence violation),.B !C(precedence cutoff in effect), or.B !<num>(ICMP unreachable code <num>).If almost all the probes result in some kind of unreachable, traceroutewill give up and exit..PPWe don't want the destination host to process the UDP probe packets,so the destination port is set to an unlikely value (you can change it with the.B \-pflag). There is no such a problem for ICMP or TCP tracerouting (for TCP weuse half-open technique, which prevents our probes to be seen by applicationson the destination host)..PPIn the modern network environment the traditional traceroute methodscan not be always applicable, because of widespread use of firewalls.Such firewalls filter the "unlikely" UDP ports, or even ICMP echoes.To solve this, some additional tracerouting methods are implemented(including tcp), see.B LIST OF AVAILABLE METHODSbelow. Such methods try to use particular protocoland source/destination port, in order to bypass firewalls (to be seenby firewalls just as a start of allowed type of a network session)..SH OPTIONS.TP.BI \--helpPrint help info and exit..TP.BR \-4 ", " \-6Explicitly force IPv4 or IPv6 traceouting. By default, the programwill try to resolve the name given, and choose the appropriateprotocol automatically. If resolving a host name returns bothIPv4 and IPv6 addresses,.I traceroutewill use IPv4..TP.B \-IUse ICMP ECHO for probes.TP.B \-TUse TCP SYN for probes.TP.B \-dEnable socket level debugging (when the Linux kernel supports it).TP.B \-FDo not fragment probe packets. (For IPv4 it also sets DF bit, which tellsintermediate routers not to fragment remotely as well)..br.brVarying the size of the probing packet by the.B packet_lencommand line parameter, you can manually obtain informationabout the MTU of individual network hops. The.B \--mtuoption (see below) tries to do this automatically..br.brNote, that non-fragmented features (like.B \-For.B \--mtu\fR)work properly since the Linux kernel 2.6.22 only.Before that version, IPv6 was always fragmented, IPv4 could usethe once the discovered final mtu only (from the route cache), which can beless than the actual mtu of a device..TP.BI \-f " first_ttlSpecifies with what TTL to start. Defaults to 1..TP.BI \-g " gatewayTells traceroute to add an IP source routing option to the outgoingpacket that tells the network to route the packet through thespecified.IR gateway .Not very useful, because most routers have disabled source routingfor security reasons..TP.BI \-i " interfaceSpecifies the interface through which.I tracerouteshould send packets. By default, the interface is selectedaccording to the routing table..TP.BI \-m " max_ttlSpecifies the maximum number of hops (max time-to-live value).I traceroutewill probe. The default is 30..TP.BI \-N " squeriesSpecifies the number of probe packets sent out simultaneously.Sending several probes concurrently can speed up.I tracerouteconsiderably. The default value is 16..brNote that some routers and hosts can use ICMP rate throttling. In sucha situation specifying too large number can lead to loss of some responses..TP.BI \-nDo not try to map IP addresses to host names when displaying them..TP.BI \-p " portFor UDP tracing, specifies the destination port base.I traceroutewill use (the destination port number will be incremented by each probe)..brFor ICMP tracing, specifies the initial icmp sequence value (incrementedby each probe too)..brFor TCP specifies just the (constant) destinationport to connect..TP.BI \-t " tosFor IPv4, set the Type of Service (TOS) and Precedence value. Useful valuesare 16 (low delay) and 8 (high throughput). Note that in order to usesome TOS precendence values, you have to be super user..brFor IPv6, set the Traffic Control value..TP.BI \-w " waittimeSet the time (in seconds) to wait for a response to a probe (default 5.0 sec)..TP.BI \-q " nqueriesSets the number of probe packets per hop. The default is 3..TP.BI \-rBypass the normal routing tables and send directly to a host onan attached network. If the host is not on a directly-attachednetwork, an error is returned. This option can be used to ping alocal host through an interface that has no route through it..TP.BI \-s " source_addrChooses an alternative source address. Note that you must select theaddress of one of the interfaces.By default, the address of the outgoing interface is used..TP.BI \-z " sendwaitMinimal time interval between probes (default 0).If the value is more than 10, then it specifies a number in milliseconds,else it is a number of seconds (float point values allowed too).Useful when some routers use rate-limit for icmp messages..TP.BI \-eShow ICMP extensions (rfc4884). The general form is.I CLASS\fB/\fITYPE\fB:followed by a hexadecimal dump.The MPLS (rfc4950) is shown parsed, in a form:.B MPLS:L=\fIlabel\fB,E=\fIexp_use\fB,S=\fIstack_bottom\fB,T=\fITTL(more objects separated by.B /)..TP.BI \-APerform AS path lookups in routing registries and print resultsdirectly after the corresponding addresses..TP.BI \-VPrint the version and exit..br.PThere is a couple of additional options, intended for an advanced usage(another trace methods etc.):.TP.B \--sport\fR=\fIportChooses the source port to use. Implies.BR \-N\ 1 .Normally source ports (if applicable) are chosen by the system..TP.BI \-M " methodUse specified method for traceroute operations. Default traditional udp methodhas name.IR default ,icmp.BR "" ( "-I" ) "and tcp.BR "" ( "-T" ) "have names.I icmpand.I tcprespectively..brMethod-specific options can be passed by.BR \-O\ .Most methods have their simple shortcuts,.BR "" ( "-I " means " -M icmp" ,etc)..TP.BI \-O " optionSpecifies some method-specific option. Several options are separated by comma (or use several.B \-Oon cmdline).Each method may have its own specific options, or many not have them at all.To print information about available options, use.BR \-O\ help ..TP.BI \-UUse UDP to particular destination port for tracerouting (instead of increasingthe port per each probe). Default port is 53 (dns)..TP.BI \-ULUse UDPLITE for tracerouting (default port is 53)..TP.BI \-P " protocolUse raw packet of specified protocol for tracerouting. Default protocol is253 (rfc3692)..TP.BI \--mtuDiscover MTU along the path being traced. Implies.BR \-F\ \-N\ 1 .New.I mtuis printed once in a form of.B F=\fINUMat the first probe of a hop which requires such.I mtuto be reached. (Actually, the correspond "frag needed" icmp messagenormally is sent by the previous hop)..br.brNote, that some routers might cache once the seen informationon a fragmentation. Thus you can receive the final mtu from a closer hop.Try to specify an unusual.I tosby.B \-t, this can help for one attempt (then it can be cached there as well)..brSee.B \-Foption for more info..TP.BI \--backPrint the number of backward hops when it seems different with the forwarddirection. This number is guessed in assumption that remote hops send replypackets with initial ttl set to either 64, or 128 or 255 (which seemsa common practice). It is printed as a negate value in a form of '-NUM' ..SH LIST OF AVAILABLE METHODSIn general, a particular traceroute method may have to be chosen by.BR \-M\ name ,but most of the methods have their simple cmdline switches(you can see them after the method name, if present)..SS defaultThe traditional, ancient method of tracerouting. Used by default..PProbe packets are udp datagrams with so-called "unlikely" destination ports.The "unlikely" port of the first probe is 33434, then for each next probeit is incremented by one. Since the ports are expected to be unused,the destination host normally returns "icmp unreach port" as a final response.(Nobody knows what happens when some application listens for such ports,though)..PThis method is allowed for unprivileged users..SS icmp \ \ \ \-IMost usual method for now, which uses icmp echo packets for probes..brIf you can ping(8) the destination host, icmp tracerouting is applicableas well..SS tcp \ \ \ \ \-TWell-known modern method, intended to bypass firewalls..brUses the constant destination port (default is 80, http)..PIf some filters are present in the network path, then most probablyany "unlikely" udp ports (as for.I defaultmethod) or even icmp echoes (as for.IR icmp )are filtered, and whole tracerouting will just stop at such a firewall.To bypass a network filter, we have to use only allowed protocol/portcombinations. If we trace for some, say, mailserver, then more likely.B \-T \-p 25can reach it, even when.B \-Ican not..PThis method uses well-known "half-open technique", which preventsapplications on the destination host from seeing our probes at all.Normally, a tcp syn is sent. For non-listened ports we receive tcp reset,and all is done. For active listening ports we receive tcp syn+ack, butanswer by tcp reset (instead of expected tcp ack), this way the remote tcpsession is dropped even without the application ever taking notice..PThere is a couple of options for.I tcpmethod:.TP.B syn,ack,fin,rst,psh,urg,ece,cwrSets specified tcp flags for probe packet, in any combination..TP.B flags\fR=\fInumSets the flags field in the tcp header exactly to.IR num ..TP.B ecnSend syn packet with tcp flags ECE and CWR (for Explicit CongestionNotification, rfc3168).TP.B sack,timestamps,window_scalingUse the corresponding tcp header option in the outgoing probe packet..TP.B sysctlUse current sysctl.IR "" ( "/proc/sys/net/*" )setting for the tcp header options above and.BR ecn .Always set by default, if nothing else specified..TP.B mss\fR=\fInumUse value of.I numfor maxseg tcp header option (when.BR syn )..PDefault options is.BR syn,sysctl ..SS tcpconnAn initial implementation of tcp method, simple using connect(2) call,which does full tcp session opening. Not recommended for normal use, becausea destination application is always affected (and can be confused)..SS udp \ \ \ \ \-UUse udp datagram with constant destination port (default 53, dns)..brIntended to bypass firewall as well. .PNote, that unlike in.I tcpmethod, the correspond application on the destination host.B alwaysreceive our probes (with random data), and most can easily be confusedby them. Most cases it will not respond to our packets though, so we will neversee the final hop in the trace. (Fortunately, it seems that at leastdns servers replies with something angry)..PThis method is allowed for unprivileged users..SS udplite \ \ \-ULUse udplite datagram for probes (with constant destination port,default 53)..PThis method is allowed for unprivileged users..brOptions:.TP.B coverage\fR=\fInumSet udplite send coverage to.IR num ..SS raw \ \ \ \ \-P protoSend raw packet of protocol.IR proto ..brNo protocol-specific headers are used, just IP header only..brImplies.BR \-N\ 1 ..brOptions:.TP.B protocol\fR=\fIprotoUse IP protocol.I proto(default 253)..SH NOTES.PPTo speed up work, normally several probes are sent simultaneously.On the other hand, it creates a "storm of packages", especiallyin the reply direction. Routers can throttle the rate of icmp responses,and some of replies can be lost. To avoid this, decrease the numberof simultaneous probes, or even set it to 1 (like in initial tracerouteimplementation), i.e..B \-N 1.PPThe final (target) host can drop some of the simultaneous probes,and might even answer only the latest ones. It can lead to extra"looks like expired" hops near the final hop. We use a smart algorithmto auto-detect such a situation, but if it cannot help in your case, just use.B \-N 1too..PPFor even greater stability you can slow down the program's work by.B \-zoption, for example use.B \-z 0.5for half-second pause between probes..PPIf some hops report nothing for every method, the last chance to obtainsomething is to use.B ping -Rcommand (IPv4, and for nearest 8 hops only)..SH SEE ALSO.BR ping (8),.BR ping6 (8),.BR tcpdump(8),.BR netstat (8)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -