[olug] Subnet mask

Daniel Linder dan at linder.org
Tue Dec 16 18:35:35 UTC 2003


Bob wrote:
> The problem is that the answer is wrong.  The answer is wrong because
> the question was wrong.

Here is a snippet of the original post that "someone" wrote:
>>> I have been given a range of numbers to use at my job and I
>>> cannot figure out the subnet mask...Help!
>>> The numbers are 205.202.101.64-205.202.101.93.  Class C address from
>>> authority.

(I apologize in advance, I can't remember who "someone" was...)

The two pieces of information I latched onto here were the following:
1: "The numbers are 205.202.101.64-205.202.101.93"
2: "Class C address"

The scenario I had envisioned was that he was using an ISP who gave him 29
addresses to use for his equipment.  Since he said "Class C address", I
asked my Magic-8-Ball what this meant and the closest answer it could come
up with was that his IP addresses were part of a larger /24 range
(205.202.101.0/24).

Knowing that this is a Linux mailing list, I was envisioning that he was
trying to setup a minimal number of IPTables rules to protect this subnet
(or route it, or whatever) and he needed a list of the minimal networks
that would completely cover this range from .64 through .93 inclusively.

> You will not have a subnet end with a 93 -- ever.  The reason?  As you
> look at the output, you'll notice that the last subnet only has two
> addresses, 92 & 93, which is invalid -- you end up with a network
> address and a broadcast address an no usable host addresses.  If you use
> 95 as the top-end address, you end up with a 32-address network with 30
> usable addresses.  I suspect 94 was taken out of the range of addresses
> since it would probably serve as the default gateway for that net.

I agree -- but you are referring to a "usable subnet" with a network
address, hosts, and a broadcast address.  I was reading the question as
asking about a "covering network range".  I guess if I could go back in
time and remove my post and ask the original person for more details.

> Remember, he was working with *one* subnet.  The way the tool has to
> carve it up to fit within the original stated range, you end up with
> four subnets (each with a unique mask), with only 22 usable addresses
> (as opposed to 30).

If the "one subnet" was actually a larger /24 of which he was provisioned
.64 through .93 inclusively *and* the four covering address/mask ranges
listed were for firewalling/routing rules, then my answer still applies. 
Again, a solution was provided for a set of questions that were too vaigue
to answer properly the first time.

To answer another quesiton, yes I have gone to various "IP Calculator" web
pages, but I thought I would help everyone bulk up their "IT tool box" a
bit and provide yet another way to do it.  Now someone can use the code
snippet I showed and write their own IP Calculator web tool, too!


Jay wrote:
> Subnets for that range:
> http://jays.net/cgi-bin/ipr.pl?ip1=205.202.101.64&ip2=205.202.101.93
>
> Source code:
> http://jays.net/ipr.pl.txt

Handy tool Jay, but could you have leveraged "divide by 2" and/or
bit-shifting in Perl (never done that myself) rather than using "X/log(2)"
mathmatics?  (My Calc and binary math are rusty right now, can't remember
the relationships between those functions.)

Dan


More information about the OLUG mailing list