secynic / ipwhois

Retrieve and parse whois data for IPv4 and IPv6 addresses
https://ipwhois.readthedocs.io/en/latest
BSD 2-Clause "Simplified" License
552 stars 121 forks source link

RDAP IP Networks #250

Open Skybound1 opened 4 years ago

Skybound1 commented 4 years ago

When performing RDAP IP Whois, the library enforces the use of an IP address. However, there are cases where it is useful to also provide details of the range we are interested in. For example, querying RDAP for 8.8.8.8 would return information regarding the encompassing /24, however if we wanted information for the encompassing /9, we would need to provide a network size. This appears to be supported at least within ARIN:

IP Networks
Queries for information about IP networks are of the form:

<rdap-url>/ip/<search-term> or /ip/<address>/<prefix>

where the path segment following ip is either an IPv4 dotted decimal or IPv6 [RFC5952] address (i.e., 2001:500:11::) or an IPv4 or IPv6 Classless Inter-domain Routing (CIDR) [RFC4632] notation address block (i.e., 12.0.0.0/8).

Query Examples

https://rdap.arin.net/bootstrap/ip/2001:500:11:: https://rdap.arin.net/bootstrap/ip/12.0.0.0/8

Example queries:

https://rdap.arin.net/registry/ip/8.8.8.8/16 https://rdap.arin.net/registry/ip/8.8.8.8

Could we get a way to provide this extra bit of information, for example a flag into IPWhois.lookup_rdap

secynic commented 4 years ago

Requested changes in the PR. Still need to test this to make sure it doesn't cause errors in other parts of the lib.