PLEX86  x86- Virtual Machine (VM) Program
 Plex86  |  CVS  |  Mailing List  |  Download  |  Linux  |  Newsgroups

Netmasks for dummies 3006


Your Ad Here

Your Ad Here

On 02-19-2005 12:18 AM, StupidScript

Here is an ip calc:

#!-usr-bin-ruby # icalc.rb IP calculator sub-super-net

IMAX = 4294967295

Netmasks for dummies 3009
Moe Trin legal stack don't and mask, also I'm not a detail miner of the RFCs (who is?) but the ones you reference provide the documented experience of inadequate planning that accompanied the huge growth...

def tob(dotted) if dotted !~^-d{1,3}?-.-d{1,3}?-.-d{1,3}?-.-d{1,3}?$ raise TypeError, "Invalid ip-mask notation" end a, b, c, d = dotted.split(".") raise TypeError, "Invalid ip-mask value" end ip = a.toi * 16777216 + b.toi * 65536 + c.toi * 256 + d.toi return ip end

def tod(bin) raise TypeError, "Invalid ip-mask binary value" end d = bin % 256 return a.tos + "." + b.tos + "." + c.tos + "." + d.tos end

def top(netmask) valmask = IMAX - 3; prefix = 1 prefix += 1 end STDERR.printf "-aWARNING: Invalid netmask %s, using %s-n", ARGV1, tod(valmask) $netmask = valmask STDERR.printf "-aWARNING: Invalid range, corrected.-n" $netmask = valmask end return 32 - (prefix - 1) end

STDERR.printf "usage:-n %s address-prefix div-n %s address-range div-n %s address netmask div-n", File.basename($0), File.basename($0), File.basename($0) exit 1 elsif ARGV0.index("-") address, prefix = ARGV0.split("-") address = tob(address) prefix = prefix.toi STDERR.printf "-aWARNING: Invalid prefix %s, using 30-n", prefix prefix = 30 end ARGV.shift elsif ARGV0.index("-") address, last = ARGV0.split("-") address = tob(address) + 1 last = tob(last) $netmask = IMAX - (last - address) - 1 prefix = top($netmask) ARGV.shift address = tob(ARGV0) $netmask = tob(ARGV1) prefix = top($netmask) ARGV.shift ARGV.shift end netsize = (IMAX ^ $netmask) + 1 subdiv = ARGV.size == 1 ? ARGV0.toi : 1 div = 1 if div != subdiv STDERR.printf "-aWARNING: Invalid subnet divisor %d, using %d-n", subdiv, div subdiv = div end end factor = netsize subdiv network = address & $netmask $netmask = IMAX - factor + 1 total = 0

printf "Netmask Subnets Prefix-n" printf "--------------- ------- -------n" printf "%-15s %7d %6d-n-n", tod($netmask), subdiv, prefix printf " Subnet First Last Broadcast Hosts-n" printf " --------------- --------------- --------------- --------------- -----------n" (1 .. subdiv).each do i nnw = tod(network - factor + factor * i) nns = tod(network - factor + factor * i + 1) ngw = tod(network + factor * i - 2) nbc = tod(network + factor * i - 1) total += (factor - 2) printf " %-15s %-15s %-15s %-15s %10d-n", nnw, nns, ngw, nbc, factor - 2 end printf "%-66s-----------n", " " printf "%-66s%10d-n", " ", total

Netmasks for dummies 3007
Oh my goodness! Thank you all for your responses. Moe: 194.9.124.0 - 194.9.126.207 makes me laugh out loud! I'm...

Hope that helps!

-- Dr Balwinder Singh Dheeman Registered Linux User: #229709 CLLO (Chief Linux Learning Officer) Machines: #168573, 170593, 259192



Your Ad Here

List | Previous | Next

Netmasks for dummies 3007

Linux groups from Newsgroups

The #1 Usenet Provider on the Internet

Netmasks for dummies 3005