Sometimes it's useful to know what IP ranges our servers are operating in. Since we run on Heroku, it's a little complicated. However, Heroku runs on AWS, which has this page dedicated to IP Ranges by Region.
Heroku recommends using this to identify which region are bing in use. If dynos are run in common spaces in US region, we can look up information about this region using Heroku's API:
using httpie:
http https://api.heroku.com/regions/us "Accept:application/vnd.heroku+json; version=3"
outputs:
{
"country": "United States",
"created_at": "2012-11-21T20:44:16Z",
"description": "United States",
"id": "59accabd-516d-4f0e-83e6-6e3757701145",
"locale": "Virginia",
"name": "us",
"private_capable": false,
"provider": {
"name": "amazon-web-services",
"region": "us-east-1"
},
"updated_at": "2016-08-09T22:03:28Z"
}
Then using AWS link mentioned above we can pull JSON file with IP ranges by region and by service (it has also been added it to this repo as ip-ranges.json
). After we get the file, we can use jq
to find ranges for the given region and service. Here is a query that would pull ranges for us-east-1
and EC2
service:
jq '.prefixes[] | select(.region=="us-east-1" and .service=="EC2") | .ip_prefix' < ip-ranges.json
And the results
# us-east-1 EC2 IP ranges as of Jan 21, 2020
18.208.0.0/13
52.95.245.0/24
54.196.0.0/15
216.182.224.0/21
216.182.232.0/22
3.5.16.0/21
107.20.0.0/14
99.77.128.0/24
67.202.0.0/18
184.73.0.0/16
3.80.0.0/12
54.80.0.0/13
3.224.0.0/12
54.221.0.0/16
54.156.0.0/14
54.236.0.0/15
54.226.0.0/15
162.250.237.0/24
52.90.0.0/15
100.24.0.0/13
54.210.0.0/15
54.198.0.0/16
52.20.0.0/14
52.94.201.0/26
52.200.0.0/13
54.160.0.0/13
162.250.238.0/23
35.153.0.0/16
52.70.0.0/15
52.94.248.0/28
99.77.254.0/24
52.54.0.0/15
54.152.0.0/16
54.92.128.0/17
52.0.0.0/15
184.72.128.0/17
23.20.0.0/14
18.204.0.0/14
54.88.0.0/14
162.250.236.0/24
99.77.129.0/24
54.204.0.0/15
15.177.64.0/23
52.86.0.0/15
52.44.0.0/15
18.232.0.0/14
54.174.0.0/15
50.16.0.0/15
35.168.0.0/13
99.77.191.0/24
3.208.0.0/12
3.5.0.0/20
174.129.0.0/16
72.44.32.0/19
34.224.0.0/12
54.224.0.0/15
75.101.128.0/17
34.192.0.0/12
54.208.0.0/15
54.242.0.0/15
216.182.238.0/23
54.234.0.0/15
54.144.0.0/14
52.2.0.0/15
184.72.64.0/18
204.236.192.0/18
15.193.6.0/24
52.4.0.0/14
208.86.88.0/23
44.192.0.0/11
52.72.0.0/15
52.95.255.80/28
50.19.0.0/16
54.172.0.0/15