in reply to Generation of sequential IP addresses for Class B network
You have not declared the variable, $_second_octet_num variable. I don't know how your program is generating 192.168.1.1 to 192.168.1.254 without that.
Here I am giving the code for generating a IP address from 192.168.1.1 to 192.168.254.254. You can adjust the code according to your situation.
#!/usr/bin/perl use strict; use warnings; my $first_octet_num = "1"; my $ip_address; foreach (1..254) { foreach (1..255) { if ($_ <= 254) { $ip_address = join ('.', 192,168,$first_octet_num,$_); print "$ip_address\n"; } else { $first_octet_num++; } } }
One more information for you, IP address start with 192, it's not class B. It's class C. Reference here.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Generation of sequential IP addresses for Class B network
by ikegami (Patriarch) on Jun 24, 2009 at 14:13 UTC | |
|
Re^2: Generation of sequential IP addresses for Class B network
by perlpal (Scribe) on Jun 24, 2009 at 11:20 UTC |