A Bash-based tool to discover Cloudflare edge IPs with open port 443 and evaluate their TLS handshake reliability against a specific SNI.
This script is useful in environments where:
- Direct outbound access is restricted
- Only ports 80/443 are allowed
- Traffic must be proxied through Cloudflare IPs
- Stable and repeatable TLS connectivity is critical (e.g. ProxyPass, reverse proxies, tunneling)
- Scans official Cloudflare IP ranges using masscan
- Filters IPs with port 443 open
- Performs an initial TLS gate check (fast reject of bad IPs)
- Runs multiple TLS handshake attempts to measure reliability
- Categorizes IPs as GOOD / NORMAL / BAD
- Saves reliable IPs into a reusable file (
good_ips)
- Linux
bashmasscanopenssltimeout(usually fromcoreutils)sudoprivileges (required by masscan)
Install masscan (example):
sudo apt install masscanEdit the variables at the top of the script:
OUT="ips.txt" # masscan output file
SNI="your.example.com" # Server Name Indication (IMPORTANT)
ATTEMPTS=10 # Total TLS handshake attempts per IP
TIMEOUT=2 # Timeout per handshake (seconds)chmod +x scan.sh
./scan.shThe script will:
- Scan Cloudflare IP ranges on port 443
- Perform an initial TLS handshake test
- Run reliability checks on passing IPs
- Output results to the console
- Save GOOD IPs into
good_ips
| Status | Condition |
|---|---|
| GOOD | 4β5 successful TLS handshakes |
| NORMAL | 2β3 successful TLS handshakes |
| BAD | Less than 2 successful handshakes |
Only GOOD IPs are written to good_ips.
ips.txtβ raw masscan outputgood_ipsβ Cloudflare IPs with stable TLS connectivity
In restricted or filtered networks, not all Cloudflare IPs behave equally. Some edges:
- Drop TLS handshakes
- Reset connections
- Are unstable over time
This tool helps you select only reliable Cloudflare IPs for:
- Reverse proxies
- ProxyPass setups
- Tunnels
- Whitelisted outbound access
- Scanning large IP ranges may trigger IDS/IPS systems
- Adjust
--max-rateif you experience packet loss - Cloudflare IP ranges may change over time
MIT License
PRs and improvements are welcome:
- Better TLS validation
- IPv6 support
- Parallel TLS checks
- JSON / CSV output
Happy scanning βοΈ