Question

Given an arbitrary IP address (registrar not known at this point), what's the easiest or most efficient way to look up the end-user CIDR to which it "belongs", and basic information about that IP block (such as registered name of owner).

I'm looking for this kind of function:

EXAMPLE INPUT:  
  $parent = get_parent_range_info('195.122.169.15');

DESIRED OUTPUT is an array that contains:

  End-user IP range it 'belongs' to =  195.122.169.0 - 195.122.169.63 (195.122.169.0/26)
  Range's registered netname = KASPERSKY-LAB

  [And other info if possible, eg:]

  descr:           BBLZ9143
  country:         DE
  changed:         ipan@level3.com 20101101
  person:          Sudakov Andrey
  address:         10/1 1st Volokolamsky Proezd
  address:         123060 Moscow,
  address:         Russia
  phone:           +79 030049180
  nic-hdl:         SA7294-RIPE
  e-mail:          unixadm@kaspersky.com
  notify:          unixadm@kaspersky.com
  mnt-by:          LEVEL3-MNT
  changed:         greg.farrell@level3.com 20101101

The info used in this example can be seen by entering IP at: https://apps.db.ripe.net/search/query.html . Other registrars have similar lookups on their websites.

The platform is PHP, with full access to shell "exec()" commands if easier.

I can see most registrars can provide this information (as XML or JSON), often through their website's API, and some *nix commands and perhaps PHP commands can intelligently work out which registrar handles an IP and discover some lookup information automatically. The few commands I know like whois, dig, host etc on *nix don't seem to provide this kind of information though.

How can I do it?

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top