In Blog, Internet, Network, Security


traceroute – print the route packets trace to network host

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 waittime] [-z sendwait] [-UL] [-D]
[-P proto] [–sport=port] [-M method] [-O mod_options]
[–mtu] [–back]
host [packet_len]
traceroute6  [options]
tcptraceroute  [options]
lft  [options]

traceroute  tracks  the route packets taken from an IP network on their way to a given host. It utilizes the IP protocol’s time to live  (TTL) field  and  attempts to elicit an ICMP TIME_EXCEEDED response from each gateway along the path to the host.

traceroute6 is equivalent to traceroute -6

tcptraceroute is equivalent to traceroute -T

lft , the Layer  Four  Traceroute,  performs  a  TCP  traceroute,  like traceroute -T , but attempts to provide compatibility with the original such implementation, also called “lft”.

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).  The  specified size  can  be  ignored  in some situations or 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) 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 TCP reset), which means we  got  to  the “host”,  or  hit  a  max  (which defaults to 30 hops). Three probes (by default) are sent at each ttl setting and a line is printed showing the ttl,  address  of  the  gateway  and 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.  If there is no  response  within  a 5.0 seconds (default), an “*” (asterisk) is printed for that probe.

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 span <num>).  If almost all the probes result in some kind of unreachable, traceroute will give up  and exit.

We 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  -p flag). There is no such a problem for ICMP or TCP tracer‐ outing (for TCP we use half-open technique, which prevents  our  probes to be seen by applications on the destination host).

In  the  modern  network environment the traditional traceroute methods can 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 LIST OF AVAILABLE METHODS below. Such methods try to use particular protocol and source/destination  port,  in  order  to bypass  firewalls  (to  be seen by firewalls just as a start of allowed type of a network session).

–help Print help info and exit.

-4, -6 Explicitly force IPv4 or IPv6 tracerouting. By default, the program  will  try to resolve the name given, and choose the appropriate protocol automatically. If resolving a host name  returns both IPv4 and IPv6 addresses, traceroute will use IPv4.

-I, –icmp
Use ICMP ECHO for probes

-T, –tcp
Use TCP SYN for probes

-d, –debug
Enable  socket  level  debugging (when the Linux kernel supports

-F, –dont-fragment
Do not fragment probe packets. (For IPv4 it also  sets  DF  bit,
which  tells  intermediate  routers  not to fragment remotely as

Varying the size of the probing packet by the packet_len command line  parameter,  you  can manually obtain information about the MTU of individual network hops. The  –mtu  option  (see  below) tries to do this automatically.

Note, that non-fragmented features (like -F or –mtu) work properly since the Linux kernel 2.6.22 only.  Before  that  version, IPv6  was always fragmented, IPv4 could use the once the discovered final mtu only (from the route cache), which  can  be  less than the actual mtu of a device.

-f first_ttl, –first=first_ttl
Specifies with what TTL to start. Defaults to 1.

-g gateway, –gateway=gateway
Tells  traceroute to add an IP source routing option to the out going packet that tells the network to route the packet  through the specified gateway (most routers have disabled source routing for security reasons).  In general, several gateway’s is allowed (comma  separated).  For  IPv6, the form of num,addr,addr…  is allowed, where num is a route header type (default is  type  2).

Note the type 0 route 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 is 30.

-N squeries, –sim-queries=squeries
Specifies the number of probe packets sent  out  simultaneously.Sending several probes concurrently can speed up traceroute     considerably. The default value is 16.Note that some routers and hosts can use ICMP  rate  throttling.In such a situation specifying too large number can lead to loss of some responses.

-n     Do not try to map IP addresses to  host  names  when  displaying them.
-p port, –port=port
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 tcptraceroute wrapper, -p speci fies the source port.

-t tos, –tos=tos
For IPv4, set the Type of Service (TOS)  and  Precedence  value.Useful  values  are 16 (low delay) and 8 (high throughput). Note that in order to use some TOS precedence values, you have to  be super user.

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

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.
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.

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).


Recommended Posts

Leave a Comment

Start typing and press Enter to search