Morning All,

        Here's a subnetting tip I have noticed since I work with routers
day in day out: Dont think in terms of the decimal notation of the masks,
think in terms of the binary -- it all becomes clear then, providing you
can see beyond the 000's and 111's :)... here what I mean :

In binary form an IP address looks like this (when sticking to the dot
octet notation), 4 blocks of 8 bits.

        00000000.00000000.00000000.00000000

When your telco/ISP gives you a Class C they are allocating you 8 bits
worth of address space for you to use how you will. hence you get a
network address like this:

        11000110.10000101.11011011.00000000

With a netmask of 

        11111111.11111111.11111111.00000000

Note how the netmask has the last 8 bits set to 0 and the first 24 bits
set to 1. This signifies that the first 24 bits are used to specify your
network (the block of addressing you own) and the last 8 bits are for
host/subnet space.

Now, with that understood you can understand subnetting. Subnetting is the
practice of taking the hostspace (those 8 bits) that your telco/isp has
given you and dividing them up further into smaller host networks. So, say
for example you wanted to divide your space in half. Essentially what you
are then doing is using an extra bit to specify your network space and 1
less bit to specify your host space (the extra bit is what devides the
networks, e.g if that network bit is 0 its subnet0 and if its 1 its
subnet1).

So, we have network addressing like this :

        11000110.10000101.11011011.00000000     Subnet0
        11000110.10000101.11011011.10000000     Subnet1

With a netmask of 

        11111111.11111111.11111111.10000000     

Note the added '1' to the last octet of the network address space.

Now say you wanted to divide subnet1 in half, so that you have the big
subnet0 and two half sized subnets. You do the same, you make one of your
host bits a network bit. Hence the following network addressing.

        11000110.10000101.11011011.00000000     Subnet0
        11000110.10000101.11011011.10000000     Subnet1
        11000110.10000101.11011011.11000000     Subnet2

With a netmask of 

        11111111.11111111.11111111.11000000     

So now we should see a pattern forming. Each time you want to divide a
block of host addressing into half you simply take the first bit (the
furthest left) of the host space and make it a network bit, and then make
the corresponding bit in the netmask a '1' (it should have been a 0
before. if not, you werent looking at the host space).

So now that your comfortable with the binary of it (and wasnt it
simple!) lets relate it back to the decimal. The deicmal/binary
relationship is like this, just looking at one octet here (a group of 8
bits).
        
        128     64      32      16      8       4       2       1
        0       0       0       0       0       0       0       0       

Hence the binary number 10010101 is really 128+16+4+1 = 149

So, now lets look at each of the combinations of netmasks you can have and
their decimal equivalents. (Im only going to look at Class C here, but it
extends right up the scale).

11111111.11111111.11111111.00000000     255.255.255.0
11111111.11111111.11111111.10000000     255.255.255.128
11111111.11111111.11111111.11000000     255.255.255.192
11111111.11111111.11111111.11100000     255.255.255.224
11111111.11111111.11111111.11110000     255.255.255.240
11111111.11111111.11111111.11111000     255.255.255.248
11111111.11111111.11111111.11111100     255.255.255.252
11111111.11111111.11111111.11111110     255.255.255.254
11111111.11111111.11111111.11111111     255.255.255.255

WHile this is very interesting, all you wanted to do was to work out how
many of the damn addresses you can fit in each subnet, or vice versa, what
size subnet you needed for a given amount of addresses. Well, it's dead
simple. Look at the last octet in the example above. Remebering that they
represent the NETWORK space, so hence it makes complete since that 'whats
left' is the host space.

Here is an example, it works the same for _every_ netmask.

So, you have a netmask of 

11111111.11111111.11111111.11110000     255.255.255.240

Therefore you have a host space of

00000000.00000000.00000000.00001111     0.0.0.15

And its that simple, in a subnet with a mask of 255.255.255.240, you have
15 available addresses. BUT. Remever, with IP addressing the lowest
address (all 0's in the host space) is the network address (identifies the
subnet) and the highest address (all 1's in the host space) is the
broadcast address. So you only really have 13 addresses that you can use
for your actual hosts in the subnet.

So there you go, it's not really an art, it is a science... but damn it
helps to forget about decimal when your dealing with something that is
very binary centric in its addressing. 

Gimme a yell if you have questions..

-- 
[=====================================================[ www.cisco.com ]====]
 James Wilson
 Hardware/VISE Customer Service Engineer
 On Site Services - APT                                 ||        ||
                                                        ||        ||
 Phone : +61-2-8448-7919                               ||||      ||||
 Pager : +61-2-9430-6381                           ..:||||||:..:||||||:..
[============================[ USA 800-829-2447 ]=[ Aust 1800-121-531 ]====]


--
SLUG - Sydney Linux User Group Mailing List - http://slug.org.au/
More Info: http://slug.org.au/lists/listinfo/slug

Reply via email to