TRACEROUTE(1)
๐ซ TRACEROUTE(1) ๐ซ
okay bestie, welcome to the Traceroute For Linux manual page ๐ this is the whole vibe, all three parts, no skips, no cap.
๐ธ NAME ๐ธ
traceroute โ print the route packets trace to network host โจ
๐ฆ SYNOPSIS ๐ฆ
traceroute [-46dFITUnreAV] [-f first_ttl] [-g gate,...]
[-i device] [-m max_ttl] [-p port] [-s src_addr]
[-q nqueries] [-N squeries] [-t tos]
[-l flow_label] [-w waittimes] [-z sendwait] [-UL] [-D]
[-P proto] [--sport=port] [-M method] [-O mod_options]
[--mtu] [--back]
host [packet_len]
traceroute6 [options]
tcptraceroute [options]
lft [options]
โจ DESCRIPTION โจ
so traceroute tracks the route that packets take from an IP network on their lil journey to a given host. the way it does this is iconic actually: it uses the IP protocol's time to live (TTL) field and tries to get an ICMP TIME_EXCEEDED response out of every gateway along the path to the host. ๐
traceroute6 is literally the same thing as traceroute -6 ๐
tcptraceroute is equivalent to traceroute -T โจ
lft, the Layer Four Traceroute, does a TCP traceroute, like traceroute -T, but it attempts to be compatible with the original implementation of that same thing, which is also called "lft". bestie behavior honestly ๐ซถ
The only required parameter is the name or IP address of the destination host. The optional packet_len gth is the total size of the probing packet (default 60 bytes for IPv4 and 80 for IPv6). ngl, the size you specify can get ignored in some situations, or it can be increased up to a minimal value. ๐
This program attempts to trace the route an IP packet would follow to some internet host by launching probe packets with a small ttl (time to live) and then listening for an ICMP "time exceeded" reply from a gateway. We start our probes with a ttl of one and increase by one until we get an ICMP "port unreachable" (or a TCP reset), which means we got to the "host", or we hit a max (which defaults to 30 hops). Three probes (by default) are sent at each ttl setting, and a line gets printed showing the ttl, the address of the gateway, and the round trip time of each probe. The address can be followed by additional information when requested. If the probe answers come from different gateways, the address of each responding system will be printed. And if there's no response within a certain timeout, an * (asterisk) is printed for that probe. no response, no problem, just a lil star โญ
After the trip time, some additional annotation can be printed: !H, !N, or !P (host, network or protocol unreachable), !S (source route failed), !F (fragmentation needed), !X (communication administratively prohibited), !V (host precedence violation), !C (precedence cutoff in effect), or !<num> (ICMP unreachable code <num>). If almost all the probes result in some kind of unreachable, traceroute will give up and exit. ๐ญ like okay fine, we get it, it's unreachable.
We do not 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 -p flag). There's no such problem for ICMP or TCP tracerouting (for TCP we use the half-open technique, which prevents our probes from being seen by applications on the destination host). sneaky but make it legal ๐
In the modern network environment the traditional traceroute methods can't always be applicable, because of the 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 LIST OF AVAILABLE METHODS below. Such methods try to use a particular protocol and source/destination port, in order to bypass firewalls (to be seen by firewalls just as a start of an allowed type of a network session). it's giving โจ*disguise*โจ, and honestly? iconic. ๐ง
โจ OPTIONS โจ
okay bestie, this is the part where it gets GOOD. every single knob you can twist, no cap ๐
--helpโ prints the help info and then dips. that's it, that's the whole job ๐-4,-6โ force IPv4 or IPv6 tracerouting, explicitly, no debating. by default the program tries to resolve the name you gave it and picks the right protocol on its own. BUT heads up: if resolving a host name hands back both IPv4 and IPv6 addresses, traceroute goes with IPv4. every time. โจ-I,--icmpโ use ICMP ECHO for probes-T,--tcpโ use TCP SYN for probes-d,--debugโ turn on socket level debugging (only when the Linux kernel supports it, so don't come for me if it doesn't ๐ซถ)-F,--dont-fragmentโ do not fragment the probe packets. (for IPv4 it also sets the DF bit, which tells intermediate routers not to fragment remotely either).
so here's the tea: by varying the size of the probing packet with the packet_len command line parameter, you can manually get info about the MTU of individual network hops. the --mtu option (down below ๐) tries to do that automatically.
note that non-fragmented features (like-For--mtu) only work properly since the Linux kernel2.6.22. before that version, IPv6 was always fragmented, and IPv4 could only use the once-discovered final mtu (from the route cache), which can be less than the actual mtu of a device. ancient behaviour, we don't stan ๐ญ
-f first_ttl,--first=first_ttlโ specifies with what TTL to start. defaults to1.-g gateway,--gateway=gatewayโ tells traceroute to add an IP source routing option to the outgoing packet that tells the network to route the packet through the specified gateway (most routers have disabled source routing for security reasons, so lowkey expect this to get ignored ๐ซ). in general, several gateway's is allowed (comma separated). for IPv6, the form ofnum,addr,addr...is allowed, wherenumis a route header type (default is type2). note the type0route header is now deprecated (rfc5095).-i interface,--interface=interfaceโ specifies the interface through which traceroute should send packets. by default, the interface is selected according to the routing table.-m max_ttl,--max-hops=max_ttlโ specifies the maximum number of hops (max time-to-live value) traceroute will probe. the default is30.-N squeries,--sim-queries=squeriesโ specifies the number of probe packets sent out simultaneously. sending several probes concurrently can speed up traceroute considerably, it's giving efficiency ๐จ. the default value is16.
note that some routers and hosts can use ICMP rate throttling. in such a situation, specifying too large a number can lead to loss of some responses. so likeโฆ don't be greedy ๐
-nโ do not try to map IP addresses to host names when displaying them. raw numbers only, no DNS glow-up.-p port,--port=portโ multi-purpose icon, let's break it down:- for UDP tracing: specifies the destination port base traceroute will use (the destination port number will be incremented by each probe).
- for ICMP tracing: specifies the initial ICMP sequence value (incremented by each probe too).
- for TCP and others: specifies just the (constant) destination port to connect.
- when using the
tcptraceroutewrapper,-pspecifies the source port.
-t tos,--tos=tosโ for IPv4, set the Type of Service (TOS) and Precedence value. useful values are16(low delay) and8(high throughput). note that in order to use some TOS precedence values, you have to be super user ๐. for IPv6, set the Traffic Control value.-l flow_label,--flowlabel=flow_labelโ use specifiedflow_labelfor IPv6 packets.-w max[,here,near],--wait=max[,here,near]โ determines how long to wait for a response to a probe. this one's a whole saga so stay with me ๐:
there are three (in general) float values separated by a comma (or a slash). max specifies the maximum time (in seconds, default 5.0) to wait, in any case.
the traditional traceroute implementation always waited the whole max seconds for any probe. but if we already have some replies from the same hop, or even from some next hop, we can use the round trip time of such a reply as a hint to determine the actual reasonable amount of time to wait. smart, right? main character energy ๐ง โจ
the optional here (default 3.0) specifies a factor to multiply the round trip time of an already received response from the same hop. the resulting value is used as a timeout for the probe, instead of (but no more than) max. the optional near (default 10.0) specifies a similar factor for a response from some next hop. (the time of the first found result is used in both cases).
first, we look for the same hop (of the probe which will be printed first from now). if nothing found, then look for some next hop. if nothing found, use max. if here and/or near have zero values, the corresponding computation is skipped. here and near are always set to zero if only max is specified (for compatibility with previous versions โ yes, we're being polite to the elders ๐ซถ).
-q nqueries,--queries=nqueriesโ sets the number of probe packets per hop. the default is3.-rโ bypass the normal routing tables and send directly to a host on an attached network. if the host is not on a directly-attached network, an error is returned. this option can be used to ping a local host through an interface that has no route through it. sneaky but valid ๐-s source_addr,--source=source_addrโ chooses an alternative source address. note that you must select the address of one of the interfaces. by default, the address of the outgoing interface is used.-z sendwait,--sendwait=sendwaitโ minimal time interval between probes (default0). if the value is more than10, 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. be patient bestie, it pays off ๐-e,--extensionsโ show ICMP extensions (rfc4884). the general form isCLASS/TYPE:followed by a hexadecimal dump. the MPLS (rfc4950) is shown parsed, in a form:MPLS:L=label,E=exp_use,S=stack_bottom,T=TTL(more objects separated by/). the Interface Information (rfc5837) is shown parsed as well, in a following form:{INC|SUB|OUT|NXT}:index,IP_addr,"name",mtu=MTU(all four fields may be missing). yes, that's a lot of brackets. it's giving protocol archaeology ๐-A,--as-path-lookupsโ perform AS path lookups in routing registries and print results directly after the corresponding addresses.-V,--versionโ print the version and exit.
there are additional options intended for advanced usage (such as alternate trace methods etc.), and honestly? this is where the real ones live ๐:
--sport=portโ chooses the source port to use. implies-N 1 -w 5. normally source ports (if applicable) are chosen by the system.--fwmark=markโ set the firewall mark for outgoing packets (since the Linux kernel2.6.25).-M method,--module=nameโ use specified method for traceroute operations. the default traditional udp method has namedefault, icmp (-I) and tcp (-T) have namesicmpandtcprespectively. method-specific options can be passed by-O. most methods have their simple shortcuts (-Imeans-M icmp, etc). pick your fighter ๐-O option,--options=optionsโ specifies some method-specific option. several options are separated by comma (or use several-Oon cmdline). each method may have its own specific options, or many not have them at all. to print information about available options, use-O help. ๐ literally just ask it, it'll tell you-U,--udpโ use UDP to particular destination port for tracerouting (instead of increasing the port per each probe). default port is53(dns).-ULโ use UDPLITE for tracerouting (default port is53).-D,--dccpโ use DCCP Requests for probes.-P protocol,--protocol=protocolโ use raw packet of specified protocol for tracerouting. default protocol is253(rfc3692).--mtuโ discover MTU along the path being traced. implies-F -N 1. new mtu is printed once in a form ofF=NUMat the first probe of a hop which requires such mtu to be reached. (actually, the correspond "frag needed" icmp message normally is sent by the previous hop). note that some routers might cache once the seen information on a fragmentation. thus you can receive the final mtu from a closer hop. try to specify an unusual tos by-t, this can help for one attempt (then it can be cached there as well). see-Foption for more info.--backโ print the number of backward hops when it seems different with the forward direction. this number is guessed in assumption that remote hops send reply packets with initial ttl set to either64, or128or255(which seems a common practice). it is printed as a negate value in a form of'-NUM'.
๐ LIST OF AVAILABLE METHODS ๐
Okay so bestie, here's the tea โ โ in general, a particular traceroute method may have to be chosen by -M name, but most of the methods have their simple cmdline switches (you'll see them right after the method name, if they got one). Let's go method by method ๐
โจ default โจ
The traditional, ancient method of tracerouting. Used by default โ no flags, no drama, it just happens.
Probe packets are udp datagrams with so-called "unlikely" destination ports. The "unlikely" port of the first probe is 33434, then for each next probe it 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 ๐ โ not our problem, not our business).
This method is allowed for unprivileged users ๐ซถ
๐ธ icmp ๐ธ -I
The most usual method for now, which uses icmp echo packets for probes. If you can ping(8) the destination host, icmp tracerouting is applicable as well. It's giving "if you can ping it, you can trace it" โจ
This method may be allowed for unprivileged users since the kernel 3.0 (IPv4, for IPv6 since 3.11), which supports new dgram icmp (or "ping") sockets. To allow such sockets, sysadmin should provide net/ipv4/ping_group_range sysctl range to match any group of the user. Yes bestie, you gotta go beg your sysadmin for that one ๐
Options:
rawโ Use only raw sockets (the traditional way). This way is tried first by default (for compatibility reasons), then new dgram icmp sockets as fallback.dgramโ Use only dgram icmp sockets.
๐ฅ tcp ๐ฅ -T
Well-known modern method, intended to bypass firewalls. Uses the constant destination port (default is 80, http). The firewall-evasion main character energy we all deserve ๐
If some filters are present in the network path, then most probably any "unlikely" udp ports (as for default method) or even icmp echoes (as for 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/port combinations. If we trace for some, say, mailserver, then more likely -T -p 25 can reach it, even when -I can not. Sneaky but make it legal ๐
This method uses well-known "half-open technique", which prevents applications 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, but answer by tcp reset (instead of expected tcp ack), this way the remote tcp session is dropped even without the application ever taking notice. The remote app literally never finds out. Iconic behaviour, no cap ๐
There is a couple of options for tcp method:
syn,ack,fin,rst,psh,urg,ece,cwrโ Sets specified tcp flags for probe packet, in any combination.flags=numโ Sets the flags field in the tcp header exactly to num.ecnโ Send syn packet with tcp flags ECE and CWR (for Explicit Congestion Notification, rfc3168).sack,timestamps,window_scalingโ Use the corresponding tcp header option in the outgoing probe packet.sysctlโ Use current sysctl (/proc/sys/net/*) setting for the tcp header options above and ecn. Always set by default, if nothing else specified.fastopenโ Use fastopen tcp option (when syn), for initial cookie negotiation only.mss=[num]โ Use value of num (or unchanged) for maxseg tcp header option (when syn), and discover its clamping along the path being traced. New changed mss is printed once in a form ofM=NUMat the first probe on which it was detected. Note, some routers may return too short original fragment in the time exceeded message, making the check impossible. Besides that the responses may come in a different order. All this can lead to a later place of the report (using-N 1can help for the order).infoโ Print tcp flags and supported options of final tcp replies when the target host is reached. Allows to determine whether an application listens the port and other useful things. Supported tcp options are all that can be set by-T -O, ie.mss,sack,timestamps,window_scalingandfastopen, with the similar output format (a value for mss and just presence for others).
Default options is syn,sysctl. โจ
๐ฆ tcpconn ๐ฆ
An initial implementation of tcp method, simple using connect(2) call, which does full tcp session opening. Not recommended for normal use, because a destination application is always affected (and can be confused). Like... it literally touches the app bestie, rude ๐ญ skip it.
๐ udp ๐ -U
Use udp datagram with constant destination port (default 53, dns). Intended to bypass firewall as well.
Note, that unlike in tcp method, the correspond application on the destination host always receive our probes (with random data), and most can easily be confused by them. Most cases it will not respond to our packets though, so we will never see the final hop in the trace. (Fortunately, it seems that at least dns servers replies with something angry ๐ค).
This method is allowed for unprivileged users ๐ซถ
๐ udplite ๐ -UL
Use udplite datagram for probes (with constant destination port, default 53).
This method is allowed for unprivileged users.
Options:
coverage=numโ Set udplite send coverage to num.
๐ dccp ๐ -D
Use DCCP Request packets for probes (rfc4340).
This method uses the same "half-open technique" as used for TCP. The default destination port is 33434.
Options:
service=numโ Set DCCP service code to num (default is1885957735).
๐ raw ๐ -P proto
Send raw packet of protocol proto. No protocol-specific headers are used, just IP header only. Implies -N 1 -w 5 .
Options:
protocol=protoโ Use IP protocol proto (default253).
๐ NOTES ๐
To speed up work, normally several probes are sent simultaneously. On the other hand, it creates a "storm of packages", especially in the reply direction. Routers can throttle the rate of icmp responses, and some of replies can be lost. To avoid this, decrease the number of simultaneous probes, or even set it to 1 (like in initial traceroute implementation), i.e. -N 1. Chill vibes only, one probe at a time ๐งโโ๏ธ
The 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 algorithm to auto-detect such a situation, but if it cannot help in your case, just use -N 1 too. She's smart but she's not a miracle worker, bestie ๐
For even greater stability you can slow down the program's work by -z option, for example use -z 0.5 for half-second pause between probes. Slow and steady wins the trace ๐ข
To avoid an extra waiting, we use adaptive algorithm for timeouts (see -w option for more info). It can lead to premature expiry (especially when response times differ at times) and printing "*" instead of a time. In such a case, switch this algorithm off, by specifying -w with the desired timeout only (for example, -w 5). Don't let the algorithm gaslight you into thinking nothing came back ๐
If some hops report nothing for every method, the last chance to obtain something is to use ping -R command (IPv4, and for nearest 8 hops only). Last resort era, but it's something ๐
โญ SEE ALSO โญ
ping(8), ping6(8), tcpdump(8), netstat(8)
And that's a wrap on the whole page, bestie ๐ this one's Traceroute, dated 11 October 2006, living in section TRACEROUTE(1) of the manual. Go forth and trace responsibly, mwah ๐โจ
๐ฆ where this page comes from
- debian trixie: traceroute 1:2.1.6-1 ยท GPL-2.0-or-later
- ubuntu noble: traceroute 1:2.1.5-1 ยท GPL-2.0-or-later
- ubuntu questing: traceroute 1:2.1.6-1
- ubuntu resolute: traceroute 1:2.1.6-1build1 ยท GPL-2.0-or-later
- ubuntu stonking: traceroute 1:2.1.6-1build1 ยท GPL-2.0-or-later
- Copyright (c) 2006 Dmitry Butskoy (dmitry@butskoy.name)
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms