IP to ASN Lookup Explained: How to Find the Autonomous System Behind an IP Address

You have an IP address in an NGINX log, firewall alert, DNS query log, SIEM event, or traceroute.

You know the address.

But who operates the network behind it?

That is where an IP to ASN lookup becomes useful.

An IP ASN lookup can help you determine which Autonomous System is announcing the network prefix containing an IP address. For a sysadmin, network engineer, DevOps engineer, or SOC analyst, this gives you more useful context than the IP address alone.

Instead of seeing:

IP: <PUBLIC_IP>

you may be able to determine:

IP:         <PUBLIC_IP>
Prefix:     <ROUTED_PREFIX>
Origin ASN: <ASN>
Network:    <NETWORK_NAME>
Registry:   <RIR>

That can help answer questions such as:

  • Which ISP or network operator is behind this address?
  • Is this traffic coming from a cloud provider, broadband ISP, mobile carrier, or hosting network?
  • Which network is announcing this prefix in BGP?
  • Are several suspicious addresses coming from the same ASN?
  • Does a routing problem affect one ASN more than another?
  • Which ASN should be used when classifying a requester for network policy?

This guide explains what an ASN is, how IP addresses become associated with Autonomous Systems, and how to perform practical ASN lookups from Linux.

It also explains an important limitation:

An ASN identifies a network routing domain. It does not identify an individual person.


What Is an Autonomous System?

An Autonomous System, usually shortened to AS, is a network or group of networks operated under a common routing administration.

The Internet is not one network.

It is a large collection of independently operated networks exchanging routing information with each other.

Those networks may belong to:

  • Internet service providers
  • Mobile carriers
  • Cloud providers
  • Hosting companies
  • Universities
  • Enterprises
  • Content delivery networks
  • Government networks
  • Research networks
  • Internet exchanges and related infrastructure

BGP, or Border Gateway Protocol, is the protocol used between these networks to exchange routing information.

RFC 4271 defines an Autonomous System in terms of a set of routers under a common technical administration that presents a coherent routing policy to other Autonomous Systems.

Each public Autonomous System normally has an Autonomous System Number, or ASN.

You will commonly see an ASN written like this:

AS64496

or simply:

64496

Modern BGP supports four-octet, or 32-bit, AS numbers. RFC 6793 extended BGP beyond the original two-octet ASN space.

IANA manages the global ASN number space and allocates ASN blocks to the five Regional Internet Registries:

  • APNIC
  • ARIN
  • RIPE NCC
  • AFRINIC
  • LACNIC

The RIRs then assign or allocate ASNs according to their regional policies. The Philippines falls within the APNIC service region.


IP Address, Prefix, BGP Route, ASN, and Network Operator

The easiest way to understand an IP-to-ASN lookup is to follow the relationship between five things:

IP address
    |
    v
Network prefix
    |
    v
BGP route announcement
    |
    v
Origin ASN
    |
    v
Network operator

Consider a documentation-only example:

IP address:
203.0.113.25

Containing prefix:
203.0.113.0/24

Origin:
AS64496

Operator:
Example Network

The IP address identifies one address.

The prefix represents a block of addresses.

A network advertises reachability for that prefix through BGP.

The Autonomous System originating that BGP route has an ASN.

An IP-to-ASN database uses routing information to build this relationship:

203.0.113.25
        |
        v
203.0.113.0/24
        |
        v
BGP announcement
        |
        v
AS64496

The values above are documentation examples. They are deliberately not real ownership claims. RFC 5737 reserves 203.0.113.0/24, along with 192.0.2.0/24 and 198.51.100.0/24, for IPv4 documentation. RFC 5398 reserves specific AS number ranges for documentation as well.


What Does the “ASN Behind an IP” Actually Mean?

When someone asks:

What is the ASN of this IP?

they usually mean:

Which Autonomous System currently originates the BGP route covering this IP address?

That wording matters.

An IP address itself does not permanently contain an ASN.

The association is derived from routing information.

For example:

IP
|
v
Find most-specific visible BGP prefix
|
v
Find AS originating that route
|
v
Return origin ASN

That origin may change.

This is why IP-to-ASN information should be treated as routing intelligence rather than a permanent attribute embedded in an address.


Registration Data Is Not the Same as Routing Data

This is one of the most important distinctions when performing an ASN lookup.

Two different questions are often mixed together.

Question 1: Who is the IP space registered to?

WHOIS and RDAP are useful here.

Regional Internet Registries maintain registration information about:

  • IPv4 allocations and assignments
  • IPv6 allocations and assignments
  • Autonomous System Numbers
  • Organizations
  • Network contacts
  • Abuse contacts

APNIC, for example, maintains inetnum, inet6num, and aut-num records for Internet number resources in the Asia-Pacific region.

Question 2: Which ASN is currently announcing the route?

For this, you want BGP routing data.

Useful sources include:

  • RIPE RIS
  • RIPEstat
  • Team Cymru IP-to-ASN Mapping
  • Other reputable BGP collectors and routing-analysis platforms

These observe routing information rather than only resource registration.

The distinction looks like this:

RDAP / WHOIS
        |
        +--> Who is this resource registered to?

BGP routing data
        |
        +--> Which ASN is currently originating this prefix?

Those answers can be different.

For example, address space may be registered to one organization but announced by:

  • A customer’s ASN
  • A hosting provider
  • A DDoS mitigation provider
  • A cloud network
  • Another provider under a routing agreement

So if your question is specifically IP to ASN, BGP origin information is usually the stronger signal.

Use RDAP or WHOIS to add registration context.


Method 1: IP to ASN Lookup with Team Cymru WHOIS

One of the easiest command-line methods is Team Cymru’s public IP-to-ASN mapping service.

The service maps an IP address to information including:

  • BGP origin ASN
  • IP address
  • BGP prefix
  • Registry
  • Allocation information
  • AS description

Team Cymru states that its mapping service uses BGP feeds from more than 50 peers and refreshes the data periodically.

On Linux, install the whois client if needed.

Ubuntu or Debian:

sudo apt update
sudo apt install whois

Then query a real public address from your logs:

whois -h whois.cymru.com " -v <PUBLIC_IP>"

The leading space before -v is intentional. It prevents some local whois clients from treating the option as their own.

The output structure looks similar to this:

AS      | IP          | BGP Prefix       | CC | Registry | Allocated  | AS Name
<ASN>   | <IP>        | <PREFIX>         | XX | <RIR>    | <DATE>     | <NAME>

You might extract only the important fields:

Origin ASN
BGP prefix
Registry
AS name

That gives you a fast answer for incident investigation or troubleshooting.

Team Cymru’s documentation is available here: Team Cymru IP to ASN Mapping Service


Method 2: DNS-Based IP to ASN Lookup

Team Cymru also provides DNS-based ASN lookups.

This is useful when you need lightweight, cacheable queries.

For IPv4, reverse the octets of the address and query:

origin.asn.cymru.com

Suppose the real address were:

A.B.C.D

The query would become:

dig +short D.C.B.A.origin.asn.cymru.com TXT

The returned structure is similar to:

"<ASN> | <PREFIX> | <CC> | <REGISTRY> | <ALLOCATED_DATE>"

For example, if you are processing an address from a web log, your workflow can be:

Source IP
   |
   v
Reverse IPv4 octets
   |
   v
DNS TXT lookup
   |
   v
ASN + BGP prefix

The documentation address 198.51.100.25 would produce the query form:

dig +short 25.100.51.198.origin.asn.cymru.com TXT

Do not expect a normal public routing result from documentation prefixes. They exist specifically for examples and should not represent ordinary globally routed customer networks.

For real investigation work, replace the address with the real public IP from your logs.

Team Cymru also supports IPv6 through its origin6.asn.cymru.com zone. IPv6 uses reversed hexadecimal nibbles rather than reversed IPv4 octets.


Method 3: Look Up the BGP Origin with RIPEstat

RIPEstat provides another useful source.

Its Network Info API accepts an IP address and returns:

  • The matching routed prefix
  • The ASN or ASNs announcing that prefix

The data comes from RIPE RIS routing observations.

You can query it with curl.

curl -s \
  "https://stat.ripe.net/data/network-info/data.json?resource=<PUBLIC_IP>"

If you have jq installed:

curl -s \
  "https://stat.ripe.net/data/network-info/data.json?resource=<PUBLIC_IP>" \
  | jq '.data | {prefix, asns}'

Expected structure:

{
  "prefix": "<MATCHING_PREFIX>",
  "asns": [
    <ORIGIN_ASN>
  ]
}

This format is useful because it makes the relationship explicit:

IP
    -> BGP prefix
        -> origin ASN

The RIPEstat Network Info API documentation is available here: RIPEstat Network Info API


Method 4: Use RDAP for Registration Context

RDAP stands for Registration Data Access Protocol.

It is the modern standardized alternative to traditional WHOIS for accessing Internet resource registration information.

Unlike traditional WHOIS’s mostly free-form text responses, RDAP uses HTTP and JSON.

APNIC describes RDAP as providing standardized queries and responses, internationalization support, and registry redirection capabilities.

For APNIC-managed resources, the general request format is:

/ ip / <IP_ADDRESS>

You can use curl and inspect the JSON response:

curl -s \
  "https://rdap.apnic.net/ip/<PUBLIC_IP>" \
  | jq

For an ASN:

curl -s \
  "https://rdap.apnic.net/autnum/<ASN>" \
  | jq

The specific RIR should normally be determined through RDAP’s bootstrap and referral mechanisms rather than assuming every address belongs to one registry.

ARIN likewise documents RDAP queries using forms such as:

<rdap-server>/ip/<IP>

and:

<rdap-server>/autnum/<ASN>

What RDAP tells you

RDAP is valuable for finding information such as:

Registered network range
Network name
Resource holder
Registration status
RIR
Contact or abuse information
ASN registration

But remember:

Registration does not automatically prove which ASN is currently originating the prefix in BGP.

Use routing data for that.


Traditional WHOIS Is Still Useful

Traditional WHOIS remains useful, especially during quick investigations.

For APNIC space:

whois -h whois.apnic.net <PUBLIC_IP>

An APNIC IP lookup can return the most specific registered network and related route objects.

APNIC documents command-line IP address searches and routing-related objects through its public WHOIS database.

After discovering an ASN, you can query it directly:

whois -h whois.apnic.net AS<ASN>

An aut-num object can contain fields such as:

aut-num:
as-name:
descr:
country:
org:
admin-c:
tech-c:
abuse-c:
mnt-by:
source:

APNIC notes that aut-num objects describe Autonomous Systems and can also assist network administrators when debugging network problems.


A Practical Linux ASN Lookup Workflow

For one suspicious or interesting IP, I normally recommend separating the investigation into stages.

Step 1: Make sure it is a public address

ipcalc <IP>

or inspect the address manually.

If it belongs to private or special-purpose space, a public ASN lookup may not make sense.

Step 2: Find the BGP origin

Use Team Cymru:

whois -h whois.cymru.com " -v <PUBLIC_IP>"

or RIPEstat:

curl -s \
  "https://stat.ripe.net/data/network-info/data.json?resource=<PUBLIC_IP>" \
  | jq '.data | {prefix, asns}'

Step 3: Record the prefix

Do not save only:

ASN: ASxxxxx

Save:

IP:        <IP>
Prefix:    <PREFIX>
Origin:    AS<ASN>
Lookup at: <TIMESTAMP>

The prefix is important when you later investigate routing changes.

Step 4: Check registration data

Use RDAP or the appropriate RIR WHOIS service.

Now you can compare:

Routing view:
Origin ASN = ASxxxxx

Registration view:
Address holder = Organization A

ASN record:
ASxxxxx = Organization B

Sometimes A and B are the same.

Sometimes they are not.

Step 5: Validate when the result matters

If this information will affect:

  • Blocking decisions
  • Routing policy
  • Incident attribution
  • DNS steering
  • Abuse escalation
  • Security automation

check another independent source.

Do not build a production decision around one stale lookup response.


Public, Private, and Documentation IP Addresses

Not every IP address should have a public ASN.

RFC 1918 private IPv4 addresses

The familiar private IPv4 ranges include:

10.0.0.0/8
172.16.0.0/12
192.168.0.0/16

RFC 1918 defines these ranges for private internets. They are not meant to be globally routed as ordinary public Internet prefixes.

If your application log shows:

192.168.1.50

an Internet ASN lookup will not tell you which ISP the end user belongs to.

You are looking at an internal address.

You need to find the public address after NAT, a reverse proxy, load balancer, VPN, or other network boundary.

Documentation IPv4 addresses

For examples in documentation, use:

192.0.2.0/24
198.51.100.0/24
203.0.113.0/24

These are reserved by RFC 5737.

IPv6 documentation

The classic IPv6 documentation prefix is:

2001:db8::/32

RFC 3849 reserved it for documentation examples.

IPv6 Unique Local Addresses

IPv6 also has Unique Local Addresses under:

fc00::/7

These are intended for local communications and are not expected to be routed on the global Internet.


Public, Private, and Documentation ASNs

ASN values also have special ranges.

For documentation examples, IANA reserves:

AS64496-AS64511
AS65536-AS65551

Private-use ASN ranges include:

AS64512-AS65534
AS4200000000-AS4294967294

RFC 6996 defines those private-use ranges and explains that private ASNs should not normally leak into the global Internet routing system.

That means this example is safe for documentation:

203.0.113.0/24 -> AS64496

It should be understood as an illustration, not an assertion that a real organization owns or announces the prefix.


IPv4 and IPv6 ASN Lookup

The basic concept is the same for IPv4 and IPv6.

IPv4

IPv4 address
    |
    v
Most-specific IPv4 route
    |
    v
Origin ASN

IPv6

IPv6 address
    |
    v
Most-specific IPv6 route
    |
    v
Origin ASN

The address format changes.

The routing concept does not.

RIPEstat’s Network Info endpoint accepts IP addresses and can return the containing routed prefix and announcing ASN information. APNIC RDAP likewise supports IPv4 and IPv6 registration lookups.

Do not build an enrichment pipeline that assumes only IPv4.

A log schema should be able to handle both:

source_ip
ip_version
prefix
origin_asn
as_name
registry
lookup_timestamp

Why IP-to-ASN Data Can Change

An ASN lookup is not necessarily permanent.

Suppose today you obtain:

IP
 |
 v
Prefix A
 |
 v
AS X

Later the same address may appear through:

IP
 |
 v
More-specific Prefix B
 |
 v
AS Y

Several things can cause this.

Routing changes

A network can change how it announces a prefix.

More-specific routes

BGP uses prefix matching.

A more-specific route can change which announcement applies to a particular IP.

For example:

198.51.100.0/23 -> AS64496

198.51.100.0/24 -> AS64497

An address inside the /24 follows the more-specific route when that route is visible and selected.

Network migrations

An organization may move:

  • Transit providers
  • Hosting platforms
  • DDoS protection
  • Network architecture
  • Address resources

Address transfers

Registration details can change when Internet number resources are transferred.

Temporary announcements

Routing events can temporarily produce different origin information.

Data refresh intervals

Lookup systems observe, process, and publish routing data at different intervals.

For example, Team Cymru documents periodic refreshes of its BGP-derived mapping, while RIPEstat’s Network Info endpoint is based on RIPE RIS data.

A lookup result should therefore have a timestamp.


Multi-Origin Prefixes: When One Prefix Has Multiple ASNs

Sometimes one prefix is visible as being originated by more than one ASN.

This is commonly described as a multi-origin AS, or MOAS, situation.

You might see:

Prefix:
<NETWORK_PREFIX>

Observed origin ASNs:
ASxxxxx
ASyyyyy

That does not automatically mean the data is wrong.

It may result from legitimate multihoming, migrations, anycast architecture, routing policy, or other arrangements.

It can also indicate a routing configuration problem or, in some cases, an unexpected route announcement.

Team Cymru explicitly notes that its service can return multiple ASNs for the same address or prefix when it observes different announcements from its routing vantage points.

RIPEstat’s routing-history API can also show the history of prefix announcements and their origin ASNs using RIPE RIS data.

Do not force a MOAS result into a single ASN without understanding why multiple origins are visible.


How to Validate Conflicting ASN Results

Suppose Tool A says:

AS64500

while Tool B says:

AS64501

Do not immediately assume one tool is broken.

Work through the problem.

1. Compare timestamps

Ask:

When was each source updated?

One service may be using newer BGP information.

2. Compare prefixes

Tool A may have matched:

198.51.100.0/23

while Tool B sees a more-specific:

198.51.100.0/24

The IP is the same.

The route view differs.

3. Look for multiple origins

Query routing data that can expose multiple origin ASNs.

4. Separate registry and routing answers

WHOIS may tell you:

Registered to Organization A

while BGP data tells you:

Originated by Organization B's ASN

That is not necessarily a contradiction.

5. Check another route collector

Use an independent BGP source when the answer affects an important operational decision.

6. Look at routing history

A recent origin change may explain why different systems disagree.

The main rule is:

Do not validate an IP-to-ASN result using only another copy
of the same underlying database.

Try to compare independent routing observations with authoritative registration data.


An ASN Does Not Identify a Person

This deserves its own section.

If an IP lookup says:

Origin ASN: ASxxxxx

you have identified a network routing domain.

You have not identified a specific individual.

A single ASN may represent:

  • Millions of broadband subscribers
  • Mobile users behind carrier-grade NAT
  • Thousands of virtual machines
  • A cloud provider
  • A university
  • An enterprise
  • A VPN service
  • A CDN
  • A hosting company

Even an individual public IP may represent many users behind NAT.

The relationship is closer to:

IP
 -> routed network
 -> ASN
 -> network operator

It is not:

IP
 -> ASN
 -> individual person

An ASN is useful network context.

It should not be treated as personal identity.


ASN Is Not GeoIP

Another common mistake is treating an ASN lookup as a location lookup.

It is not.

ASN information answers:

Which network is routing this prefix?

GeoIP tries to answer:

Where is this address probably being used?

Those are different questions.

A multinational cloud provider may have one ASN announcing infrastructure across many countries.

A mobile operator may route users through infrastructure far from their physical location.

A public resolver may use anycast.

A VPN address may represent a user somewhere else entirely.

Team Cymru specifically warns that its registry country codes should not be treated as IP geolocation data.

This distinction also matters in DNS decision systems.

PinoyLinux discusses the difference between geographic location, network distance, and actual latency in Latency, Geography, And Network Distance: What DNS Can And Cannot Know.


Operational Use: Network Troubleshooting

An ASN lookup becomes useful when a problem appears to affect only certain networks.

Suppose users report:

Provider A -> Service works normally
Provider B -> High latency
Provider C -> Packet loss

Grouping source addresses by ASN can expose a pattern.

Instead of looking at thousands of individual IPs:

IP 1
IP 2
IP 3
IP 4
IP 5
...

you may discover:

Most affected addresses
        |
        v
Same ASN

That can shift your investigation toward:

  • ISP routing
  • Peering
  • Transit
  • Prefix announcements
  • Regional interconnection
  • Carrier-specific issues

It does not prove that the ASN caused the incident.

It gives you a useful dimension for investigation.


Operational Use: Abuse and SOC Analysis

SOC teams can enrich security events with ASN data.

Instead of logging only:

{
  "source_ip": "<PUBLIC_IP>"
}

you could enrich the event:

{
  "source_ip": "<PUBLIC_IP>",
  "prefix": "<BGP_PREFIX>",
  "origin_asn": "<ASN>",
  "as_name": "<NETWORK_NAME>",
  "registry": "<RIR>"
}

Now analysts can ask:

How many alerts came from this ASN?

Are many addresses from the same hosting network scanning us?

Did a sudden attack involve one provider or many?

Are these IPs from residential networks or data-center networks?

Be careful with automated blocking.

Blocking an ASN can affect far more users than blocking one address.

A major ISP, cloud provider, or CDN may contain a huge number of legitimate systems.

ASN data is excellent for enrichment and correlation.

It should not automatically become a block rule.


Operational Use: Log Enrichment

ASN enrichment is useful for:

  • NGINX access logs
  • Apache logs
  • Firewall events
  • IDS/IPS alerts
  • SIEM records
  • DNS query logs
  • Authentication logs
  • API gateway logs
  • Abuse reports

A good enriched record might contain:

timestamp
source_ip
source_prefix
origin_asn
as_name
registry
country_if_separately_resolved
lookup_source
lookup_timestamp

Notice the final two fields:

lookup_source
lookup_timestamp

They matter.

Because ASN mappings can change, you need to know where the value came from and when it was collected.


How IP-to-ASN Lookup Connects to Requester Classification

PinoyLinux previously discussed requester classification, where a network system turns signals such as an IP address, prefix, country, ASN, resolver information, or ECS into useful routing context.

Read that deeper discussion in Inside Requester Classification: IP, ASN, Country, And Resolver Signals.

This article handles one specific step inside that larger process:

Requester IP
     |
     v
Find prefix
     |
     v
Map prefix to origin ASN
     |
     v
ASN becomes classification data

The ASN can then become one input among several.

For example:

Requester:
<IP>

Classification:
Country: PH
ASN: ASxxxxx
Prefix: <PREFIX>

A policy engine could use that information later.

But the IP-to-ASN lookup itself should remain a clean, independently testable operation.


How This Connects to DNS Steering

ASN-aware DNS steering uses the network identity behind a requester as one possible routing signal.

PinoyLinux’s DNS Steering 101: How Authoritative DNS Influences Traffic Direction explains the larger DNS decision process.

The practical relationship is simply:

DNS requester signal
        |
        v
IP or ECS prefix
        |
        v
IP-to-ASN lookup
        |
        v
Requester ASN
        |
        v
Routing policy

For example:

If ASN A:
    Prefer endpoint X

If ASN B:
    Prefer endpoint Y

Otherwise:
    Use default policy

The article Weighted, Geo, ASN, And Failover Routing: Steering Techniques Compared explains where ASN-aware routing fits among other steering techniques.

The important point for this guide is that the quality of the routing decision depends partly on the quality of the IP-to-ASN mapping.

Bad or stale mapping can produce bad classification.


DNS Resolver IP Versus Real Client ASN

There is an extra complication with authoritative DNS.

The source IP seen by an authoritative DNS server is normally the recursive resolver.

That means an IP-to-ASN lookup may identify:

ASN of recursive resolver

rather than:

ASN of actual end user

This distinction is important.

Example:

End user
   |
   v
Public recursive resolver
   |
   v
Authoritative DNS

The authoritative server may perform an ASN lookup on the resolver address.

That may identify the DNS provider’s ASN rather than the user’s ISP.

EDNS Client Subnet can sometimes provide part of the client network and improve this classification.

PinoyLinux covers the trade-offs in EDNS Client Subnet: Powerful Signal Or Operational Trap?.

ECS should still be treated as an optional network signal, not perfect knowledge.

This is why the IP-to-ASN lookup mechanism and the question “Which IP should I classify?” need to remain separate.


Troubleshooting: No ASN Found

Sometimes your lookup returns no ASN.

Work through these checks.

Is the IP private?

Examples:

10.x.x.x
172.16.x.x through 172.31.x.x
192.168.x.x

These do not have normal global BGP origin ASNs.

Is it a documentation address?

Examples:

192.0.2.x
198.51.100.x
203.0.113.x

These are not ordinary public production addresses.

Is it IPv6 local or special-purpose space?

Check whether it is a global IPv6 address before expecting a normal public ASN result.

Is the prefix currently routed?

An address can be registered but not presently visible in global BGP.

Registration does not guarantee a live global route.

Is the lookup source stale?

Try another BGP data source.

Did you query the correct address?

Reverse proxies and load balancers often make logs tricky.

Your application may have recorded:

proxy_ip

instead of:

client_ip

Check trusted proxy configuration before enriching the data.


Troubleshooting: Multiple ASNs Found

If a service returns:

ASxxxxx
ASyyyyy

do not discard one immediately.

Check:

  1. Whether the prefix is multi-origin.
  2. Whether different collectors see different announcements.
  3. Whether a routing transition is taking place.
  4. Whether one route is more specific.
  5. Whether anycast or multihoming explains the result.
  6. Whether the result changes across time.

Use routing history if necessary.


Troubleshooting: WHOIS and BGP Give Different Organizations

This is common enough that it should not surprise you.

You may have:

RDAP:
Prefix registered to Company A

BGP:
Prefix originated by AS belonging to Company B

Possible reasons include:

  • Customer-provider relationships
  • Provider-independent address space
  • Cloud hosting
  • DDoS mitigation
  • Transit arrangements
  • Bring-your-own-IP deployments
  • Network migrations

Ask what you actually need to know.

If you need the resource holder:

Use RIR registration data.

If you need the network currently announcing the route:

Use BGP origin data.

If you need both:

Record both.

Troubleshooting: ASN Data Looks Stale

Record:

IP
Prefix
ASN
Lookup source
Lookup time

Then compare another routing source.

Also check routing history.

If an ASN changed recently, both answers may have been correct at different times.

For operational systems, consider refreshing ASN data regularly rather than treating an IP-to-ASN mapping as permanent configuration.


A Better ASN Lookup Data Model

If you are building your own tooling, avoid storing only:

IP -> ASN

A better record is:

IP
|
+-- matched prefix
|
+-- origin ASN or ASNs
|
+-- ASN name
|
+-- RIR
|
+-- registration holder
|
+-- routing source
|
+-- lookup timestamp

This gives you enough context to troubleshoot disagreements later.

For example:

{
  "ip": "<PUBLIC_IP>",
  "prefix": "<MATCHED_PREFIX>",
  "origin_asns": [
    "<ASN>"
  ],
  "as_name": "<NAME>",
  "registry": "<RIR>",
  "lookup_source": "RIPE RIS",
  "looked_up_at": "<TIMESTAMP>"
}

If the prefix becomes multi-origin, the schema can already handle multiple ASNs.


Practical Rules for IP-to-ASN Lookups

Use these rules in production work:

  1. Check that the IP is globally routable before looking for a public ASN.
  2. Use BGP-derived data when you need the route origin.
  3. Use RDAP or WHOIS when you need registration information.
  4. Do not confuse resource registration with BGP origination.
  5. Record the matched prefix, not only the ASN.
  6. Support both IPv4 and IPv6.
  7. Expect mappings to change.
  8. Store a lookup timestamp and data source.
  9. Allow more than one origin ASN.
  10. Validate important decisions against another source.
  11. Do not use ASN country fields as GeoIP.
  12. Do not treat an ASN as the identity of an individual user.
  13. Do not automatically block an entire ASN because of one abusive IP.
  14. In DNS systems, know whether you are classifying the resolver or the client network.

These rules make ASN lookup useful without giving the data more authority than it deserves.


Related PinoyLinux Guides

If you want to understand how ASN information becomes part of larger networking decisions, continue with these PinoyLinux articles.

Requester classification

Inside Requester Classification: IP, ASN, Country, And Resolver Signals

This explains how IP addresses, prefixes, ASN, country information, resolver signals, and ECS can become classification inputs.

DNS steering basics

DNS Steering 101: How Authoritative DNS Influences Traffic Direction

Read this if you need the larger context for how authoritative DNS can use network information when selecting answers.

EDNS Client Subnet

EDNS Client Subnet: Powerful Signal Or Operational Trap?

This explains why the IP visible to authoritative DNS may represent a recursive resolver and how ECS can sometimes provide better client-network context.

Geography and network distance

Latency, Geography, And Network Distance: What DNS Can And Cannot Know

Useful when you need to understand why ASN, geographic location, network path, and latency are related but different signals.

ASN-aware routing policy

Weighted, Geo, ASN, And Failover Routing: Steering Techniques Compared

This covers where ASN-aware routing fits alongside geographic, weighted, prefix-based, and failover policies.

Routing policy updates

Keeping DNS Answers Fast While Updating Routing Policy

Useful for understanding what happens when ASN mappings and routing policies become production inputs that need controlled updates.


Key Takeaways

An IP-to-ASN lookup maps an IP address through its routed network prefix to the Autonomous System announcing that prefix.

The basic relationship is:

IP address
    |
    v
Most-specific BGP prefix
    |
    v
Origin ASN
    |
    v
Network operator

An ASN tells you about the network routing context behind an IP.

It does not identify a specific person.

WHOIS and RDAP provide registration information. BGP-derived services such as RIPE RIS and Team Cymru provide routing-origin information. Use the correct source for the question you are trying to answer.

Always keep the matched prefix and lookup timestamp alongside the ASN.

Expect changes.

A network can announce more-specific routes, migrate providers, become multi-origin, or change how address space is routed.

For sysadmins and SOC analysts, ASN enrichment can make logs and incidents easier to understand.

For network engineers, it can expose provider-specific routing patterns.

For DNS and CDN systems, it can become one input into requester classification and routing policy.

The lookup itself is simple.

Understanding what the result actually means is the important part.

References

lordfrancs3

lordfrancs3

Lordfrancis3 is a member of PinoyLinux since its establishment in 2011. With a wealth of experience spanning numerous years, he possesses a profound understanding of managing and deploying intricate infrastructure. His contributions have undoubtedly played a pivotal role in shaping the community's growth and success. His expertise and dedication reflect in every aspect of the journey, as PinoyLinux continues to champion the ideals of Linux and open-source technology. LordFrancis3's extensive experience remains an invaluable asset, and his commitment inspires fellow members to reach new heights. His enduring dedication to PinoyLinux's evolution is truly commendable.

Articles: 71