In this guide, we cover DNS monitoring using tools such as netshoot, Wireshark, and tcpdump. We also demonstrate how to trace network system calls and review the detailed output from DNS queries.
Using Docker and netshoot for DNS Monitoring
If you’re on macOS, one quick way to access various networking tools is by running the netshoot Docker image. This container includes pre-installed utilities that are perfect for DNS troubleshooting in containerized setups. To run the netshoot container, execute:strace to trace system calls. For instance, the command below monitors network-related system calls during a DNS lookup. The -f flag instructs strace to follow any child processes, ensuring comprehensive activity logging, and the -e trace=network option limits the output to network system calls:
Analyzing DNS Resolution Steps
Following the resolution chain further reveals subsequent nameserver responses. In the next example, the second DNS response is received from a different IP address:strace output shows communication with the nameserver at IP address 205.251.195.12:
Monitoring DNS Traffic with Wireshark
Another powerful tool for DNS monitoring is Wireshark. On macOS, Wireshark enables you to capture and inspect DNS traffic in real time. After launching Wireshark, follow these steps:-
Select the network interface (typically
EN0for internet connectivity). - Apply a filter to display only DNS traffic. A common filter is to capture UDP and TCP traffic on port 53.
-
Run a DNS query, for example:
Capturing DNS Traffic with tcpdump
For command-line enthusiasts, tcpdump provides an effective way to monitor DNS traffic. Use the command below to capture all traffic on the default DNS port (53):Because DNS logs can be very detailed, leveraging AI chatbots or other interpretative tools can help demystify the complex outputs from tools like tcpdump.