Bloodaxe's Realm     The Medieval World  


Learn the basics of subnetting a TCP/IP network
Page 2 of 2


It helps to have an understanding of the binary math involved in the above computations. Let's start by looking at how to convert an IP address to binary. The table below shows that binary math is made up of bits and values, which correspond to the numbers in an IP address:

Bit 1 2 3 4 5 6 7 8
Value 128 64 32 16 8 4 2 1

So given an address such as 192.168.0.1 and a mask of 255.255.255.0, what does that mean? Let's break down the four octets of 192.168.0.1.

To get the 192 in the first octet we need a 128 and a 64 (added together they equal 192), which would look like this:

Bit 1 1 0 0 0 0 0 0
Value 128 64 32 16 8 4 2 1

To get 168 for the second octet requires a 128, a 32, and an 8:

Bit 1 0 1 0 1 0 0 0
Value 128 64 32 16 8 4 2 1

The next two are easy with all zeroes for the third octet and a single 1 for the fourth octet:

Bit 0 0 0 0 0 0 0 0
Value 128 64 32 16 8 4 2 1

 

Bit 0 0 0 0 0 0 0 1
Value 128 64 32 16 8 4 2 1

When put together, the binary representation of 192.168.0.1 is:
 
11000000.10101000.00000000.00000001

Next, weíll break down the subnet mask, which in our example is 255.255.255.0. In binary, that would look like this:
 
11111111.11111111.11111111.00000000

This was pretty easy. As you can see above, decimal 255 is the same as having all 1s. Therefore, a mask of 255.255.255.0 tells us that the first three octets are used for the network portion of the address and the last octet is used for the host portion. Reading from left to right, wherever the 1s stop in the subnet mask is where the network portion of the address stops. The 0s represent the host portion of the address. Thus, if you compare the IP address to the subnet mask and you bring down the 0s in the subnet mask to "erase" any of the 1s in corresponding slots in the IP address, you will arrive at the network address. Here's a look at how it works:

11111111.11111111.11111111.00000000  255.255.255.0 [Subnet mask]
11000000.10101000.00000000.00000001  192.168.0.1     [IP address]
11000000.10101000.00000000.00000000  192.168.0.0      [network address]

Subnetting means planning
Before actually subnetting a network, itís good to do some planning. How many host addresses will be needed? How much room will be needed for expansion? Itís easier to make room when first subnetting than it is to go back later and resegment a large network.

Also remember that in every IP subnet, there will be a network address and broadcast address. In our example, the network address would be 192.168.0.0 and the broadcast would be 192.168.0.255. You can't use these two addresses for hosts. That leaves us with 192.168.0.1-192.168.0.254 to use with hosts. No matter how you subnet your network, you must always remember to avoid using the network address (the first address) or the broadcast (the last address) for any hosts.

Valuable knowledge
Of course, there's a lot more to subnetting, but this should help you to understand basics. I recommend downloading a subnet calculator and playing with some example networks. The more you work with IP addressing and subnetting, the easier it becomes.

Knowledge of subnetting can be extremely helpful, even if you arenít breaking up networks all the time. Not only will it help you manage whatever networks may be under your control, but itís also good to have an understanding of whatís going on in the background. Being able to subnet helps you understand how computers make decisions on whether to route a packet. Subnetting also allows you to make better use of available IP addresses, makes dividing networks easy, and allows you separate subnets logically.