Within this tutorial, we will provide a beginner’s guide to subnetting. Before we dive into subnetting we will look into the structure of an IP address, along with some of the key IP schemes that assist in modern day IP subnetting.

Note: The scope of this document covers IPv4 subnetting only.

What is IP?

IP is a connectionless protocol that operates at the network layer of the OSI model. IP enables communication between hosts by carrying data within packets. Each host is assigned an IP address which is used to ensure that traffic is sent to the correct destination, synonymous in many ways to a postal address that we place on a letter.


An IP address (in the case of v4) is built upon 32-bits, expressed in four numbers known as octets. Each octet is 8 bits i.e one byte.

Each address is made up of 2 identifiers (shown below):

  • Network - the network the IP address belongs to. For example the street name.
  • Host - the host identifier of the device for the network. For example the house number.


Figure 1 - IP Address.

To determine which parts of an IP address are the network bits, and which are host bits, a subnet mask is used. Within a subnet mask, the sequential bits that are on (1) are deemed the network bits and the bits that off (0) are considered the host bits. For example, would result in the first 2 octets (16bits) being the network bits and the remainder being the host bits.


When the IP protocol was first released it was built upon a classful addressing architecture. This architecture provided three different network classes - known as class A, B and C. Each class provided a different subnet mask based upon the IP range.

Class 1st Octet Bits Range Mask
A 0 –
B 10 –
C 110 –
Class Mask Range Range Prefix Binary
A– /8 00001010.00000000.00000000.00000000
B– /12 10101100.00010000.00000000.00000000
C– /16 11000000.10101000.00000000.00000000

However, this was hugely inefficient, should a company require 2 IP addresses for a point to point link then the smallest classful network that could be assigned was a class C network, which would provide 256 hosts. As you can see this was a huge waste.


With the explosion of the internet and the need to address more and more devices, this issue was compounded and a solution was required.

The solution to this issue came in the form of - Classless Inter-Domain Routing (CIDR) and Variable Length Subnet Masking (VLSM). Both of which are key to modern day subnetting.

Classless Inter-Domain Routing (CIDR)

CIDR (as per RFC1519) was implemented to allow the routing of both classful and classless networks. Classless networks do not use the subnet masks mandated by the different A, B or C classes, instead, the subnet mask (aka CIDR “bit” notation) is represented - ranging from /8 to /32.

This allowed networks to be aggregated, reducing the number of entries in the IP routing tables, whilst also allowing for greater efficiency in IP route processing.

Variable Length Subnet Masking (VLSM)

VLSM is the "subnetting of subnets," which means that VLSM allows network engineers to divide an IP address space into a hierarchy of subnets of different sizes, making it possible to create subnets with very different host counts without wasting large numbers of addresses.[1]

Subnetting Overview

First of all - what is subnetting?

A subnetwork or subnet is a logical subdivision of an IP network.The practice of dividing a network into two or more networks is called subnetting.[2]

Subnetting provides us with a number of benefits, such as:[3]

  • Conserving IP addresses.
  • Reducing networking traffic (i.e BUM).
  • Simplifying the network design.

If you recall, we previously spoke about an IP address having a network and host identifier. Subnetting works by taking bits from the host part of an IP address in order to create subnet identifier bits (shown below). We then use these subnet bits to calculate the number of additional subnets available.


Figure 2 - Subnetting.

How to Subnet w/ Examples

In order to show how subnetting is performed, I will step through a number of examples. I won't go into full-blown explanations I will cut straight past the BS, to the calculations. Boom!

Before we begin, it is worth mentioning that I will use a technique that uses something known as the magic number.

The Magic Number

The magic number is simply the decimal representation of the host bits (in red).

IP Address =
Subnet Mask = /26 or
Magic Number: 256 - 192 = 64

We will now use the magic number as part of our examples. Let's go…

Subnet Mask Chart

Here is a quick reference table for help when subnetting.

Subnet Mask CIDR Binary Notation Network Bits Host Bits Available Addresses /32 11111111.11111111.11111111.11111111 32 0 1 /31 11111111.11111111.11111111.11111110 31 1 2 /30 11111111.11111111.11111111.11111100 30 2 4 /29 11111111.11111111.11111111.11111000 29 3 8 /28 11111111.11111111.11111111.11110000 28 4 16 /27 11111111.11111111.11111111.11100000 27 5 32 /26 11111111.11111111.11111111.11000000 26 6 64 /25

11111111.11111111.11111111.10000000 25 7 128 /24 11111111.11111111.11111111.00000000 24 8 256 /23 11111111.11111111.11111110.00000000 23 9 512 /22 11111111.11111111.11111100.00000000 22 10 1024 /21 11111111.11111111.11111000.00000000 21 11 2048 /20 11111111.11111111.11110000.00000000 20 12 4096 /19 11111111.11111111.11100000.00000000 19 13 8192 /18 11111111.11111111.11000000.00000000 18 14 16384 /17 11111111.11111111.10000000.00000000 17 15 32768 /16 11111111.11111111.00000000.00000000 16 16 65536 /15 11111111.11111110.00000000.00000000 15 17 131072 /14 11111111.11111100.00000000.00000000 14 18 262144 /13 11111111.11111000.00000000.00000000 13 19 524288 /12 11111111.11110000.00000000.00000000 12 20 1048576 /11 11111111.11100000.00000000.00000000 11 21 2097152 /10 11111111.11000000.00000000.00000000 10 22 4194304 /9 11111111.10000000.00000000.00000000 9 23 8388608 /8 11111111.00000000.00000000.00000000 8 24 16777216


Calculate the next 5 Networks

What are the next 5 networks from

Our answer is calculated via the following steps:

  1. The magic number is 16 (/28 == ; 256-240 == 16).
  2. How many 16’s fit into = 0.
  3. Therefore the first network is
  4. Keep adding the magic number to obtain the next network.

The following 5 networks are:

Calculate the Total Available Subnets

How many subnets and hosts per subnet can you get from the network

Our answer is calculated via the following steps:

  1. Calc the subnet bits.
    • Net bits = 16bits.
    • Host bits = 4bits.
    • Subnet bits = 12bits.
  2. The total subnets is 4096 (based on 12bits)
  3. The total hosts per subnet.
    • Lets us the magic number. 256 - 240 = 16.
    • Minus 2 (1 for network number and 1 for broadcast) = 14.

Total subnets = 4096
Total hosts (per subnet) = 14

Calculate the Valid host Range

What is the valid host range of a part of?

Our answer is calculated via the following steps:

  1. The magic number is 16 (/20 == ; 240-256 = 16).
  2. How many 16’s (magic number) into x.x.93.x? 80
  3. The network number is
  4. The broadcast is:
    1. 3rd octet = 80 + 16 (magic number) - 1 = 95
    2. 4th octet = 255.
  5. Network Range is

The valid range is

Calculate the Subnet

Which subnet does host belong to?

Our answer is calculated via the following steps:

  1. The magic number is 32 (x.x.x.224-256).
  2. How many 32’s in 192

The subnet is

Calculate the Broadcast Address

What is the Broadcast of

Our answer is calculated via the following steps:

  1. The magic number is 128 (x.x.x.128-256).
  2. How 128’s fit into x.x.x.0? 0
  3. Next subnet is
  4. Range of subnet is

Broadcast is


  1. "What is variable-length subnet mask (VLSM)? - Definition from WhatIs ...." 17 Aug. 2014, Accessed 7 May. 2019. ↩︎

  2. "Subnetwork - Wikipedia." Accessed 7 May. 2019. ↩︎

  3. "Simplify Routing with Subnetting: How to Organize Your Network Into ...." 8 Nov. 2007, Accessed 7 May. 2019. ↩︎

Ready to Master Network Automation? Start Your Journey Today!
Our membership provides:
  • Full deep-dive course library (inc. Batfish, pyATS, Netmiko)
  • Code repositories inc. full course code, scripts and examples
  • 24x7 multi-vendor labs (Arista, Cisco, Juniper)
  • Private online community
  • Live monthly tech sessions
  • Access to tech session library

Join Now ➜