How to Use Wget to Download and Log DNS Lookups on Ubuntu
This guide explains how to utilize the wget command-line utility on Ubuntu to download files while simultaneously recording DNS resolution details. By combining specific wget flags, you can capture network debugging information, including hostname lookups, into a local log file for analysis.
To begin, ensure wget is installed on your Ubuntu system. While it is
pre-installed on most versions, you can verify or install it by running
sudo apt update && sudo apt install wget in your
terminal. Once ready, you can proceed to download a file and log the DNS
resolution process using the debug and output logging flags.
The primary command to achieve this combines the -d flag
for debug output and the -o flag to specify the log file.
Execute the following command in your terminal, replacing the URL with
your target file and log.txt with your preferred log
filename:
wget -d -o log.txt https://example.com/file.zipIn this command, the -d option enables debug mode, which
forces wget to print detailed information about its operations,
including the DNS resolution step where it resolves the domain name to
an IP address. The -o option redirects all standard output
and error messages, including the debug information, into the specified
log file instead of displaying it only on the screen.
After the download completes, you can inspect the log file to verify
the DNS lookup details. Use the cat command to view the
contents of the log:
cat log.txtSearch through the output for lines starting with
Resolving. This line indicates the DNS lookup event,
showing the domain name queried and the IP address returned. This method
provides a straightforward way to audit network resolution activity
specific to the wget process without requiring additional network
monitoring tools.