Tuesday, March 4, 2014

Subnetting: Like math but you actually use it.

I initially had trouble understanding subnetting because I rushed into it without having a deep understanding of how binary made up IP addresses.  So for the education of myself or anybody that needs to have it broken down, I'll try to explain.  This post assumes you know some of the generalities of how the internet works, but are fuzzy on the specifics of subnetting.

What is a subnet and why should I care?

A subnet is a logical division of a network.  A network is a group of computers that communicate with each other through (generally)  a backbone of Ethernet cords, switches, routers, and servers within a domain.  To best picture it,  consider a large office building to be a domain.   All of the computers in the office are in the domain.  The purpose of the network is to conveniently and privately share information in the office without going through the cloud of the internet.

The purpose of subnetting is to separate the office's network up in to pieces. This has many benefits.  For example,  most companies don't want the information on the Human resources computers to be easily accessible to the computers in the sales department.  Putting them on different subnets is best practice.  Also, in a large network, subnetting will make it for faster communication because it limits the number of  PCs contacted during a broadcast.

How does it work?

Here's where it gets complicated.    To understand subnetting, you must understand the elements of an IP address and to understand that, you must understand the binary nature of IP addresses.

An IP address such as 192.168.10.25 is not really “192.168.10.25″. IP hosts really see this address as:

11000000.10101000.00001010.00011001
The IP as us humans see it is in dot decimal notation.  To convert them to binary,you must first realize that each number(S) between the decimals translates to 8 digits in binary, each with different value based on their position.
The values based on position.
128 64 32 16 8 4 2 1

So,  lets do some simple math.     To get the 192 in the fist bracket,  you would need to add 128 and 64 together.  In binary, we can imagine a 1 to turn the full positional amount on and 0 to be turning the positional amount off.   So as listed above 192 equals  1100000 .   The 128 and 64 are turned on and the rest are turned off.
Now lets move on to 168.  128+32+8 will do it.   So converting it to binary looks like  10101000
Now, truthfully your windows calculator will convert this for you through the programmer function.  To me,  however, understanding the concept was important for me not to feel lost.  Let's move to the next important concept.

An IP address is comprised of two parts.  The network address and the host address.  The subnet mask is what will determine which parts of the address are which.  In your network settings,  you probably see something like this.
IP  192.168.10.25
Subnet mask  255.255.255.0
255 is the highest possible value in each of the decimal groups.  (Also called Octets because they take 8 bits each, just like IP.)     So the subnet mask is 24 bits  (8+8+8)  What this means for the IP address is that the first 3 octets are network addresses and the last one is the host address. What this means for an IT person is that your network has one octet (254 addresses plus one broadcast address) available to be assigned to local computers.  To the outside internet, they will appear to be coming from the IP of the same router. (default gateway)  But through a technology called  DNS,  they will be translated to the host computers address as necessary.   This is convenient as is conserves our limited number of public IPV4 addresses.    If we modified the subnet mask  to .255.255.0.0  we would have 16 bits and 65,534 hosts.  (take my word on the number of hosts.)  The trouble with this is that it leaves us with little flexibility in how many hosts we have.  254  or 65,534.   To get that number to Goldilocks levels of just right,  we must subnet.

To subnet, we are stealing a bit or two from the host address and using at a division to separate out a tighter fit  in the number of host addressed we have available.  Imagine you are in a company with 500  computers.    .254 is to small but 65,534 is too much to keep up with,
Red bits create new network addresses

The “stolen” host–>network bits are in bold:
/24 – 255.255.255.0  = 11111111.11111111.11111111.00000000
/25 – 255.255.255.128 = 11111111.11111111.11111111.10000000
/26 – 255.255.255.192 = 11111111.11111111.11111111.11000000
/27 – 255.255.255.224 = 11111111.11111111.11111111.11100000
/30 – 255.255.255.252 = 11111111.11111111.11111111.11111100

The 24 bit mask is normal.   It is the common class C mask. To learn about the historical classes,click here.  Nothing has been stolen and the last octet allows 254 hosts.   Each line below steals an additional bit from the host. Note that the quantity of new subnets does not match up with the quantity of stolen bits. For example, if you steal 3 bits, this does not mean you have just allowed for the creation of 3 subnets. Looking at the /26 row along with the IP address 192.168.10.0, this would mean you have a potential for the creation of 4 new networks using the expanded fourth octet of the mask (11000000): 00000000, 01000000, 10000000, and 11000000. These networks would correspond to 192.168.10.0, 192.168.10.64, 192.168.10.128, and 192.168.10.192. You have to realize, though,that the more you steal from the host address, the less hosts you have available for hosts.

When I continue,  We'll learn how to tell what subnet an IP belongs to.  It's not the most intuitive thing in the world, but with the right guidance, it can be done without a headache.

---Continued--

The way to find out the subnet, you must add up the binary form of the IP and the subnet mask.  Except,  this doesn't follow the normal rules of math. To get it,  you must  use this chart.
  • 1 + 1 = 1
  • 1 + 0 = 0
  • 0 + 0 = 0
So, lets add an example's IP and binary.

172.16.17.42 −- 10101100.00010000.00010001.00101010
255.255.240.0 − 11111111.11111111.11110000.00000000
Subnet address ==== 10101100.00010000.00010000.00000000 (172.16.16.00)

Ok,  I'll make up an example to work out.  Try to figure them out yourselves before looking at the answer.

192.168.12.52
255.255.255.230

11000000 10101000 000001100 00110100
11111111 11111111 111111111 11110000
11000000 10101000 000001100 00110000
192.168.12.48

Thoroughly frustrated?   Once you've got the concept down,  try using a subnet calculator.

Video Version


No comments:

Post a Comment