IP to CIDR / IP Range

Does anyone know an API / Script that gives me CIDR for a network IP address? Not IP range up to CIDR!

Reference Information. A fraudster logs into my site and uses a proxy server or web host to hide his IP address or fake his ip position. Now it makes no sense to simply block its IP address. I want to block the entire host network for registration. Therefore, I need to do ip whois to get the CIDR network. I want to automate it.

+4
source share
1 answer

IP addresses are issued to end users LIR (local Internet registry). LIRs are required to register various data for any assigned address space in the respective RIR (Regional Internet Registry) databases. There are 5 RIRs (ARIN, RIPE NCC, APNIC, LACNIC and AfriNIC) responsible for different parts of the world. As far as I know, they all provide a RESTful API that you can use to get the information you need.

For example, if the IP address is from Europe, you can use the RIPE API to search for inetnum objects or routes associated with any IP address:

http://rest.db.ripe.net/search?query-string=194.79.41.40

You will get several objects inside whois-resource, and the most interesting for you is the object route:

<object type="route">
 <link xlink:type="locator" xlink:href="http://rest.db.ripe.net/ripe/route/194.79.40.0/22AS35796"/>
 <source id="ripe"/>
 <primary-key>
  <attribute name="route" value="194.79.40.0/22"/>
  <attribute name="origin" value="AS35796"/>
 </primary-key>
 <attributes>
  <attribute name="route" value="194.79.40.0/22"/>
  <attribute name="descr" value="NBS"/>
  <attribute name="origin" value="AS35796" referenced-type="aut-num">
   <link xlink:type="locator" xlink:href="http://rest.db.ripe.net/ripe/aut-num/AS35796"/>
  </attribute>
  <attribute name="mnt-by" value="NBS-MNT" referenced-type="mntner">
   <link xlink:type="locator" xlink:href="http://rest.db.ripe.net/ripe/mntner/NBS-MNT"/>
  </attribute><attribute name="source" value="RIPE" comment="Filtered"/>
 </attributes>
</object>

, , , , , , .

RIR:

  • (): afrinic.net
  • APNIC (- ): apnic.net
  • ARIN ( ): arin.net
  • LACNIC ( ): lacnic.net

Edit: , API. whois, , , JSON XML .

Whois TCP- 43 ( IP-). , . . telnet whois.ripe.net 43, 194.79.41.40 IP-, RIPE NCC.

whois , , , RIR, IP-. RIR () whois.iana.org , RIPE NCC, whois (RIR), IP. , whois, , , , .

, , 5 whois.

+8
source

Source: https://habr.com/ru/post/1569544/


All Articles