[afnog] AS# to IP range

Mihamina Rakotomandimby mihamina at rktmb.org
Thu Mar 21 10:41:48 UTC 2013


On 2012-05-11 13:20, Iñigo Ortiz de Urbina wrote:
> For instance, Google's primary ASN:
> o Widget you can embed anywhere:
> https://stat.ripe.net/query/widget/AS15169?widget=announced-prefixes
> o Raw data you can fetch and parse in an automated fashion:
> https://stat.ripe.net/plugin/announced-prefixes/data.json?resource=AS15169

I found an "upstream" way for that, taken from http://goo.gl/lukNj
     $ dig +short -t TXT _netblocks.google.com @8.8.8.8

With some quick and dirty sed magical:
     $dig +short -t TXT _netblocks.google.com @8.8.8.8 \
         | sed 's/ip4://g' \
         | sed 's/"v=spf1 //g' \
         | sed 's/ ?all"//g' \
         | sed 's/ /\n/g'


Worse :-P
wget 
'https://stat.ripe.net/plugin/announced-prefixes/data.json?resource=AS15169' 
-O - \
     | grep prefix | grep -v '::' \  <=== Duh!
     | sed 's/"//g' | sed 's/://g' | sed 's/,//g' | sed 's/\[//g' \
     | awk '{print $2}'


-- 
RMA.



More information about the afnog mailing list