This Python script measures the latency of the top 5 popular DNS servers by sending ICMP ping requests and sorts them in ascending order of latency.
- Pings top DNS servers like Google, Cloudflare, OpenDNS, Quad9, and Comodo.
- Measures the average latency of each DNS server.
- Sorts and displays the servers by latency.
- Python 3.x
- The
pingcommand must be available on your system (default on most Linux and macOS systems).
-
Clone this repository:
git clone https://github.com/moksh45/dns-latency-checker.git cd dns-latency-checker -
Run the script:
python dns_latency_checker.py
-
The output will display the DNS servers sorted by their average latency in milliseconds:
DNS Server Latencies (in ms): Cloudflare (1.1.1.1): 12.45 ms Google (8.8.8.8): 14.67 ms Quad9 (9.9.9.9): 18.34 ms OpenDNS (208.67.222.222): 20.56 ms Comodo (8.26.56.26): 25.78 ms
- Google Public DNS:
8.8.8.8 - Cloudflare DNS:
1.1.1.1 - OpenDNS:
208.67.222.222 - Quad9 DNS:
9.9.9.9 - Comodo Secure DNS:
8.26.56.26
- The script uses the
pingcommand to test latency. Ensure you have the necessary permissions to execute it. - The script has been tested on Linux and macOS. Minor adjustments may be required for Windows.
This project is licensed under the MIT License.
Let me know if you need help with any of the steps!