From: Leigh Harrison (ccileigh@gmail.com)
Date: Mon Oct 17 2005 - 19:47:40 GMT-3
All,
Please see slight correction below
This puts the "null 0" on the same line now
LH
PS:-Active perl is the easiest to use for Windows
Leigh Harrison wrote:
> All,
>
> Spurred on by Kevins posting of loads of routes - I posted a request
> on a perl newsgroup for someone to knock me up a perl script to do
> it. Within 45 mins a thoroughly decent chap named Brian Helterline
> had answered my plea.
>
> Run the script and put in how many routes you would like the script to
> create and it will fire them out for you, i.e.,
> c:\> perl routescript 50
>
> and 50 routes will fly up the screen ready to be cut and paste (if
> you're running linux you can always send them to a file)
>
> Brian,
>
> I altered the script a tiny bit, so I could get a more weighted random
> number for the network masks - hope you don't mind!!
>
> Once again - many thanks for you effort on this - I'm sure it will be
> very useful to a great many people.
>
> LH
>
>
> -------------------------------------------
>
> use strict;
> use warnings;
>
> #ip route 1.2.3.0 <http://1.2.3.0> 255.255.255.0
> <http://255.255.255.0> null 0
>
>
> my @netmask1 = qw / 128 192 224 240 248 252 254 255 255 255 255 255
> 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
> 255 255 255 /;
> my @netmask2 = qw/ 0 128 192 224 240 248 252 254 255 255 255 255 255
> 255 255 255 255 255 255 255 255 255 255 255 255 255 /;
>
>
> my $count = shift or Usage();
>
> while ( $count-- > 0 ) {
> my @ip = ( int(rand(223))+1, # 1 to 223
> int(rand(256)), # 0 to 255
> int(rand(256)), # 0 to 255
> int(rand(256)) # 0 to 255
> );
> my @mask = ( 0, 0, 0, 0 );
> $mask[0] = $netmask1[ int(rand(@netmask1)) ];
> if ( $mask[0] == 255 ) {
> foreach my $idx ( 1..3 ) {
> $mask[$idx] = $netmask2[ int(rand(@netmask2)) ];
> last unless $mask[$idx] == 255;
> }
> }
>
> print "ip route ", join( ".", @ip), " ", join( ".", @mask), " ",
> "null 0\n";
> }
>
>
> sub Usage {
> print "$0 <number of ip addresses to generate>\n";
> exit;
> }
>
> -------------------------------------------
This archive was generated by hypermail 2.1.4 : Sun Nov 06 2005 - 22:00:51 GMT-3