Understanding TCP/IP Subnets

A TCP/IP subnet is a segment of a network where all of the computers on that segment can communicate with each other without having to go through a router.  The computers on the subnet will have IP addresses that are within a given range of addresses, and those addresses will all have the same network ID as defined by the subnet mask.  Lost me?  Let's take a closer look...

Let's say that your ISP has leased you a range of IP addresses, say 168.2.24.0 - 168.2.24.255, and told you that your subnet mask is 255.255.255.0.  What does that mean?  Well, a closer look at the subnet mask should clarify things.

An IP address or a subnet mask is typically written in dotted-decimal notation (255.255.255.0).  Each section is called an octet, with a possible range of 0-255.  They're called octets because they can be converted to a binary number 8 bits long.  So when we convert our subnet mask to dotted-binary notation, we get:

11111111.11111111.11111111.00000000

Where the ones end and the zeros begin is the imaginary line between the network ID (the ones) and the host ID (the zeros).  This means that, in our case, the first 24 bits are reserved for the network ID, and the last 8 bits are reserved for host ID's.  So our network ID (shown with a host ID of all zeros) is 168.2.24.0, or shown in binary:

10101000.00000010.00011000.00000000

and the upper end of our subnet (host ID of all ones) in binary is:

10101000.00000010.00011000.11111111 (168.2.24.255)

Often, the subnet is presented as networkID/numberOfBitsInTheNetworkID, or 168.2.24.0/24.

Before we proceed to subnet our range even further, let's throw in a couple of additional details that we can refer to later.  The first address in our range is 168.2.24.0 (host ID 00000000).  You can't assign this address to a computer (the host ID can't be all zeros nor all ones).  These special addresses are reserved for broadcasts.  So you can only assign 168.2.24.1 through 168.2.24.254 to computers (and printers and routers and such), yielding 254 addresses.  Often, a router is given the .1 address (168.2.24.1) so that computers on our subnet can talk to other subnets (or the Internet).

254 computers broadcasting to each other can get pretty chatty, leading to lots of traffic, degrading performance.  So, often times, network administrators will further break up a subnet this size into smaller subnets.

To break the subnet into two subnets, we simply take an extra bit for the network ID leaving one less bit for host IDs. So now our binary subnet mask represents 25 bits for the network ID and will look like this:

11111111.11111111.11111111.10000000 (255.255.255.128)

This breaks our address range is broken up into two subnets.  With only seven host bits, instead of 256 addresses, each can only contain 128, 00000000 (0) - 01111111 (127) for the first subnet, and 10000000 (128) - 11111111 (255) for the second subnet.  Another way to say this is that the range of the first network 168.2.24.0/25 is from 168.2.24.0-168.2.24.127 and the range of the second network 168.2.24.128/25 is from 168.2.24.128 - 168.2.24.255. 

Keep in mind that as before, you can't assign a host ID with all zeros nor all ones, so in the first subnet, 168.2.24.0 and 168.2.24.127 can not be assigned to a host (the router for this subnet will likely be assigned 168.2.24.1 again), and in the second subnet, 168.2.24.128 and 168.2.24.255 can not be assigned (the router will likely be assigned 168.2.24.129).  Got that?

Let's do that one more time, and this time we'll break our range into four subnets.  To do that, we take yet another bit for the network ID (26 bits this time), that's:

11111111.11111111.11111111.11000000 (255.255.255.192) which breaks the range into 4 subnets of 64 addresses each:

168.2.24.0/26 (168.2.24.0-.63), .0 and .63 may not be used, router goes on .1
168.2.24.64/26 (168.2.24.64-.127), .64 and .127 may not be used, router goes on .65
168.2.24.128/26 (168.2.24.128-.191), .128 and .191 may not be used, router goes on .129
168.2.24.192/26 (168.2.24.192-.255), .192 and .255 may not be used, router goes on .193

You can go the other way, and make two subnets into one bigger subnet, but I'll save that for another post.  Happy subnetting!

0 comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...