How does the traceroute -A command work? How does the program look up the ASN? On which protocols or databases does the query depend? Can I recreate the -A option?

I am using this version: Modern traceroute for Linux, version 2.0.18, Jun 30 2012.

2 Answers 2


A whois query is made for every IP returend.

Here is a manual example. Get one of the IPs of networkengineering.stackexchange.com

> host networkengineering.stackexchange.com
networkengineering.stackexchange.com has address
networkengineering.stackexchange.com has address
networkengineering.stackexchange.com has address
networkengineering.stackexchange.com has address
networkengineering.stackexchange.com has address

And check which AS the IP belongs to:

 > whois  | grep -i origin
 OriginAS:       AS13335

Whois outpus way more information. The protocol ist specified in RFC3912

Note that whois output of the regional registries differ and not all will provide the origin as. So traceroute -A will not provide AS informations for all addresses.

  • I don't think so. Commented Sep 14, 2015 at 9:04
  • LACNIC: whois, whois, whois, do not reveal the ASN. Neither does the tool at lacnic.net. The ASNs shown by traceroute are: [AS4967/AS10834]; [AS5648]; [AS4926]. Commented Sep 14, 2015 at 9:05
  • APNIC: whois does not reveal the ASN. Neither does the tool at apnic.net. But traceroute shows AS4808. On the contrary, querying whois via the form at apnic.net shows an additional section: % Information related to ''. That's the same ASN as identified by traceroute. Still, whois does not reveal the ASN. Commented Sep 14, 2015 at 9:13
  • I've done all traceroutes again. On two hosts, using different ISPs. For each hop a Whois query is sent to I could manually query each hop via jwhois -f -h $IPv4. Searching the web for "" whois did lead me to RADB. To sum it up: traceroute does not ask a RIR, as whois does without the -h option. Commented Sep 14, 2015 at 15:09
  • 1
    Okay: Would you please explain how traceroute -A is working? It must be some form of magic and the file as_lookups.c in the traceroute source code, where whois.radb.net is queried and the output is searched for "origin", must be fake and only there to confuse people.
    – user2084
    Commented Mar 27, 2017 at 11:30

--as-path-lookups is based on RADB IRR data, which may very well be incorrect/missing.

traceroute/as_lookups.c in traceroute-2.1.0 Dmitry Butskoy

    Copyright (c)  2006, 2007           Dmitry Butskoy
                                        <[email protected]>
    License:  GPL v2 or any later

    See COPYING for the status of this software.

#define DEF_RADB_SERVER         "whois.radb.net"
#define DEF_RADB_SERVICE        "nicname"
if (!ra_addr.sa.sa_family) {
    const char *server, *service;
    struct addrinfo *res;
    int ret;

    server = getenv ("RA_SERVER");
    if (!server)  server = DEF_RADB_SERVER;

    service = getenv ("RA_SERVICE");
    if (!service)  service = DEF_RADB_SERVICE;

    ret = getaddrinfo (server, service, NULL, &res);
    if (ret) {
        fprintf (stderr, "%s/%s: %s\n", server, service,
        exit (2);

    memcpy (&ra_addr, res->ai_addr, res->ai_addrlen);

    freeaddrinfo (res);

example of incorrect information

  * ( [AS19905]  180.570 ms ( [AS19905]  187.246 ms

based on RADB IRR

$ whois -h whois.radb.net
descr:      AC_SINGTEL
origin:     AS19905
mnt-by:     MAINT-AS7786
changed:    [email protected] 20150730  #02:53:10Z
source:     RADB

IRR/BGP comparison on IRR Explorer

  • BGP from AS7473, RADB AS7473
  • not seen in BGP, Level3 AS19905, RADB AS7473 the
  • traceroute hop is actually in AS7473

Moral of the story, there is no way to reliable get a route's origin AS in any static database (IRR, registry etc). And the origin may very well be different depending on your vantage point in DFZ.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.