Subnetting

Subnetting

Subnetting

By Victor Napolillo, ecpi Technical College

            Each and every IP address that you will ever work with will fall into one of several classes, but always one.  Each of these classes has its own default subnet mask that is used if no subnetting is done:

Class                   IP Range                                     Default Subnet Mask         High Order Bits

Class A          0.x.x.x – 126.0.0.0                                       255.0.0.0                                0
Class B         128.0.x.x – 191.255.0.0                              255.255.0.0                           10
Class C         192.0.0.x – 223.255.255.0                          255.255.255.0                       110

Wait a minute, there are some numbers missing.  Where are 127.0.0.0 – 127.255.255.255?  IANA (Internet Assigned Numbers Authority) has designated that these are to be used for internal networks only.  That having been said, pay close attention to these numbers, as knowing them is the first step to understanding subnetting.

            Let’s look at networks and hosts.  In the above figure, the numbers indicate the network portion or octets of the IP address, while the “x” represents the host portion or octets.  Obviously, the more x’s you have, the greater the number of possible hosts on your network.

Class             Network Portion          # of Networks                 Host Portion            # of Hosts
Class A          1 number (octet)                126                             3 x (octets)              16,777,214
Class B          2 numbers (octets)            16,384                        2 x (octets)               65,534
Class C          3 numbers (octets)            2,097,152                  1 x (octets)               254

            Before any actual subnetting can be done, each octet in an IP must be converted to its binary equivalent.  We’ll pick the Host IP address of 196.16.8.3 for our example.

196                 .           16                    .           8                      .           3
11000100      .           00010000      .           00001000      .           00000011

Now let’s look at ANDing.  The subnet mask filters out the network bits by using ANDing. ANDing takes the IP address in binary value and uses the binary value of the subnet mask to determine the bits that are left as one or 'active'. This is accomplished by taking the first bit (beginning with octet 1) of the IP address and the first bit of the subnet mask and checking the outcome of the two bits.  There are only 4 possible outcomes:  1+1=1, 1+0=0, 0+1=0, and 0+0=0

255                 .           255                 .           255                 .           0
11111111      .           11111111      .           11111111      .           00000000

Now let’s AND them:

11000100      .           00010000      .           00001000      .           00000011
11111111      .           11111111      .           11111111      .           00000000
11000100      .           00010000      .           00001000      .           00000000 = 196.16.8.3

            So after ANDing, we have 196.16.8.0 as our Subnet; that means we can assign IP addresses to our Hosts of 196.16.8.0 – 196.16.8.255 right?  Well, almost.  All subnets need a network address and a broadcast address.  The Network address will always be the first address, in this case 196.16.8.0.  The Broadcast address is the last address in the range, or 196.16.8.255.  That leaves us with the useable Host Ips of 196.16.8.1 – 196.16.8.254.

            Think you have the hang of it?  Here comes the curve ball.  The IP address of 196.16.8.3 with a subnet of 255.255.255.0 is usually written as 196.16.8.3 /24.  Why the 24?  Remember that each octet of an IP is made up of 8 bits.  The default 255.255.255.0 can be thought of as 8 bits + 8 bits + 8 bits + 0 bits = 24 bits.  So what happens when you see an address of  196.16.8.3 /27?  Where do you get the extra 3 bits from?  Easy, you borrow them from the fourth octet’s host portion. Now we have 8 bits + 8 bits + 8 bits + 3 bits = 27 bits; lets see how that translates into binary:
11111111  .  11111111  .  11111111  .  11100000
Converted from binary to decimal:
255.255.255.226

This also means that we are now limited to only 5 bits for our Host portion of the IP.  The rule of thumb is that when Host bits go down, the maximum number of subnets goes up, but the amount of possible hosts on each network goes down.  Confused?  Let’s look at both of our examples together:

196.16.8.3 /24                                                           196.16.8.3 /27
11000100.00010000.00001000.00000011         11000100.00010000.00001000.00000011
Subnet Mask                                                           Subnet Mask
11111111.11111111.11111111.00000000         11111111.11111111.11111111.11100000

See where the 1’s stop on our /27 network?  That is the end of the Network portion, and the 0’s mark the beginning of the host portion.  So, our possible networks have gone up, but the number of possible hosts on each network has decreased.  In our original example (/24) we had 1 possible subnet with 253 useable hosts; now with our /27 subnet, we have 8 possible subnets but only 30 possible hosts.  It’s a trade off, and depending on the size of your network you can play with the numbers to fit your desired needs.

Terms You Just Ought to Know


ANDing – The process of comparing the binary values of an IP address with the subnet mask to determine network and host address.  The possible outcomes are: 1+1=1, 1+0=0, 0+1=0, and 0+0=0

BorrowTaking bits from the host portion of the network to create a Subnet or taking bits from the network portion of the address to create a Supernet.  (Note:  Subnetting goes from left to right in the subnet mask while supernetting goes from right to left.)

Broadcast Address - An address which can be used as the destination of a communication that indicates the packet/message is a broadcast. IP has broadcast addresses as does IEEE 802.

Host Portion - The portion of an IP address reserved for the host.

Network Address - The network portion of an IP address. For a class A network, the network address is the first byte of the IP address. For a class B network, the network address is the first two bytes of the IP address. For a class C network, the network address is the first three bytes of the IP address. In each case, the remainder is the host address.

Network PortionThe part of an IP address reserved for the network

Octet - 1) A byte that consists of eight bits. 2) A byte composed of eight binary elements.