Internet – How IP Addresses Are Mapped to Autonomous System Numbers

as-numberinternetip address

How are IP addresses mapped to Autonomous System Numbers (ASNs)? Is there a reference database for it? Then how are these Autonomous Systems geographically located?

Best Answer

Note: This information is kind of RIPE-centric because that's the RIR I deal with most.

The relationships between IPs (inet-num) and ASNs (aut-num) are documented in public Internet Routing Registries (IRR) using Routing Policy Specification Language (RPSL). IRRs are simply whois databases which provide additional object types (route, route-set, aut-num, as-set, etc) to store the RPSL information. IRRs are operated by all Regional Internet Registries (RIRs such as RIPE, ARIN, etc) as well as some other parties such as RADB.

RPSL can define not just which aut-num relates to which inet-num objects but also the transit and peering arrangements of a given aut-num. This information can be used to build router configurations such as with the utility RtConfig. Additionally some LIRs document their policies for accepting new peering requests and the BGP communities they make available to their peers here.

It's important to note that besides automatically configuring routers with RPSL there isn't any "magic glue" between the IRR data and what is actually happening in the wild. RPSL is a best effort practice, which should be kept up to date, but doesn't mean there's any technical barrier to announcing a route without first publicising it in RPSL.

As an example, let's see what routes are documented for the BBC website:

dan.carley@jim ~ $ whois -T route $(dig +short bbc.co.uk)
% This is the RIPE Database query service.
% The objects are in RPSL format.
%
% The RIPE Database is subject to Terms and Conditions.
% See http://www.ripe.net/db/support/db-terms-conditions.pdf

% Note: This output has been filtered.
%       To receive output for a database update, use the "-B" flag.

% Information related to '212.58.224.0/22AS2818'

route:        212.58.224.0/22
descr:        BBC
origin:       AS2818
mnt-by:       BBC-MNT
source:       RIPE # Filtered

% Information related to '212.58.224.0/20AS2818'

route:        212.58.224.0/20
descr:        BBC (EU network)
origin:       AS2818
mnt-by:       BBC-MNT
source:       RIPE # Filtered

% Information related to '212.58.224.0/19AS2818'

route:          212.58.224.0/19
descr:          BBC
origin:         AS2818
mnt-by:         BBC-MNT
source:         RIPE # Filtered

This indicates that their website will be available from three routes of increasing size (/19, /20 and /22 to the same prefix) via AS2818. Querying that ASN will then give us some additional information about their peers and policies (snipped for brevity):

dan.carley@jim ~ $ whois -T aut-num as2818
% This is the RIPE Database query service.
% The objects are in RPSL format.
%
% The RIPE Database is subject to Terms and Conditions.
% See http://www.ripe.net/db/support/db-terms-conditions.pdf

% Note: This output has been filtered.
%       To receive output for a database update, use the "-B" flag.

% Information related to 'AS2818'

aut-num:        AS2818
as-name:        BBC
descr:          BBC Internet Services, UK
import:         from AS174 action pref=100; accept AS174
import:         from AS286 action pref=100; accept AS-KQ AS-QWEST
import:         from AS553 action pref=100; accept AS-BELWUE
import:         from AS702 action pref=50; accept AS-UUNETUK
[..]
export:         to AS174 announce AS-BBC
export:         to AS286 announce AS-BBC
export:         to AS553 announce AS-BBC
export:         to AS702 announce AS-BBC
[..]