LinuxCommandLibrary

dnstracer

Trace DNS query resolution path

TLDR

Find out where your local DNS got the information on www.example.com

$ dnstracer [www.example.com]
copy

Start with a [s]pecific DNS that you already know
$ dnstracer -s [dns.example.org] [www.example.com]
copy

Only query IPv[4] servers
$ dnstracer -4 [www.example.com]
copy

[r]etry each request 5 times on failure
$ dnstracer -r [5] [www.example.com]
copy

Display all steps during execution
$ dnstracer -v [www.example.com]
copy

Display an [o]verview of all received answers after execution
$ dnstracer -o [www.example.com]
copy

SYNOPSIS

dnstracer [-c queryclass] [-q querytype] [-t timeout] [-m maxloops] [-l] [-v] [-d] hostname

PARAMETERS

-c queryclass
    Specify DNS query class (default: IN)

-q querytype
    Specify DNS query type (default: A)

-t timeout
    Set query timeout in seconds (default: 5)

-m maxloops
    Maximum delegation loops (default: 30)

-l
    List all nameservers from cache

-v
    Enable verbose output

-d
    Enable debug mode

DESCRIPTION

dnstracer is a powerful command-line tool for debugging DNS resolution by tracing the full path of a recursive DNS query from the root nameservers down to the authoritative server. It simulates the process a resolver follows, sending iterative queries and following NS referrals, displaying each step including server IP, response time, and delegation details.

Unlike dig +trace, dnstracer starts from the root and queries each level explicitly, helping identify issues like lame delegations, timeouts, or misconfigurations in the DNS hierarchy. Output shows query type, class, server queried, status (SERVFAIL, NXDOMAIN, etc.), and NS records received. Ideal for network admins troubleshooting delegation chains or slow resolutions.

CAVEATS

May fail on firewalls blocking UDP/53; does not handle DNSSEC by default; root hints must be available or fetched.

EXAMPLE USAGE

dnstracer example.com
Traces A record path for example.com from root.

dnstracer -q MX -t 3 gmail.com
Traces MX records with 3s timeout.

HISTORY

Developed by dnstracer@nl.alibabanet around 2002; maintained sporadically, available in most Linux distros via dnstracer package. Inspired by need for explicit delegation tracing beyond standard tools.

SEE ALSO

dig(1), host(1), nslookup(1), drill(1)

Copied to clipboard