Last active
February 12, 2026 18:33
-
-
Save shakquraa/ead8ecc2b3a5f6c5d30096101747dda4 to your computer and use it in GitHub Desktop.
Simple Bash script to collect, deduplicate, and maintain fresh DNS resolvers for recon workflows.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| # Directory setup (portable & clean) | |
| BASE_DIR="$HOME/.dns-resolvers" | |
| TEMP_DIR="$BASE_DIR/temp" | |
| FINAL_FILE="$BASE_DIR/resolvers.txt" | |
| # Resolver sources | |
| URLS=( | |
| "https://gist.githubusercontent.com/sirkirby/2e83de47cef930baddedfb12e80a5558/raw/public-dns-resolvers.txt" | |
| "https://public-dns.info/nameservers.txt" | |
| "https://public-dns.info/nameservers-all.txt" | |
| "https://raw.githubusercontent.com/BonJarber/fresh-resolvers/main/resolvers.txt" | |
| "https://raw.githubusercontent.com/cxosmo/dns-resolvers/main/resolvers.txt" | |
| "https://raw.githubusercontent.com/kh4sh3i/Fresh-Resolvers/master/resolvers.txt" | |
| "https://raw.githubusercontent.com/phasip/resolvers/master/resolvers.txt" | |
| "https://raw.githubusercontent.com/proabiral/Fresh-Resolvers/main/resolvers.txt" | |
| "https://raw.githubusercontent.com/rix4uni/resolvers/main/resolvers.txt" | |
| "https://raw.githubusercontent.com/trickest/resolvers/main/resolvers.txt" | |
| "https://www.cambus.net/files/public-dns-servers.txt" | |
| ) | |
| # Create directories | |
| mkdir -p "$TEMP_DIR" | |
| # Cleanup old data | |
| rm -f "$FINAL_FILE" | |
| rm -f "$TEMP_DIR"/* 2>/dev/null | |
| echo "[+] Fetching DNS resolvers from multiple sources..." | |
| # Download resolver lists | |
| i=0 | |
| for url in "${URLS[@]}"; do | |
| ((i++)) | |
| file="$TEMP_DIR/resolver_$i.txt" | |
| curl -s "$url" -o "$file" | |
| done | |
| echo "[+] Combining & deduplicating resolvers..." | |
| # Merge, filter IPv4 (+ optional port), deduplicate | |
| cat "$TEMP_DIR"/* 2>/dev/null | | |
| tr -d '\r' | | |
| grep -E '^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+(:[0-9]+)?$' | | |
| sort -u >"$FINAL_FILE" | |
| # Cleanup temp files | |
| rm -rf "$TEMP_DIR" | |
| # Result | |
| if [[ -f "$FINAL_FILE" ]]; then | |
| COUNT=$(wc -l <"$FINAL_FILE") | |
| echo "[✓] Resolvers saved to $FINAL_FILE ($COUNT unique)" | |
| else | |
| echo "[✗] Failed to generate resolver list" | |
| fi |
Author
Great catch! You’re absolutely right about the basename overwrite issue.
Thanks for the clean fix and for adding CR cleanup — really appreciate it 🙌
I’ll update the script with this improvement.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is a great work, thanks for you effort
but i have notices several source URLs ended in
resolvers.txt. The script usedbasename, which caused downloads to overwrite each other in the temporary directoryhere is a slight modification to address this issue