Find all the netblocks owned by a particular organisation

By | May 2, 2013
On 2013-03-20 at 11:55 +0100, DTNX Postmaster wrote: 
> I've looked up quite a few now, and they are all Crystone ranges, 
> belonging to their various European subsidiaries. There doesn't seem to 
> be an easy way to show all IP ranges belonging to 'CR422-RIPE', but 
> that could very well be a lack of understanding on my part. 

Given a "ripe" command that boils down to: 

 whois -h whois.ripe.net -- "$*" 

(and the $* not $@ is deliberate), you want: 

 ripe -K -T inetnum,inet6num -i admin-c CR422-RIPE 

So, primary keys only (not the details), for network blocks (not route 
objects, etc etc), with an inverse query, searching where the admin-c 
field is CR422-RIPE. 

I'd post the results inline, but don't want to even risk dealing with 
people arguing I've violated T&C or somesuch. 

They have 283 inetnum blocks, 0 inet6num blocks. A lot of these are 
disaggregated. Some are not exact netblocks. 

% sed -n 's/^inetnum: *//p' < cr422 | \ 
 perl -MNet::Netmask -ne 'BEGIN { @all = () }; 
 die "unhandled line: $_" unless /^([0-9.]+)\s+-\s+([0-9.]+)$/; 
 push @all, range2cidrlist($1, $2); 
 END { foreach (cidrs2cidrs(@all)) { print "$_\n" } }' | wc -l 
 201 

"cr422" is the raw output from the query command above. 

-Phil

My example

#whois -h whois.ripe.net -- "$*" ripe -K -T inetnum,inet6num -i admin-c CR422-RIPE > cr422
#sed -n 's/^inetnum: *//p' < cr422 | perl -MNet::Netmask -ne 'BEGIN { @all = () }; die "unhandled line: $_" unless /^([0-9.]+)\s+-\s+([0-9.]+)$/; push @all, range2cidrlist($1, $2); END { foreach (cidrs2cidrs(@all)) { print "$_\n" } }'