Three ways to count to 255

As an easy reference, here’s 3 ways to generate an IP address list for use with other scripts using three common scripting methods.

1. Windows For command
Command: FOR /L %variable IN (start,step,end) DO command [command-parameters]
Example: for /L %I (1,1,255) DO echo 192.168.1.%I >> IPs.txt

2. Bash Shell
Example: for (( i=1; i<=5; i++)); do echo "192.168.1.$i"; done

3. Perl Script
for ( $i = 0; $i< 255; $i++)
print "192.168.52.$i\n";

Obviously you can do this for any class subnet you’d just have to use nested for loops.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: