How to use the command 'dnstracer' (with examples)
- Linux
- December 25, 2023
The dnstracer
command is used to determine where a DNS (Domain Name System) gets its information from. It provides useful information about the DNS resolution process, including the DNS servers involved and the responses received.
Use case 1: Find out where your local DNS got the information on www.example.com
Code:
dnstracer www.example.com
Motivation: This use case allows you to trace the DNS resolution process for a specific domain (www.example.com ) and find out which DNS servers were involved in retrieving the information.
Explanation: The command is followed by the domain name (www.example.com ) you want to trace. By default, it starts with your local DNS server and traces the resolution process until it reaches the authoritative DNS server for the domain.
Example output:
Tracing to www.example.com[a] via A.ROOT-SERVERS.NET, maximum of 5 retries
A.ROOT-SERVERS.NET [.] (198.41.0.4)
|\___ m.gtld-servers.net [com.] (192.55.83.30)
| |\___ a.iana-servers.net [example.com.] (199.43.132.53) Got authoritative answer
| |\___ b.iana-servers.net [example.com.] (199.43.133.53) Got authoritative answer
Use case 2: Start with a specific DNS that you already know
Code:
dnstracer -s dns.example.org www.example.com
Motivation: In some situations, you may already know the specific DNS server you want to start the tracing process from. This use case allows you to specify that DNS server (dns.example.org) as the starting point.
Explanation: The -s
option is used to define a specific DNS server to start the tracing process from. This can be useful when you want to trace the resolution process from a known DNS server instead of starting from your local DNS server.
Example output:
Tracing to www.example.com[a] via dns.example.org, maximum of 5 retries
dns.example.org [example.org.] (192.168.1.10)
|\___ a.iana-servers.net [example.com.] (199.43.132.53) Got authoritative answer
|\___ b.iana-servers.net [example.com.] (199.43.133.53) Got authoritative answer
Use case 3: Only query IPv4 servers
Code:
dnstracer -4 www.example.com
Motivation: In some cases, you may want to limit the tracing process to only IPv4 servers. This use case allows you to exclude IPv6 servers from the resolution process.
Explanation: The -4
option tells dnstracer
to only query IPv4 servers during the resolution process. This can be useful when troubleshooting DNS issues that might be specific to IPv4.
Example output:
Tracing to www.example.com[a] via A.ROOT-SERVERS.NET, maximum of 5 retries
A.ROOT-SERVERS.NET [.] (198.41.0.4)
|\___ m.gtld-servers.net [com.] (192.55.83.30)
| |\___ a.iana-servers.net [example.com.] (199.43.132.53) Got authoritative answer
| |\___ b.iana-servers.net [example.com.] (199.43.133.53) Got authoritative answer
Use case 4: Retry each request 5 times on failure
Code:
dnstracer -r 5 www.example.com
Motivation: When performing DNS resolution, sometimes the request may fail before receiving any response. This use case allows you to specify the number of retry attempts (5 in this example) before giving up.
Explanation: The -r
option is used to define the number of retry attempts in case of failures. By default, dnstracer
retries each request only once. This option can be useful when dealing with intermittent DNS issues.
Example output:
Tracing to www.example.com[a] via A.ROOT-SERVERS.NET, maximum of 5 retries
A.ROOT-SERVERS.NET [.] (198.41.0.4) Failed
A.ROOT-SERVERS.NET [.] (198.41.0.4) Failed
A.ROOT-SERVERS.NET [.] (198.41.0.4)
|\___ m.gtld-servers.net [com.] (192.55.83.30)
| |\___ a.iana-servers.net [example.com.] (199.43.132.53) Got authoritative answer
| |\___ b.iana-servers.net [example.com.] (199.43.133.53) Got authoritative answer
Use case 5: Display all steps during execution
Code:
dnstracer -v www.example.com
Motivation: This use case provides detailed information about each step of the DNS resolution process, including the DNS servers involved, the queries made, and the responses received.
Explanation: The -v
option enables verbose mode, which displays all steps during the execution of dnstracer
. This can be useful for troubleshooting DNS issues or for gaining a better understanding of the resolution process.
Example output:
Tracing to www.example.com[a] via A.ROOT-SERVERS.NET, maximum of 5 retries
A.ROOT-SERVERS.NET [.] (198.41.0.4)
-> Got referral to A.GTLD-SERVERS.NET [com.] (192.5.6.30)
-> Got referral to U.GTLD-SERVERS.NET [com.] (192.30.14.30)
-> Got referral to TC.BR [example.com.] (200.160.0.5)
\___ TC.BR [example.com.] (200.160.7.102) Got authoritative answer
Use case 6: Display an overview of all received answers after execution
Code:
dnstracer -o www.example.com
Motivation: This use case provides a concise overview of all the received answers after the execution of dnstracer
, making it easier to analyze the results.
Explanation: The -o
option enables the overview mode, which displays a summary of all the received answers. This can be useful when you only need a high-level understanding of the DNS resolution process.
Example output:
Tracing to www.example.com[a] via A.ROOT-SERVERS.NET, maximum of 5 retries
Received answer from A.ROOT-SERVERS.NET (198.41.0.4): [a]
Received answer from TC.BR [example.com.] (200.160.7.102): [a]
Conclusion:
The dnstracer
command is a powerful tool for tracing the DNS resolution process and gathering information about the DNS servers involved. With its various options, you can customize the tracing process to suit your needs and gain insights into the resolution of domain names.