netmask_table.pl - A perl script to create an IPv4 netmask table...

Once upon a time, way back in the 1980s, I put an IPv4 netmask table together that took off and seems to be copied and published all over the net now. (Just google "pozar" and "netmasks".) Back then I hand built this table. A friend wanted an expanded table to any size netmask. Instead of hand coding this again, I wrote this perl script.

Just change the "$base_netmask_size" to what ever you want it to start out on and refernce as a the "base" netmask that is subnetting. For instance a /28 would look like...

Netmask 255.255.255.240 /28 (11111111111111111111111111110000)
There are 1 subnets in a /28
0.0.0.0 to 0.0.0.15

Netmask 255.255.255.248 /29 (11111111111111111111111111111000)
There are 2 subnets in a /28
0.0.0.0 to 0.0.0.7
0.0.0.8 to 0.0.0.15

Netmask 255.255.255.252 /30 (11111111111111111111111111111100)
There are 4 subnets in a /28
0.0.0.0 to 0.0.0.3
0.0.0.4 to 0.0.0.7
0.0.0.8 to 0.0.0.11
0.0.0.12 to 0.0.0.15
Suggestions welcomed, flames devnulled.

Tim