Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: IP prefixes: match IP against "best" network

by Fangorn (Initiate)
on Jul 03, 2007 at 12:41 UTC ( [id://624665]=note: print w/replies, xml ) Need Help??


in reply to IP prefixes: match IP against "best" network

Great one, I'm happy to have inspired You :).

I used (some of) the code in my project, I hope to publish it soon.

Here's my small script that's using aggregate to, well, aggregate prefixes. That's not perl, I hope it's not a blasphemy here :) . And it actually uses zsh syntax, but it should not be a problem to bashify it.

#!/usr/local/bin/zsh INDEX=1 while [ $INDEX -lt 70000 ] do PREFIXES=`grep "[[:space:]]$INDEX$" example|awk '{print $1}'` if [ $PREFIXES ] then a=`echo $PREFIXES|aggregate` echo $a|awk '{print $1, "\t'$INDEX'"}' let INDEX=$INDEX+1 else let INDEX=$INDEX+1 fi done

For me it crunched ~220000 prefixes to ~120000 so I think it's worth to use it. Not only will the data be smaller but also there will be less lookups (it only aggregates data prefixes of a single AS, so if there are overlapping prefixes with different AS numbers they will be preserved).

Replies are listed 'Best First'.
Re^2: IP prefixes: match IP against "best" network
by kaiserbiz (Initiate) on Mar 01, 2008 at 15:58 UTC
    HI, What Do I need to try this script? I am new to Perl and I find it fascinating.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://624665]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (4)
As of 2024-04-20 02:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found