Skip to content

Instantly share code, notes, and snippets.

@nicksantamaria
Last active August 16, 2024 03:39
Show Gist options
  • Save nicksantamaria/2b23678212add30117f3feadc9459c0b to your computer and use it in GitHub Desktop.
Save nicksantamaria/2b23678212add30117f3feadc9459c0b to your computer and use it in GitHub Desktop.
Retrieve a list of CIDR ranges for AWS ELBs and CloudFront (relevant to Sydney region).
# Region: Sydney (ap-southeast-2)
# Service: ELBs.
curl -ss https://ip-ranges.amazonaws.com/ip-ranges.json | jq -arM -c '.prefixes[] | select(.region | contains("ap-southeast-2")) | select(.service | contains("AMAZON")) | .ip_prefix' | tee results.txt
# Region: Sydney (ap-southeast-2)
# Service: CloudFront.
curl -ss https://ip-ranges.amazonaws.com/ip-ranges.json | jq -arM -c '.prefixes[] | select(.region | contains("ap-southeast-2")) | select(.service | contains("CLOUDFRONT")) | .ip_prefix' | tee -a results.txt
# Region: Global
# Service: CloudFront.
curl -ss https://ip-ranges.amazonaws.com/ip-ranges.json | jq -arM -c '.prefixes[] | select(.region | contains("GLOBAL")) | select(.service | contains("CLOUDFRONT")) | .ip_prefix' | tee -a results.txt
# Check results.txt for results.
13.54.0.0/15
52.62.0.0/15
52.64.0.0/17
52.64.128.0/17
52.65.0.0/16
52.92.52.0/22
52.94.13.0/24
52.94.198.112/28
52.94.248.64/28
52.95.36.0/22
52.95.128.0/21
52.95.241.0/24
52.95.255.16/28
54.66.0.0/16
54.79.0.0/16
54.153.128.0/17
54.206.0.0/16
54.231.248.0/22
54.231.252.0/24
54.240.192.0/22
54.240.203.0/24
54.240.204.0/22
54.252.0.0/16
54.253.0.0/16
103.8.172.0/22
13.54.63.128/26
13.32.0.0/15
52.46.0.0/18
52.84.0.0/15
52.222.128.0/17
54.182.0.0/16
54.192.0.0/16
54.230.0.0/16
54.239.128.0/18
54.239.192.0/19
54.240.128.0/18
204.246.164.0/22
204.246.168.0/22
204.246.174.0/23
204.246.176.0/20
205.251.192.0/19
205.251.249.0/24
205.251.250.0/23
205.251.252.0/23
205.251.254.0/24
216.137.32.0/19
@schwartz1375
Copy link

Note this only pull IPv4, thus you missing IPv6 Address
curl https://ip-ranges.amazonaws.com/ip-ranges.json | jq '.ipv6_prefixes | .[] | select(.service == "CLOUDFRONT") | .ipv6_prefix'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment