This script runs a dig DNS query against a specified DNS server while simultaneously capturing the associated DNS traffic with tcpdump.
The result is a .pcap file for later analysis (e.g. in Wireshark) and a tcpdump log file.
Run as root or with sudo:
sudo ./dig_dump.sh <dig options>Example:
sudo ./dig_dump.sh example.com AYou will then be prompted to enter the DNS server IP (IPv4 or IPv6).
The script will:
- Start
tcpdumpto capture DNS packets. - Execute the
digquery with your options. - Stop
tcpdumpafter a short delay. - Save the capture and log.
- Launch Wireshark (if installed) to open the capture file.
- Root privileges (or run with
sudo) - Tools:
digtcpdumpwireshark(optional, for automatic viewing)
-
Input:
digcommand options (e.g., query name, record type).- DNS server IP (prompted interactively).
-
Output:
dns_capture.pcap(DNS traffic capture)tcpdump_log.txt(capture log)
- The script overwrites existing
dns_capture.pcapandtcpdump_log.txt. - Works for both IPv4 and IPv6 DNS servers.
- If Wireshark is not installed, the capture remains available for later analysis.
This script is covered under the repository’s main MIT License.