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
[..]
That's basically correct. An allocated address belongs to a pool from which it may be assigned but it hasn't yet been marked as in use. Pools are managed by various organizations like ISPs, Webhosting services, and Universities.
Keep in mind that the files you're parsing are going to be outdated the moment they're published, and that any given address may have been assigned for quite a while before it gets reported back.
Edit: It looks like the comment is correct. IP Addresses marked as assigned are managed by a sub-organization, but they may or may not actually be in use. Ranges marked as allocated should not be in use, except for where there is a lag in updating these reports. Keep in mind this comment about that data:
In particular, it should be noted that these reports seek to
indicate where resources were first allocated or assigned. It is not
intended that these reports be considered as an authoritative
statement of the location in which any specific resource may
currently be in use.
http://ftp.apnic.net/stats/apnic/
Best Answer
To answer your first question mobile/cell-phone IP addresses are handed out using DHCP like any other client device. To answer your second questions, well yes, through NAT - that's what NAT does, it allows multiple 'inside' devices to get IP services through a NAT gateway - external IP services will not be able to identify individual internal devices like phones by IP but could via a session ID, cookie or similar.