When you do a DNS request, which DNS server is used? This tool will tell you. It does a DNS request while capturing network packets using native AF_PACKET sockets and gets the DNS server that replied.
Warning: Requires root access since it captures network packets while doing the DNS requests.
sudo ./whichdnssudo ./whichdns --domain google.comsudo ./whichdns --iponly --domain google.comsudo ./whichdns --debug --domain google.com./whichdns version./whichdns --helpNo external dependencies required - uses only native Linux AF_PACKET sockets.
go build- Linux (AF_PACKET sockets are Linux-specific)
- Root privileges (for raw socket access)
- Go 1.19+ (for AF_PACKET support)
Default interface: eno1
[████████████████████████████████████████] 100.00%
DNS server IP: 1.1.1.1$ sudo ./whichdns --iponly --domain google.com
1.1.1.1$ ./whichdns version
Version: 1.0.3This tool uses native Linux AF_PACKET raw sockets to capture Ethernet frames directly from the network interface. Unlike traditional packet capture libraries, it performs all packet parsing and filtering in userspace using pure Go code.
Built with Cobra - a modern CLI framework for Go that provides:
- Long flag support only (no short flags)
- Subcommands (version, help)
- Automatic help generation
- Clean command structure
- Zero external dependencies - No libpcap, CGO, or system libraries required
- Smaller binaries - No vendored C libraries
- Better portability - Only requires Linux kernel support
- Full control - Custom packet dissection and filtering logic
- Creates raw AF_PACKET socket bound to the default network interface
- Performs DNS lookups to generate network traffic
- Captures Ethernet frames containing DNS responses
- Parses Ethernet → IP → UDP → DNS packets in userspace
- Extracts the responding DNS server IP address
Requirements: Linux with AF_PACKET support (kernel 2.2+), root privileges for raw socket access.
Contributions are always welcome! All contributions are required to follow the https://google.github.io/styleguide/go/
Please report any security vulnerabilities to the project using issues or directly to the owner.
This project follows the go project code of conduct, please refer to https://go.dev/conduct for more details
- Add --iponly option to return just the DNS server IP for scripting
- Replace libpcap with native AF_PACKET sockets
- Add support for other packet capture methods (BPF, etc.)
I will always follow the Linux Kernel License as primary, if you require any other OPEN license please let me know and I will try to accomodate it.