This script reads a list of IP addresses from a file, performs multiple iterations of latency checks using curl, and outputs the top 3 IP addresses with the lowest latency. It also displays progress information for each iteration.
- Save the script to a file, e.g.,
check_ips.sh. - Make the script executable:
chmod +x check_npm.sh
- Create a file named
ips.txtin the same directory as the script. List all the IP addresses you want to check, one per line. - Run the script:
./check_npm.sh
The script will output the top 3 IP addresses with the fastest response times.
104.16.27.34
104.16.0.35
104.16.28.34
104.16.29.34
104.16.25.34
104.16.1.35
104.16.31.34
104.16.30.34
104.16.26.34
104.16.2.35
104.16.24.34
104.16.3.35
To get a list of IP addresses that a domain resolves to from different geographic locations, you can use the following methods:
-
Online DNS tools:
- Use websites like WhatsMyDNS or ViewDNS to see how a domain resolves from different DNS servers around the world.
-
Command Line Tools:
- Use the
digcommand with different DNS servers:dig +short @8.8.8.8 example.com # Google DNS dig +short @1.1.1.1 example.com # Cloudflare DNS dig +short @9.9.9.9 example.com # Quad9 DNS
- To automate this for multiple DNS servers, you can create a script that queries these servers and aggregates the results.
- Use the
-
Third-Party APIs:
- Use DNS query APIs like DNSimple, Google DNS API, or Cloudflare DNS API.
#!/bin/bash
DOMAIN="example.com"
SERVERS=("8.8.8.8" "1.1.1.1" "9.9.9.9")
for SERVER in "${SERVERS[@]}"; do
echo "DNS Server: $SERVER"
dig +short @$SERVER $DOMAIN
doneThis script will query the specified domain against multiple DNS servers and return the resolved IP addresses.