How to Trace Network Route and ASN Information in Ubuntu Using mtr -z

When diagnosing network latency spikes, packet loss, or suboptimal routing across the internet, standard utility tools like ping and traceroute offer limited insight. Traditional traceroute prints a static snapshot of intermediate routers, while ping only tests the destination endpoint. mtr (My Traceroute) combines the real-time polling power of ping with the multi-hop tracing of traceroute. By adding the -z (or --aslookup) parameter, mtr queries Border Gateway Protocol (BGP) routing tables to display the exact Autonomous System Number (ASN) governing each hop along the transit path.

Why Autonomous System (ASN) Telemetry Is Critical

The global internet is composed of tens of thousands of interconnected independent routing domains known as Autonomous Systems (ASes), operated by internet service providers (ISPs), transit backbones (like Lumen, Telia, or Cloudflare), and cloud hyperscalers (like Google, Amazon, and Microsoft). Knowing the ASN for each hop allows network engineers and systems administrators to:

  • Identify Route Handoffs: Pinpoint exactly where packets exit your local internet service provider and transition onto upstream Tier-1 transit backbones.
  • Isolate Packet Loss Sources: Determine whether latency jitter or packet loss originates within your local ISP network or inside a remote transit carrier’s peering exchange.
  • Troubleshoot Cloud Connectivity: Verify whether traffic destined for AWS, Azure, or Google Cloud enters the provider’s private edge network near your physical location or tromboned across transatlantic hops.

Installing mtr on Ubuntu

The mtr package is available directly from the standard Ubuntu package repositories:

  1. Open the Terminal application on Ubuntu (press Ctrl + Alt + T).
  2. Update your local package lists:
    sudo apt update
  3. Install the mtr-tiny or standard mtr package:
    sudo apt install mtr -y

Running mtr with ASN Lookups (mtr -z)

To initiate a real-time dynamic trace that displays Autonomous System Numbers beside each router:

  1. In the terminal, run mtr combined with the -z flag targeting a destination IP address or domain name:
    mtr -z 1.1.1.1
  2. An interactive, continuously refreshing ncurses interface opens in the terminal window:
    HOST: ubuntu-server            Loss%   Snt   Last   Avg  Best  Wrst StDev
     1. AS???   192.168.1.1          0.0%    10    0.8   0.9   0.7   1.4   0.2
     2. AS12322 10.45.0.1            0.0%    10    5.2   5.4   4.9   6.1   0.4
     3. AS12322 ae-12.core1.lon.isp   0.0%    10    8.1   8.3   7.9   9.2   0.5
     4. AS13335 172.70.240.1          0.0%    10    8.4   8.7   8.2  10.1   0.6
     5. AS13335 one.one.one.one       0.0%    10    8.3   8.5   8.1   9.0   0.3

Interpreting the Output Columns

The output table displays vital performance metrics updating every second:

  • AS column: Shows the registered Autonomous System Number (e.g., AS13335 belongs to Cloudflare). Local private subnets (such as 192.168.1.1) display AS??? because private RFC 1918 addresses are not registered on public BGP tables.
  • Loss%: The percentage of ICMP or UDP probe packets dropped at that specific hop. Consistent packet loss extending across all subsequent hops indicates a genuine hardware or link bottleneck.
  • Snt: The total number of probes transmitted.
  • Last, Avg, Best, Wrst: Round-trip latency values in milliseconds.
  • StDev: Standard deviation of ping times; high standard deviation indicates network jitter.

Generating Static Text Reports for Ticketing and Logs

If you need to attach routing telemetry to an ISP support ticket or network audit log, use the -r (report) and -c (count) flags to generate a static output without launching the interactive screen:

mtr -z -r -c 50 digitash.com > routing_audit.txt

This command transmits 50 consecutive probes, compiles the statistical averages with full ASN mapping, and writes the clean textual report directly into routing_audit.txt.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.