In this post, let’s recall what is subnetting (for routing and switching purposes) and how it is done.
introduction and motivation
Network subnetting is very important subject that maybe referred to as VLSM for variable length subnetting. The basic idea is about managing a space of IP addresses (IPv4). Historically, a network length or space was fixed and known at advance: we distinguish class A network, from B, C and D. A class C network is 8 bit long offering almost 2^8=256 IP address to assign to hosts, network nodes, servers, objects, etc wheras a class B is 16 bit long, a class A 24 bit long (an IP address is 32 bit long and divided into two parts: a network part that identifies the network of association and host part that identifies the host in the network). With internet growth, this way of doing things showed big limitations and waste of usable IP addresses… VLSM is supposed to overcome these limitations by allowing more control of this allocation of IP address in the form of subnets of any length (not limited to classes A, B and C).
Then, given a network ip address, what would be the optimal subnetting (subdividing the network address into subnetworks) method? optimal, such as to use the less possible ip addresses, the less possible subnets, a subnet per vlan or multiple subnets per vlan, etc. depending on our need and the case (hosting (hosts and servers), segmenting (security) switching or routing, etc.)
A top down approach
Let’s suppose that we’ve been assigned this network x.y.z.w/L and a need for n department (this seperation maybe for security or routing reasons, etc.). Each i department needs d_i ip addresses (host IP addresses), where i is any number between 1 and n.
a flat network
If we use a flat network assignment, the total of ip addresses we need are d_1 + d_2 + … + d_i + … + d_n = D. D must be at least less than 2^(32-L) the total available users of host space in a flat network assignment… we need to find L in such way that D is fullfilled with the minimum waste of host space.
from the biggest network need to the smallest
In a top-down approach we start by the biggest d_i. We process x number such as 2^x > d_i > 2^(x-1). x must satisfy this condition, L-x >= 0. Then we have 2^(32-L-x) new /32-x sub networks. The first network is used to satisfy d_i need. For the next biggest department we’re sure that the next available /32-x network would fit.
Our next job is to try to optimize this network usage of ip addresses… and redo the same for the remaining subnets (ordered by size, from the biggest to the smallest); we’re sure that this method is less efficient than the flat network method but allowes other features (routing, etc.). A flat network may burden the network at OSI level 2: a huge broadcast domain is not a good idea… (requires CPU processing).
top down approach some limitations
This approach have some limitations. For example:
- a d_i = 1023 may require a 2048 subnet block instead of a 1024. To d_i we need to add the broadcast and network addresses that are not usable by hosts in non point-to-point network (/31 masks). The result is that 2048 – 1023 + 2 = 1023 addresses are reserved but not used…
- many subnets like the previous one may deplete rapidly our available space…
- the processing of subnets is dependent of their order by size. If the initial size varies for any reason, the calculation needs to be done for all the space…
A down top approach
The down-top approach helps resolve some top-down aproach limitations.
infinite small subnetting
Let’s suppose now that we all our space is subnetted into /31 point network. In such way, if d_i is even, d_i/2 subnetwork of /31 fits its need totally. The worst case is when d_i/ is odd, then we need d_i/2 + 1, /31 subnets to fit d_i need…
We’ve realized the most optimal subnetting using only /31 subnets. It is optimal in terms of effective usage of the reserved ip address space…
small subnet and aggregate to fit the need
to fit the need of any subnet we just aggregate those micro subnets (the same applied to formatting of hard drives)
issues of down to top subnetting
This approach resolves some top-down approach limitations but causes other issues:
- each /31 subnet would correspond to a vlan? router sub interface? router interface?
- two /31 subnets pertaining to the same department would communicate through a layer 3 versus a layer 2 path which is not always optimal
- the available vlan space could be rapidly exhausted if we need to assign each subnetwork to a vlan id
- the routing table would grow rapidly… subnetting like this requires more routing work against switching
What else… an hybrid
An hybrid approach would take advantages of the both down-top and top-down approach in building an efficient subnetting technique…