Start with Team Cymru, over whois or DNS
The origin ASN is the autonomous system that announces a route covering the address. Several routes can cover one address, and we take the most specific one: that is our rule (standard longest-prefix routing), not something the pages we read state as a rule. You read the ASN from routing data, not from the address itself, which is why the answer depends on which dataset you ask. For one address, the shortest working command is whois against Team Cymru's server, and the equivalent for scripts is a DNS TXT query. Below, we run each method on public addresses so you can see where they agree and where they trip you up. For the background on what an ASN is, see our ASN explainer.
The commands ran on 1 December 2026 between 13:41 and 13:48 UTC on one macOS 27.0 machine, using the system whois, DiG 9.10.6, curl 8.7.1 and jq 1.6. The timing figures also include later runs at about 14:00 UTC and a separate re-run at a different time, which came out lower, and the APNIC route lines in the plain whois excerpt come from a re-run at about 14:00 UTC. The addresses are well-known public services (8.8.8.8, 1.1.1.1, 9.9.9.9 and others) plus reserved documentation and private addresses for the unrouted cases. Every output block carries its date and client, and nothing is reconstructed from memory.
$ whois -h whois.cymru.com " -v 8.8.8.8"
AS | IP | BGP Prefix | CC | Registry | Allocated | AS Name
15169 | 8.8.8.8 | 8.8.8.0/24 | US | arin | 2023-12-28 | GOOGLE - Google LLC, US
$ whois -h whois.cymru.com "-v 8.8.8.8"
whois: illegal option -- v
usage: whois [-aAbfgiIklmPQrRS] [-c country-code | -h hostname] [-p port] name ...The space before -v inside the quotes is not decoration. Without it, the macOS whois client tried to parse -v as its own option and refused, as the second command shows. Team Cymru's page tells you to quote the query with a leading space for the same reason, so the local client does not read the flags. The columns are the origin AS, the address, the BGP prefix, the registry's country code, the registry, an allocation date and the AS name.
Do not put two addresses on one query line. We expected an error, but the server answered for the first address only and printed the second in an Info column, so the second lookup is silently dropped.
$ whois -h whois.cymru.com " -v 1.1.1.1 8.8.8.8"
AS | IP | BGP Prefix | CC | Registry | Allocated | Info | AS Name
13335 | 1.1.1.1 | 1.1.1.0/24 | AU | apnic | 2011-08-11 | 8.8.8.8 | CLOUDFLARENET - Cloudflare, Inc., USFor several addresses, use bulk mode: send begin, verbose, one address per line and end to port 43 in one connection. Team Cymru recommends this over many single queries and says that sources sending large numbers of individual whois queries get null-routed. It also says to use GNU netcat rather than the standard nc, which it warns may truncate output. We only had the macOS nc. Our first attempt printed nothing. Holding stdin open for five seconds and setting a timeout made all six rows come back. We also sent the nine addresses used later in one bulk request and got nine rows. We did not test GNU netcat or lists longer than nine addresses.
$ (printf 'begin\nverbose\n8.8.8.8\n1.1.1.1\n9.9.9.9\n151.101.1.69\n140.82.112.3\n66.249.66.1\nend\n'; sleep 5) | nc -w 10 whois.cymru.com 43
Bulk mode; whois.cymru.com [2026-12-01 13:42:05 +0000]
15169 | 8.8.8.8 | 8.8.8.0/24 | US | arin | 2023-12-28 | GOOGLE - Google LLC, US
13335 | 1.1.1.1 | 1.1.1.0/24 | AU | apnic | 2011-08-11 | CLOUDFLARENET - Cloudflare, Inc., US
19281 | 9.9.9.9 | 9.9.9.0/24 | US | arin | 2017-09-13 | QUAD9-AS-1 - Quad9, US
54113 | 151.101.1.69 | 151.101.0.0/22 | US | arin | 2016-02-01 | FASTLY - Fastly, Inc., US
36459 | 140.82.112.3 | 140.82.112.0/24 | US | arin | 2018-04-25 | GITHUB - GitHub, Inc., US
15169 | 66.249.66.1 | 66.249.64.0/20 | US | arin | 2004-03-05 | GOOGLE - Google LLC, USThe same data over DNS
The DNS interface returns the same mapping fields as a TXT record, except the AS name. You build the name by reversing the address and adding origin.asn.cymru.com, and a second query to AS15169.asn.cymru.com returns the AS name and owner. Team Cymru describes DNS as cacheable, lighter than whois and the better fit for recurring or automated lookups, and says a prefix it does not hold returns NXDOMAIN.
$ dig +short TXT 8.8.8.8.origin.asn.cymru.com
"15169 | 8.8.8.0/24 | US | arin | 2023-12-28"
$ dig +short TXT AS15169.asn.cymru.com
"15169 | US | arin | 2000-03-30 | GOOGLE - Google LLC, US"
$ dig +short TXT 1.66.249.66.origin.asn.cymru.com # reversed 66.249.66.1
"15169 | 66.249.64.0/20 | US | arin | 2004-03-05"
"15169 | 66.249.64.0/19 | US | arin | 2004-03-05"
$ dig TXT 5.113.0.203.origin.asn.cymru.com | grep -E 'status|SOA' # reversed 203.0.113.5
;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 48298
asn.cymru.com. 900 IN SOA ns1.asn.cymru.com. noc.cymru.com. 1796129888 1800 900 86400 900Two details matter in code. An unrouted address, here the documentation address 203.0.113.5, is a DNS error (NXDOMAIN), not an empty answer, and +short hides the status line, so check the response code if you need to tell "no route" from "query failed". And 66.249.66.1 returned two rows, one for each route that covers it, in the order /20 then /19. Keep every row and pick the longest prefix (our rule) instead of taking the first one.
Reversing the octets is easy to get wrong
If you forget to reverse the octets, you do not get an error. You get a valid answer for a different address. 8.8.8.8 reads the same backwards, so it hides the mistake. We queried 140.82.112.3 both ways:
$ dig +short TXT 140.82.112.3.origin.asn.cymru.com # wrong: this asks about 3.112.82.140
"16509 | 3.64.0.0/10 | US | arin | 2017-12-20"
"16509 | 3.112.0.0/14 | US | arin | 2017-12-20"
$ dig +short TXT 3.112.82.140.origin.asn.cymru.com # right for 140.82.112.3
"36459 | 140.82.112.0/24 | US | arin | 2018-04-25"
"36459 | 140.82.112.0/20 | US | arin | 2018-04-25"The wrong query is a plausible AS number (16509), which would pass a casual check. We also saw the row order change between two identical queries for that wrong name: /14 then /10 the first time, /10 then /14 the second. We did not study the ordering further, but it is enough reason to sort by prefix length in code.
Team Cymru's page describes IPv6 lookups under origin6.asn.cymru.com using the reversed nibbles of the address, one label per hexadecimal digit.
Our advice is to generate that string with a script rather than by hand, because the address has 32 labels once fully expanded. Our IPv4 vs IPv6 lookup article shows what that expanded form looks like and how a lookup normalises the different ways of writing one address.
$ python3 -c 'import ipaddress;a=ipaddress.ip_address("2001:4860:4860::8888");print(".".join(reversed(a.exploded.replace(":","")))+".origin6.asn.cymru.com")'
8.8.8.8.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.6.8.4.0.6.8.4.1.0.0.2.origin6.asn.cymru.com
$ dig +short TXT 8.8.8.8.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.6.8.4.0.6.8.4.1.0.0.2.origin6.asn.cymru.com
"15169 | 2001:4860::/32 | US | arin | 2005-03-14"Why plain whois and RISwhois answer different questions
Plain whois asks a registry who holds an address block. That is registration data, not routing data, and the two can differ. We ran it for 8.8.8.8, where whois followed the IANA referral to ARIN, and for 1.1.1.1, which went to APNIC. The ARIN record has an OriginAS field and it was blank for 8.8.8.8 and for 9.9.9.9, and neither reply contained a route object. The APNIC reply has no OriginAS field in the address record, but it names the routing AS in a free-text description line and appends a separate route object with the origin AS13335.
$ whois 8.8.8.8 # ARIN record, selected lines
NetRange: 8.8.8.0 - 8.8.8.255
CIDR: 8.8.8.0/24
NetName: GOGL
NetType: Direct Allocation
OriginAS:
Organization: Google LLC (GOGL)
RegDate: 2023-12-28
$ whois 1.1.1.1 # APNIC reply: the address record, then a separate route object
inetnum: 1.1.1.0 - 1.1.1.255
netname: APNIC-LABS
descr: APNIC and Cloudflare DNS Resolver project
descr: Routed globally by AS13335/Cloudflare
country: AU
% Information related to '1.1.1.0/24AS13335'
route: 1.1.1.0/24
origin: AS13335
descr: APNIC Research and Development
source: APNICThat variety follows from the protocol. RFC 3912 defines only the exchange (a text query over TCP port 43, a text reply, then the server closes the connection) and, in our reading of it, defines the reply only as text with no field structure, so each registry formats its own. Parsing plain whois for an ASN usually means one parser per registry, and the record may still not contain the answer. Team Cymru's allocation date for 8.8.8.0/24 (2023-12-28) matches the ARIN RegDate above, which fits its statement that those fields come from registry records.
RISwhois shows every route that covers the address
The RIPE NCC's RISwhois service reports routes seen in BGP data collected by its route collectors and returns RPSL-style records. Its documentation says the -M flag, for an IP address, returns only the longest matches. Our default query for 8.8.8.8 returned three covering routes.
$ whois -h riswhois.ripe.net 8.8.8.8
route: 8.0.0.0/9
origin: AS3356
route: 8.0.0.0/12
origin: AS3356
route: 8.8.8.0/24
origin: AS15169
$ whois -h riswhois.ripe.net " -M 8.8.8.8"
route: 8.8.8.0/24
origin: AS15169Reading the first block gives AS3356, which is the covering aggregate, not the network announcing 8.8.8.8's /24. Our rule is to take the most specific route, which is standard longest-prefix matching. None of the pages we read states it as a rule, so treat it as our editorial choice.
The RIS page documents -M as returning only the longest matches for an IP address. In our run -M returned only the /24, while -1 and -L still returned all three routes. For IPv6, the default query for 2001:4860:4860::8888 returned four routes: 2000::/3, two different origins for 2000::/6, and the /32 announced by AS15169.
Script it with RIPEstat or the IPCheckHQ API
RIPEstat's network-info call takes an IP address and returns the prefix it falls under and the ASNs announcing that prefix. RIPE's page says it is based on RISwhois, which the page describes as based on 8-hour data dumps, so in our reading a result can lag by about the dump interval. RIPEstat's data API sets no request cap, asks you to register with the RIPE NCC if you make more than 1,000 requests a day on a regular basis, and allows 8 concurrent requests per IP address.
$ curl -s "https://stat.ripe.net/data/network-info/data.json?resource=1.1.1.1" | jq '.data'
{
"asns": [
"13335"
],
"prefix": "1.1.1.0/24"
}
$ curl -s "https://stat.ripe.net/data/prefix-overview/data.json?resource=8.8.8.8" | jq '.data | {announced, asns, resource, related_prefixes}'
{
"announced": true,
"asns": [
{
"asn": 15169,
"holder": "GOOGLE - Google LLC"
}
],
"resource": "8.8.8.0/24",
"related_prefixes": [
"8.0.0.0/9",
"8.0.0.0/12"
]
}
$ curl -s "https://stat.ripe.net/data/as-overview/data.json?resource=AS15169" | jq '.data | {resource, holder, announced}'
{
"resource": "15169",
"holder": "GOOGLE - Google LLC",
"announced": true
}network-info answers "which ASN and prefix" in one small object. prefix-overview describes the prefix: whether it is announced, the originating ASNs with holder names, and related prefixes, which here are the two shorter routes that RISwhois also listed. as-overview names the holder of an AS number. RIPE's prefix-overview page says results are filtered by how many RIS peers see a route, so a route seen by few peers can be missing.
Our API, and what it does not return
We run an IP lookup API and an ASN lookup tool, so we tested them the same way. GET /api/v1/ip/{ip} returns the ASN in its network object, and GET /api/v1/asn/{asn} returns facts for an AS number. The data is a derived IP-to-ASN mapping from the DB-IP ASN Lite database, and the API's own source note says it is not live BGP routing or registry data. It does not return a prefix for an IP, so the prefix comparison below covers Team Cymru and RIPEstat only. The responses carry rate-limit headers, so read them before you loop.
$ curl -s https://ipcheckhq.com/api/v1/ip/8.8.8.8 | jq '.network'
{
"asn": 15169,
"asn_name": "Google LLC",
"isp": "Google LLC",
"organization": "Google LLC",
"connection_type": "hosting"
}
$ curl -s https://ipcheckhq.com/api/v1/asn/15169 | jq '{asn, organization, prefixes, source}'
{
"asn": 15169,
"organization": "Google LLC",
"prefixes": {
"ipv4": 185,
"ipv6": 31
},
"source": {
"database_build": "2026-12-01",
"attribution": "IP geolocation and ASN data by DB-IP (https://db-ip.com), CC BY 4.0",
"limitation": "Derived IP-to-ASN mapping from the DB-IP ASN Lite database, not live BGP routing or RIR registration data. Prefix counts and address space describe what that database attributes to the ASN."
}
}
$ curl -s https://ipcheckhq.com/api/v1/ip/203.0.113.5 | jq '{success, network, special_range}'
{
"success": true,
"network": {
"asn": null,
"asn_name": null,
"isp": null,
"organization": null,
"connection_type": null
},
"special_range": "documentation"
}
$ curl -s -o /dev/null -w 'HTTP %{http_code}\n' https://ipcheckhq.com/api/v1/asn/64496
HTTP 404For a documentation address the IP endpoint reports success with a null ASN and names the special range, and an AS number that is not in the database returns 404. Treat a null ASN as "no answer", not as an error, and check success and the HTTP status separately.
Nine IPs, three sources: where they agree and where they trip you
To see how far the methods diverge in practice, we ran one script over nine routed public IPs on one day: Google and Cloudflare resolvers, Quad9, OpenDNS, Fastly, GitHub, a second Cloudflare address, a Microsoft address and a second Google address. It does a Team Cymru DNS lookup (longest prefix kept), a RIPEstat network-info call, and an IPCheckHQ API call for each.
#!/usr/bin/env bash
# Origin ASN and prefix for each IP from three sources: Team Cymru DNS,
# RIPEstat network-info, and the IPCheckHQ API (ASN only: it returns no prefix).
set -u
ips="8.8.8.8 1.1.1.1 9.9.9.9 208.67.222.222 151.101.1.69 140.82.112.3 104.16.0.1 132.196.86.2 66.249.66.1"
printf '%-16s | %-22s | %-22s | %-8s\n' IP "Cymru DNS (AS prefix)" "RIPEstat (AS prefix)" "IPCheckHQ"
for ip in $ips; do
rev=$(echo "$ip" | awk -F. '{print $4"."$3"."$2"."$1}')
# Cymru can return several TXT rows (one per covering prefix): keep all, show the longest.
cy_all=$(dig +short TXT "$rev.origin.asn.cymru.com" | tr -d '"')
cy=$(echo "$cy_all" | awk -F' [|] ' 'NF{split($2,p,"/"); if (p[2]+0>=best) {best=p[2]+0; a=$1; pre=$2}} END{if(a) print a" "pre; else print "none"}')
cy_n=$(echo "$cy_all" | grep -c .)
ri=$(curl -s "https://stat.ripe.net/data/network-info/data.json?resource=$ip" | jq -r '(.data.asns | join(",")) + " " + .data.prefix')
ap=$(curl -s "https://ipcheckhq.com/api/v1/ip/$ip" | jq -r '.network.asn // "null"')
printf '%-16s | %-22s | %-22s | %-8s | cymru rows: %s\n' "$ip" "$cy" "$ri" "$ap" "$cy_n"
doneIP | Cymru DNS (AS prefix) | RIPEstat (AS prefix) | IPCheckHQ
8.8.8.8 | 15169 8.8.8.0/24 | 15169 8.8.8.0/24 | 15169 | cymru rows: 1
1.1.1.1 | 13335 1.1.1.0/24 | 13335 1.1.1.0/24 | 13335 | cymru rows: 1
9.9.9.9 | 19281 9.9.9.0/24 | 19281 9.9.9.0/24 | 19281 | cymru rows: 1
208.67.222.222 | 36692 208.67.222.0/24 | 36692 208.67.222.0/24 | 36692 | cymru rows: 1
151.101.1.69 | 54113 151.101.0.0/22 | 54113 151.101.0.0/22 | 54113 | cymru rows: 1
140.82.112.3 | 36459 140.82.112.0/24 | 36459 140.82.112.0/24 | 36459 | cymru rows: 2
104.16.0.1 | 13335 104.16.0.0/20 | 13335 104.16.0.0/20 | 13335 | cymru rows: 1
132.196.86.2 | 8075 132.196.0.0/16 | 8075 132.196.0.0/16 | 8075 | cymru rows: 1
66.249.66.1 | 15169 66.249.64.0/20 | 15169 66.249.64.0/20 | 15169 | cymru rows: 2- Origin ASN agreement
- 9 of 9
- Team Cymru DNS, RIPEstat and the IPCheckHQ API, one day
- Prefix agreement
- 9 of 9
- Team Cymru DNS (longest row) and RIPEstat; our API returns no prefix
- Addresses with two Cymru DNS rows
- 2 of 9
- 140.82.112.3 and 66.249.66.1, one row per covering route
On this day the three sources agreed on the origin ASN for every address, and Team Cymru and RIPEstat agreed on the prefix for every address once we kept the longest Cymru row. We saw no prefix disagreement. One would appear if you compared RIPEstat's prefix with the shorter of Cymru's two rows. For 140.82.112.3 the covering routes are a /24 and a /20, and for 66.249.66.1 a /20 and a /19. Code that reads the first TXT row can land on either, and we saw that order vary. Nine addresses on one day is a small sample. It shows the methods can agree, not that they always will, and Team Cymru notes that a broader and a more specific announcement can carry different ASNs, which it treats as normal routing policy.
The country column is the registry's, not the operator's
Team Cymru states that its country, registry and allocation date come straight from the regional registries' records, that they are not geolocation, and that they can differ from where an address is used. Our run shows it. The Microsoft address 132.196.86.2 comes back as GB, registry ripencc and allocated 1989-03-13, with the AS name MICROSOFT-CORP-MSN-AS-BLOCK - Microsoft Corporation, US. Our API reported US for that address's location, and 1.1.1.1 shows AU in Cymru's output, matching the country line in its APNIC record. Do not use the CC column to decide where traffic comes from.
Documentation and private addresses return no origin
We also sent four addresses with no origin through each source: 203.0.113.5, 192.0.2.1 and 2001:db8::1 (documentation ranges) and 10.0.0.1 (private). Each tool reports the absence differently, which matters when you parse the output.
| Source | What it returned |
|---|---|
| Team Cymru DNS | NXDOMAIN status, no TXT record |
| Team Cymru whois | A row with NA as the AS, NA as the prefix, no country, and the registry other |
| RIPEstat network-info | An empty asns list and an empty prefix string |
| IPCheckHQ API | success true, a null ASN, and a special_range of documentation or private |
Which method for which job
The table collects what we ran. Speeds are runs for 8.8.8.8 from one machine and one network: three consecutive runs at 13:47 UTC, three more at 14:00 UTC, and a separate re-run at a different time that came out somewhat lower for DNS, RIPEstat and RISwhois. The ranges cover all of them, but treat them as indicative only, not a benchmark. DNS repeats may come from a cache.
| Method | What it gives you | Bulk | IPv6 | Time for 8.8.8.8 (indicative) | Limits we hit or read |
|---|---|---|---|---|---|
| Team Cymru whois | Origin AS, prefix, registry country, allocation date, AS name | Yes: begin and end over port 43 (we ran 6 IPs, then 9) | Yes, tested | About 570 to 650 ms | Heavy single-query volume can be null-routed per Team Cymru; the CC column is not geolocation |
| Team Cymru DNS | The same fields in a TXT record; owner from a second query | One query per IP (we looped 9) | Yes, via origin6 and reversed nibbles, tested | About 50 to 80 ms | You reverse the address yourself; several rows are possible, so keep the longest prefix (our rule); NXDOMAIN when unrouted |
| RIPEstat network-info | ASNs and prefix as JSON | One request per IP (we looped 9) | Yes, tested | About 440 to 525 ms | Based on 8-hour dumps; no cap, but register above 1,000 requests a day; 8 concurrent per IP |
| RISwhois | Every covering route with its origin, or only the longest with -M | Not tested | Yes, tested | About 290 to 350 ms | The default output lists shorter covering routes first, so under our longest-prefix rule the first block is not the answer |
| Plain whois | Who holds the address block, with contacts | Not tested | Not tested | About 1.1 to 4.4 s | ARIN replies for 8.8.8.8 and 9.9.9.9 had a blank OriginAS and no route object; the APNIC reply for 1.1.1.1 has no OriginAS field but appends a separate route object with origin AS13335; format differs by registry |
| IPCheckHQ API | ASN, organization and network type from a DB-IP derived database | One request per IP (we looped 9) | Yes, tested | About 600 to 780 ms | Not live BGP or registry data; no prefix for an IP; rate limited |
For a one-off lookup in a terminal, use Team Cymru whois. For a script or a recurring job, use Team Cymru DNS or RIPEstat, keep every returned route and choose the longest prefix (our rule), and treat a missing answer as its own case. For a few dozen addresses, use bulk mode instead of a loop of single whois calls. Use plain whois when you want the registered owner and abuse contacts, not the origin AS. If you want the answer in a browser, or alongside location and network type, use our ASN lookup or the full IP lookup. For routing questions where the latest announcement matters, such as a hijack or a recent migration, check a live looking glass, because every dataset here is a snapshot.
Questions readers ask
ip asn lookup
For one address, run whois -h whois.cymru.com " -v 8.8.8.8" and read the first column, which was 15169 on 1 December 2026. In a browser, enter the address in our ASN lookup. From code, call GET /api/v1/ip/8.8.8.8 and read network.asn, which was also 15169.
asn by ip
The ASN for an IP is the origin AS of a route that covers it. When a tool lists several routes, our rule is to take the one with the longest prefix, as in the RISwhois example for 8.8.8.8 where the /24 held AS15169 and the shorter routes held AS3356.
Team Cymru's page says one prefix can show more than one origin ASN, and that a broader and a more specific announcement covering the same address can return different ASNs, so a single answer is not guaranteed.
ip to asn
Pass the address to a mapping service and read the AS number it returns. The DNS route is a TXT query on the reversed address, for example 8.8.8.8.origin.asn.cymru.com returning 15169. The reverse direction, from an AS number to its owner and prefix counts, is AS15169.asn.cymru.com for the owner or GET /api/v1/asn/15169 for the facts our database holds, which our ASN lookup page also shows.
ip to asn mapping
An IP-to-ASN mapping is a table of prefixes and the AS that originates each, built from BGP routing data. Team Cymru says its mapping is built from more than 50 BGP peers and refreshed every 4 hours, and RIPEstat's network-info is based on RISwhois, which its page describes as based on 8-hour data dumps. Our ASN lookup and API use a DB-IP database build instead, dated 2026-12-01 in our run, so they can differ from live routing. For 8.8.8.8, all of them returned AS15169.
how to get asn
If you mean finding the ASN behind an address you have in a log, use any of the methods above: Team Cymru whois or DNS in a terminal, RIPEstat in a script, or our ASN lookup. A common next step is to check whether the network is a hosting provider, which we cover when verifying a crawler's source IP.
