A lightweight DNS client implementation that performs domain name to IP address translation by directly communicating with DNS servers using the DNS protocol.
- Custom DNS query message construction
- UDP-based communication with DNS servers
- Support for Google's public DNS (8.8.8.8)
- Timeout-based retry mechanism
- Detailed response parsing and display
- Resource Record (RR) processing
git clone [your-repository-url]
cd dns-client
python3 main.py <hostname>
Example:
python3 main.py example.com
The client will display detailed information about the DNS resolution process, including:
- Query ID
- Response flags
- Question section details
- Answer section with resolved IP addresses
- Additional resource records (if any)
The implementation follows the standard DNS protocol specification (RFC 1035) with:
- Header section with query identification and flags
- Question section containing the domain name query
- Answer section in responses with resolved addresses
- 5 second timeout for each query attempt
- Maximum 3 retry attempts
- Error reporting if no response is received
- Currently focuses on A records (IPv4 addresses)
- Future support planned for NS, MX, and CNAME records
- Python 3.6+
- No external libraries required (uses standard library only)
For debugging purposes, you can use Wireshark to capture and analyze the DNS packets:
- Start Wireshark and filter for DNS packets (filter:
dns
) - Run your query
- Examine the packet structure and fields
Contributions are welcome! Please feel free to submit a Pull Request.
- Based on DNS protocol specifications from RFC 1035
- Uses Google's Public DNS service