New Zealand ADSL Mailing List


Re: (OT) Help: Subnet Mask

From: Michael Beattie <mike_at_ethernal.org>
Date: Wed, 3 Oct 2001 19:53:56 +1200
Message-ID: <20011003195356.A8653@relativity.ethernal.org>

On Wed, Oct 03, 2001 at 04:38:51PM +1200, James Pluck wrote:
> Thank you for all your help people. As an adjunct to this, does anyone have
> a site or some information that explains how the bitmapping (presumed) of
> the subnet mask works? I have seen a couple of "Cheat sheets" but nothing
> that explains the inner-workings as it were.

since everyone else gives URL's[0], I'll attempt a real explanation that
can go in the archive.

A netmask is a "Network Mask" - to put it literally, it specifies the
bits in an IP that represent what network (subnet) that IP belongs to.

255 = (2^9)-1 = 1 byte. (8 bits, all on)

so, an IP is, bitwise: xxxxxxxx.yyyyyyyy.zzzzzzzz.wwwwwwww

a netmask is the number of bits from the left hand side that do not
change in a subnet. it can also be specified as a dotted quad listing
the number in decimal that represents the bits that are non-changable.

so: 192.168.1.0/24 -> 192.168.1.0 to 192.168.1.255
     192.168.0.0/16 -> 192.168.0.0 to 192.168.255.255

now, a netmask of "/24" is 24 bits. 24/8 = 3, so the first three bytes
cannot change:

11111111.11111111.11111111.00000000

24 1's. 24 bits for the network, 8 for hosts.

but, a full byte can be represented as 255:

255.255.255.0

now, since you just want to change the third byte of the IP, and it will
only differ by one - then you only need to unlock the binary equivalent
of a 1. the rightmost bit:

11111111.11111111.11111110.00000000

11111110 in binary is 254, so:

255.255.254.0 is the dotted quad of the netmask you want.

Things get a lot more confusing, the larger the netmask. A quick
googling turns up this page:
http://www.cpm.ru:8100/service/manuals/max6000/max6000/isptele/maxip.htm
as a relatively good explanation of netmasks and IP's - albeit, for a
specific piece of hardware, but it gives a nice bit of theory too.

For reference:

x.x.x.x/8 = Class A
x.x.x.x/16 = Class B
x.x.x.x/24 = Class C

Default classes for IP ranges. (if you dont specify a netmask)

0.0.0.0 - 127.255.255.255 Class A
128.0.0.0 - 191.255.255.255 Class B
192.0.0.0 - 223.255.255.255 Class C

for the clever people out there, it is dependant on the first 2 bits of
the IP address. (not the netmask):

00 Class A
10 Class B
11 Class C

(which holds true on the IANA assigned private networks:
10.x.x.x - Class A
172.16.x.x - Class B
192.168.x.x - Class C)

HTH,
Mike.

[0] - ok, I gave a URL, but only because that depth of the explanation
is a bit out of the scope of this quick and dirty attempt :>

-- 
Michael Beattie <mike@ethernal.org>
yip yip yip yip yip yip yap yap yip *BANG* NO TERRIER
This message is part of the NZ ADSL mailing list.
see http://unixathome.org/adsl/ for archives, FAQ,
and various documents.
To unsubscribe: send mail to majordomo@lists.unixathome.org
with "unsubscribe adsl" in the body of the message
Received on Wed Oct 3 19:54:11 2001

This archive was generated by hypermail 2.2.0 : Thu Nov 30 11:48:16 2006 EST