Skip to content

Instantly share code, notes, and snippets.

@erchn
Last active February 5, 2019 21:36
Show Gist options
  • Save erchn/90c0f1b625f5ea26a4da3a5aa4103b68 to your computer and use it in GitHub Desktop.
Save erchn/90c0f1b625f5ea26a4da3a5aa4103b68 to your computer and use it in GitHub Desktop.
Match Cloudflare IPs with regex
# https://www.cloudflare.com/ips/
# this is not meant to catch malformed IPs
/(103\.21\.24[4567]\.[0-9]+ # 103.21.244.0/22
|103\.22\.20[0123]\.[0-9]+ # 103.22.200.0/22
|103\.31\.[4567]\.[0-9]+ # 103.31.4.0/22
|104\.(1[6789]|2[0-9]|3[01])\.[0-9]+ # 104.16.0.0/12
|108\.162\.(19[2-9]|2[0-9]+)\.[0-9]+ # 108.162.192.0/18
|131\.0\.7[2345]\.[0-9]+ # 131.0.72.0/22
|141\.101\.(6[4-9]|[7-9][0-9]|1[01][0-9]|12[0-7])\.[0-9]+ # 141.101.64.0/18
|162\.15[890]\.[0-9]+\.[0-9]+ # 162.158.0.0/15
|172\.(6[4-9]|7[01])\.[0-9]+\.[0-9]+ # 172.64.0.0/13
|173\.245\.(4[89]|5[0-9]|6[0-3])\.[0-9]+ # 173.245.48.0/20
|188\.114\.(9[6-9]|10[0-9]|11[01])\.[0-9]+ # 188.114.96.0/20
|190\.93\.(24[0-9]|25[0-9])\.[0-9]+ # 190.93.240.0/20
|197\.234\.24[0-3]\.[0-9]+ # 197.234.240.0/22
|198\.41\.(12[89]|1[3-9][0-9]|2[0-9][0-9])\.[0-9]+)/ # 198.41.128.0/17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment