The Arithmetic
Subnet size
The size of a subnet is calculated from the hosts bits. So, for /24:
- host bits:
32 - 24 = 8 - size: \(2^8\)
For /27:
- host bits:
32 - 27 = 5 - size: \(2^5\)
Two addresses in each subnet are reserved (subnet ID and broadcast ID). so:
- usable: \(size - 2\)
Fixed Length subnetting
- This is simply division. You divide the starting
sizeby the desired number of subnets:- subnet sizes are always powers of 2. As a result, division is also by powers of 2
- subnetting entails growing the prefix by a certain number of bits:
- growing the prefix by 1 bit is equivalent to dividing by 2
- growing the prefix by 2 bits is equivalent to dividing by 4
- growing the prefix by 3 bits is equivalent to dividing by 8
- given
nextra bits, division is by \(2^n\)
- the bits added to the prefix are "borrowed" from host bits.
- consequently, a subnet's size shrinks as its prefix grows and vice versa
Variable Length subnetting
This is essentially repeated fixed-length subnetting
- Determine number of networks
- Determine number of hosts per network
- Add 2 to number of hosts per network and round up to the nearest power of 2
- Perform a quick check that assigned network range can accommodate all the required addresses.
- Sort the networks in order of size (this can be altered but makes process not algorithmic)
- Starting with largest network:
- Divide the network into equal parts sized according to the largest subnet. The number of parts will determine how many extra bits to use in subnetting.
- Example: 1 extra bit to yield 2 subnets, 2 extra bits to yield 4 subnets, 3 extra bits to yield 8 subnets, etc
- Assign the blocks to subnets excluding already assigned blocks.
- Repeat the process, starting with the next biggest subnet until all subnets have been assigned.