To truly understand subnets it’s far easier to understand them from the perspective of the computer. Most people will be used to seeing a subnet written as, for example, 255.255.255.0, but decimal octets are purely for the readability of human eyes. Computers work with subnets on a binary level, and where a human sees 255.255.255.0, a computer sees 11111111111111111111111100000000.
So how does a subnet translate to network division? Well, every IP address has a network portion and a host portion, such as 192.168.2.128. In this example — if a subnet of 255.255.255.0 is used — 192.168.2 is the network and 128 is the host. The first question a computer asks itself is, “is the device I’m sending data to on the same network as me?”, and then proceeds to compare the destination IP address against its own IP address. If 192.168.2.128 is sending data to 192.168.2.206, then it can see by comparing it to the subnet 255.255.255.0 that they are both on the same network, and therefore the data only needs to be sent via the local network.
All of the 1′s in a subnet represent the network, and all of the 0′s represent the host; the computer aligns the subnet with the IP address to determine which numbers represent the network and which represents the host:
Here, anything which shares the network address of 11000000.10101000.00000010 is on the same network. If bits are borrowed from the host portion of the address, then for every bit that’s borrowed the available hosts per network is halved.
If a subnet of 11111111.11111111.11111111.10000000 is used, then the address space is halved into binary addresses that start with 0 and addresses that start with 1, and there would now be 2 networks under 192.168.2 with 126 hosts each.
If a subnet of 11111111.11111111.11111111.11110000 is used, then the following happens:
The network has now been cut in to 16ths and has 14 hosts per network. Thus with a subnet of 255.255.255.240, all of the addresses from 1 to 14 are in one network, and 17 to 30 are in another.
It’s important to remember that where one see’s all 1′s as the host address, this is the broadcast address, and all 0′s is the network ID. In the above example, all host addresses of 0000 are the network ID, and 1111 are the broadcast address. With an 8 bit host address this is 255 (e.g. 192.168.2.255) and 0 (e.g. 192.168.2.0) respectively, and as the amount of bits change so do these boundaries.
Working in binary makes life a lot easier once one gets used to it. By having a list of binary IP addresses handy, one can immediately see which addresses are going to fall into which network. Additionally by keeping in mind how many bits are being borrowed for the subnet, it is easy to mentally calculate how many hosts there will be per network.
With 11111111.11111111.11111111.10000000 there are 7 bits for the host, and so 2^7 = 128 – 2 = 126 hosts per network.
To calculate the subnet, the following table is needed:
Add up the columns that have the number 1 under them, and the subnet is converted. 11111111 = 255, and so the subnet is 255.255.255.240. Keep in mind that a subnet must be a series of 1′s in a row, and so there are only 8 possible values for each octet.