Subnetworking
  Author: Logan
  Date: 8 Sept 2004
  Category: Networking
  Expertise Level: ++++
  ISA Logo

What is Sub-Networking and what does it do?

Throughout the history of computing, there are many examples of people failing to understand that computers and technology would grow at the rate that it has. IP and the internet is no exception. If not for new addressing techniques, we would have run out of A, B and C networks years ago. Subnetting provided the first significant addressing feature that would conserve IP address space.

Network classes still exist within subnetting [see the article on IP Addressing for more detail on classes]. However, subnetting allows you to divide those up into smaller more manageable chunks by allowing you to take a network and subdivide it up into many smaller networks. The need for this functionality is both technical and administrative.

  • All hosts in the same group must not be separated by a router (making them a single LAN)

  • Hosts separated by a Router must be part of a separate IP group

  • Without subnetting, the smallest group possible is a single Class A, B or C network, meaning we would have run out of assignable addresses years ago.

  • With subnetting, one or several networks can be assigned to an organisation and that organisation can take those addresses and subdivide them into smaller networks (subnets) of a more usable size.

To better explain why subnetting is needed, take point three listed above, "Without Subnetting the smallest group possible is a single class A, B, or C network." If we were to take this example to an extreme, and say I had been allocated a class A network; as a result I would have around four million IP addresses at my disposal. The trouble is without sub-networking, I can only use those within one single IP Group, in other words, one LAN (Local Area Network). As you may imagine, a single LAN with four million devices on it would be huge - I can not imagine there is a single LAN this large anywhere in the world. The answer therefore is Sub-Networking, to divide your address space up into smaller sections as that you can make multiple LANs from it, thus saving IP addresses.

Why can I not set up multiple LANs without dividing up my network? The answer to this question is simple: routers. In order to connect two or more LANs (thus forming a WAN [Wide Area Network]) you need a router separating them. If you were divide up your address space, how would your router then know whether to forward a frame or not? The answer is that it wouldn't. A network needs some form of structure in order to function, you can't divide your addresses as you see fit and expect your router to know where they are, it just wouldn't work! Sub-Networking allows you to do this though, but in an organised manner and with a set of rules that your router understands.

What are these rules and how do subnets work?

Explaining how subnets work is a little more difficult, the concept is more easily understood when looking at it in binary. If we take a private Class A network, 10.x.x.x and we were to apply a Subnet Mask of 255.255.255.0, this means that per LAN we have divided up our class A network into sub-networks that can host 254 devices. If we were to change that subnet mask to 255.255.252.0, the size of our LAN has just changed, and we can now host 1018 devices per subnet. How do these subnet masks divide up the network though and what do they mean? Well, as said earlier, the concept is most easily understood when reviewing it in binary.

If we take the first example, the subnet mask of 255.255.255.0 (our /24 network), and we will take an IP address of 10.239.16.1

In binary, they look like this:

Diagram: subnet-1

Looking at the subnet mask, the host portion of the LANs will be everything after the 1's (since there are 24 1's, we would refer to this as a /24 network) If we apply this information to the above examples we get the following:

Diagram: subnet-2

For a host to be a part of this subnet, the first three octets (the IP address before the / ) must be the same (10.239.16.x) the octet after the / is variable. For example:

Diagram: subnet-3

The next IP address in the sequence will be 10.239.17.1. To achieve this IP address we have to increment the value in the next octet. Since the next octet is part of the subnet portion of the address, this address will be part of another subnet. Therefore, the basic rule is, as soon as a binary bit has to increment past the host portion of the address, the new address is in a different subnet.

Diagram: subnet-4

To make it a little more complex, subnets are not just defined per octet; they can be set at (almost) any point in the address. For example, the /22 network (255.255.252.0) mentioned earlier - if we were to look at that in the same way that we did the /24 example, we would see the following:

Diagram: subnet-5

Now, in this example, all of the bits previous to the / must remain the same, otherwise, again, we would be looking at another subnet. However, since two of the bits after the / are within the third octet, this number can now increment, whilst remaining within the same subnet, but only to a certain point. This is where the features of sub-networking really begin to make sense. By changing the third octet of the subnet mask from 255 to 252 (and therefore moving the integer) the network has grown from being able to support 254 devices, to 1023.

To illustrate the /22 network example, in binary it would look like this:

Diagram: subnet-6

Again, the next IP address in the sequence will be part of another subnet:

Diagram: subnet-7

What does this mean to my router?

For the sake of this example, we will say that the local tnterface of your router has an address of 10.239.16.1, with a subnet mask of 255.255.252.0 (/22). Again, for the sake of this example, your IP address can be 10.239.19.124 and you wish to use an FTP server with an IP address of 10.239.102.54. Your PC will send the frame containing the data to your router, your router will look at the destination IP address and know that it is outside of its native subnet (as it knows its own IP address and subnet mask). The router ignores the host portion of the octet, and determines that the FTP server will be on the 10.239.100.0 network. Its routing table holds an entry for the router 10.239.100.1 and so it forwards the frame (dependent on the routing protocol) to 10.239.100.1. Upon receipt, that router will recognise that it is part of its own Subnet and forward the frame over its ethernet interface onto the LAN.

Assigning Subnet Masks

Your subnet mask will be assigned by your ISP or network administrator (depending on whether you are using a Private/Corporate Network, as in the above examples, or whether you are connecting to the internet using your ISP). However, as previously mentioned, you can set the host portion of the address up almost anywhere within the address. When setting subnets up though, you have to remember classes. For example, if we were to take the previous Class A addres example 10.x.x.x, you could not set a subnet mask of 252.0.0.0, as this subnet mask would exceed the available IP address range. The subnet mask for the maximum number of hosts would be 255.0.0.0, this would mean that you are not using sub-networking at all, as you would not be dividing your address range up. The same could be said of a Class B address 130.0.2.45 (for example) - you can not use a mask with a lesser value than 255.255.0.0, and for a class C address than 255.255.255.0

To better explain this, IP address are divided up into three sections: Network, Subnet and Host.

The Class A Network 10.0.0.0 using a subnet mask of 255.255.255.0 would be divided like this:

Diagram: subnet-8

The Class B Network 130.0.0.0 using a mask of 255.255.255.0 would be divided like this:

Diagram: subnet-9

The Network Portion of the address is always static. For Class A, it will be 8 Bits (the first octet). For Class B, it will be 16 bits (the first two octets). For class C, it will be 24 bits (the first three octets). The host portion will be dependent on the subnet mask - that is, the number of host bits as defined by the subnet mask. The Subnet portion will be 32 - (number of network bits + number of host bits).

Conclusion

Sub-networking is a difficult feature of TCP/IP to explain, and a fairly difficult feature to understand. The concept, however, is simple, and the use of it effective. Grasping the concept of sub-networking and its use is the first step towards understanding IP, routing and the design of networks.

Links