How to check if an IP address belongs to AWS

AWS publishes the address ranges it uses in one file, ip-ranges.json. If an IP falls inside one of those ranges, AWS uses it. If it doesn't, you have learned less than you might think: plenty of addresses that route to AWS are left out of the file on purpose.

Below are four ways to check, from quickest to most thorough, and what each one can and can't tell you.

Method 1: look it up here

Paste an IP address, a CIDR block or a hostname into the box above. The page downloads ip-ranges.json directly from AWS, matches your query in your browser and shows:

Some examples, with what they returned when this guide was written: 3.18.1.10 (EC2 address space, US East (Ohio)), 13.32.12.39 (CloudFront), 52.94.76.1 (AWS, service not disclosed) and 8.8.8.8 (not in AWS's ranges).

The matching happens in your browser, so the addresses you look up aren't sent anywhere unless you choose one of the optional checks, such as reverse DNS. Hostnames are the other exception: to resolve one, the page asks a public DNS-over-HTTPS resolver. The privacy page lists who sees what.

Method 2: search ip-ranges.json yourself

The file is public and authoritative. Download it and check when AWS published it:

curl -sO https://ip-ranges.amazonaws.com/ip-ranges.json
jq -r '.createDate' ip-ranges.json   # publication time, UTC

jq has no CIDR matching, so this filter turns IPv4 addresses into numbers and compares them. It prints every range that contains the address:

jq -r --arg ip 3.0.5.33 '
  def ip2n: split(".") | map(tonumber) | .[0]*16777216 + .[1]*65536 + .[2]*256 + .[3];
  ($ip | ip2n) as $n
  | .prefixes[]
  | (.ip_prefix | split("/")) as [$net, $len]
  | ($net | ip2n) as $start
  | select($n >= $start and $n < $start + pow(2; 32 - ($len | tonumber)))
  | [.ip_prefix, .service, .region, .network_border_group] | @tsv' ip-ranges.json

3.0.0.0/15    AMAZON                ap-southeast-1  ap-southeast-1
3.0.0.0/15    EC2                   ap-southeast-1  ap-southeast-1
3.0.5.32/29   EC2_INSTANCE_CONNECT  ap-southeast-1  ap-southeast-1

For IPv6 as well as IPv4, Python's standard library does the CIDR maths:

curl -s https://ip-ranges.amazonaws.com/ip-ranges.json | python3 -c '
import ipaddress, json, sys
ip = ipaddress.ip_address(sys.argv[1])
d = json.load(sys.stdin)
for p in d["prefixes"] + d["ipv6_prefixes"]:
    net = ipaddress.ip_network(p.get("ip_prefix") or p["ipv6_prefix"])
    if ip in net:
        print(net, p["service"], p["region"], p["network_border_group"])
' 2600:1f18::1

2600:1f18::/33 AMAZON us-east-1 us-east-1
2600:1f18::/33 EC2 us-east-1 us-east-1

Reading the rows

The ip-ranges.json reference explains every field.

Method 3: check who announces the address (ASN and whois)

Every public IP is announced to the internet by a network with an autonomous system number (ASN). Team Cymru's free whois service maps an IP to its ASN in one command:

whois -h whois.cymru.com " -v 3.18.1.10"

AS      | IP         | BGP Prefix   | CC | Registry | Allocated  | AS Name
16509   | 3.18.1.10  | 3.16.0.0/14  | US | arin     | 2017-12-20 | AMAZON-02 - Amazon.com, Inc., US

ASNs you are likely to meet:

ASNRegistered asMeaning
AS16509AMAZON-02Amazon's main AWS network; most AWS addresses
AS14618AMAZON-AESAlso AWS
AS8987GOVCLOUD (Amazon)Also Amazon-operated
AS214101EU-SOVEREIGN-CLOUDAWS European Sovereign Cloud
AS55960, AS135629Names of the local operatorsAWS China Regions, run by local partners. The registered names don't mention Amazon.
AS7224, AS62785AMAZON-AS, AMAZON-FCAmazon's corporate networks, not AWS
AS801AMAZON-LEOAmazon Leo satellite internet, not AWS

Caveats:

Method 4: reverse DNS

dig +short -x 3.18.1.10
ec2-3-18-1-10.us-east-2.compute.amazonaws.com.

dig +short -x 13.32.12.39
server-13-32-12-39.bud50.r.cloudfront.net.

A name ending in compute.amazonaws.com (or compute-1.amazonaws.com for US East (N. Virginia)) is AWS's default name for EC2 address space. Names ending in r.cloudfront.net are CloudFront edge servers, and bud50 is the edge location, Budapest. The region guide decodes more patterns.

Why "not listed" doesn't mean "not AWS"

AWS publishes ranges for the services customers commonly use for egress filtering, and says it doesn't publish them for every service. Addresses that can route to AWS but won't match the file include:

So when an address isn't listed, check the ASN (method 3). On this site, a not-listed result offers a one-click check that asks RIPEstat whether an Amazon network announces the address. It is opt-in because it sends the IP to RIPE NCC.

Which method to use

MethodTells youMisses
This site or ip-ranges.jsonThat AWS uses the range; service code, region and border groupBYOIP, SES, unpublished services; never the customer
ASN and whoisWhich network routes the address; who holds the blockService and region; China and partner-run networks under other names
Reverse DNSSometimes the region, CloudFront edge location or SESMost addresses have generic names or none

Whichever method you use, a match tells you AWS operates the range. It never tells you which AWS customer is behind an address: see who owns this AWS IP address?

Sources