Forum Moderators: phranque

Message Too Old, No Replies

Reading and Understanding IP Ranges from RIR records

         

Nail_Yener

10:37 am on Dec 20, 2014 (gmt 0)

10+ Year Member



Hi,

I am preparing IP ranges for countries to use in my script (.htaccess file) from the data provided by RIRs (Apnic, Afrinic, Arin, Lacnic, Ripencc). I have a couple of questions about how to read and understand the data they provide. For example, Apnic's public records for IP allocations/assignments can be found at:

ftp://ftp.apnic.net/pub/apnic/stats/apnic/delegated-apnic-extended-latest

1) Is this the most current file that I should use? Or should I use some other file from:

ftp://ftp.apnic.net/pub/apnic/stats/apnic/

2) Some ranges are "assigned" and some ranges are "allocated". What does that exactly mean? Are assigned ranges actively in use but allocated ranges are not in use yet and waiting to be assigned? Shall I use only the assigned records in my script?

3) How do I convert the IP range info into CIDR notation? For example, there are two records:

A) apnic|AU|ipv4|1.0.0.0|256|20110811|assigned|A91872ED
B) apnic|JP|ipv4|1.0.64.0|16384|20110412|allocated|A9252414

I know I will be using the following parts:

A) 1.0.0.0|256
B) 1.0.64.0|16384

First value is the starting IP, second value is the number of IPs in that range. Do I convert it like the following:

A)
256 = 2^8
32-8 = 24
so the CIDR range is
1.0.0.0/24

B)
16384 = 2^14
32-14 = 18
so the CIDR range is
1.0.64.0/18

Is that correct?

Thanks.

wilderness

1:58 pm on Dec 20, 2014 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Google IP country [google.com]

lucy24

8:34 pm on Dec 20, 2014 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Is that correct?

These two examples agree with the information I've got, so it sounds as if your math is working.

One thing to watch out for: within each registry there are administrative ranges which belong on paper to some country. For APNIC it's Australia; for RIPE it's the Netherlands. EU assignments are also wonky, because some of them really do mean "European Union" while others just mean "unassigned block that will eventually go to some EU member country".

The early part of 1 is weird anyway. There's a whole series of ranges that break down as
/24
/24
/23
/22
/21
and so on up to /17 each time.

Pro tip: https doesn't auto-link, but http does. The site will redirect you if it sees fit.

Nail_Yener

8:03 am on Dec 21, 2014 (gmt 0)

10+ Year Member



Thank you, lucy24. I think they didn't do a good job at the beginning while assigning the IPv4 blocks to countries and now we, webmasters, are having a hard time figuring out the origin of the traffic our websites are getting.