Demystifying Networking: A Beginner's Guide to IP Addresses, Subnet Masks, and Subnetting.

Kene OjiteliKene Ojiteli
9 min read

Networking was always that one topic I kept putting off until I realised it’s the backbone of almost everything I do as a DevOps Engineer. Concepts like Subnetting, CIDR notation, IP classes, and the OSI model used to feel overwhelming and sounded like magic to me. But with some patience and practical examples, I finally cracked the code, and I want to help you do the same.

In this article, I will break down everything I wish I understood, from the basics of how computers communicate using IP addresses to what subnetting means and how everything connects within the OSI model. Whether you are a complete beginner, someone brushing up, preparing for a cloud certification, or diving into DevOps, this article will simplify those tricky networking topics in a way that makes sense.

How Computers Communicate Using IP

Computer networking is the process by which computers and devices communicate with each other and exchange information. For example, the way humans communicate via texts and calls with phones, computers communicate via networks to send and receive data. This communication happens through connections, like cables (wired) or Wi-Fi (wireless), using rules called protocols (like IP, TCP, HTTP).

An IP (Internet Protocol) address is a unique address that identifies a device on the Internet or a local network. Think of an IP address the same way a house address is used to locate or differentiate a house (no two houses share the same address), an IP address uniquely identifies a device on a network.

It’s important to note that the computer only understands bits and bytes (0s and 1s), so it uses an IP address (for example, 192.168.10.20 converted to binary) while humans use hostnames (for example, www.google.com).

Private IP addresses usually range from:

  • 10.0.0.0 – 10.255.255.255

  • 172.16.0.0 – 172.31.255.255

  • 192.168.0.0 – 192.168.255.255

While Public IP addresses are:

  • Routable on the internet.

  • Assigned by your ISP or cloud provider.

Understanding IP addresses

At the moment, an IP address has two versions: IPv4 (an older version that is running out of addresses, which uses a 32-bit address space with a dot-decimal notation) and IPv6 (which uses a 128-bit address space, providing a virtually limitless number of addresses using hexadecimal notation). I will be focusing on IPv4 in this article.

Understanding IPv4 Addressing

An IPv4 address is a 32-bit number divided into 4 octets separated by a dot. This means that each octet is made up of 8 bits (which is also equivalent to 1 byte) and each octet ranges from 0 - 255 (where 0 is the minimum value and 255 is the maximum value). The image below shows a typical IPv4 address in both decimal and binary format.

ipv4

An IP has 2 parts, namely the host bit (which identifies devices within the network) and the network bit (which identifies the network, and is the reserved or fixed portion), but this is determined by the IP address class (IP addresses are divided into classes based on their first octet).

Ip address classes

There are 5 main IP address classes. This article focuses on types A, B, and C, which are used by large organisations, medium-sized businesses, and small networks, respectively. Types D and E are reserved for multicast and experimental use, respectively.

N.B.: Class A ranges from 1 - 126 and Class B ranges from 128 - 191, one would wonder if 127 was omitted? No, 127 was not omitted; it is reserved for loopback, making Class A have only 126 usable networks.

From the diagram above, I will break down how to calculate the number of available hosts and the number of networks for each class.

To calculate the number of networks = 2 ^ (Number of network bits)
The number of network bits depends on how many bits are reserved for identifying networks in that class.

ClassNetwork BitsNumber of Networks (2^network bits)
A7 bits2⁷ = 128 → 128 - 2 = 126 usable
B14 bits2¹⁴ = 16,384 networks
C21 bits2²¹ = 2,097,152 networks

This calculation is done based on the default subnet mask (a 32-bit value used to distinguish the network portion of an IP address from the host portion) for each class (refer to the first diagram in this article).

For Class A;

Subnet mask in decimal = 255.0.0.0      
Subnet mask in binary = 11111111.00000000.00000000.00000000 (the computer only understands numbers in binary format). 
Network bit = 11111111 = 2 ^ (8 - 1) = 2 ^ 7 = 128 (the first bit in class A is always 0, making 7 bits available, so we subtract 1 from the sum of the first octet)
Total Class A network = 128
Usable Class A network = 128 - 2 = 126 (0.x.x.x and 127.x.x.x are reserved for special routing and loopback, respectively).

For Class B;

Subnet mask in decimal = 255.255.0.0      
Subnet mask in binary = 11111111.11111111.00000000.00000000 
Network bit = 11111111.11111111 = 2 ^ (16 - 2) = 2 ^ 14 = 16,384 (the first 2 bits in class B are always 10, so we subtract 2 from the sum of the first 2 octets)
Total Class B network = 16,384

For Class C;

Subnet mask in decimal = 255.255.255.0      
Subnet mask in binary = 11111111.11111111.11111111.00000000 
Network bit = 11111111.11111111.11111111 = 2 ^ (24 - 3) = 2 ^ 21 = 2,097,152 (the first 3 bits in class C are always 110, so we subtract 3 from the sum of the first 3 octets)
Total Class C network = 2,097,152

Note that the network bits are the octets comprising 1.

To calculate the number of available hosts = 2 ^ (Number of host bits) - 2, where the 2 subtracted is reserved for the network ID and broadcast address.
Using the formula above is similar to calculating the network bits except that the host bits comprise zero (0) in the subnet mask, and subtracting 2 for each class.

For Class A;

Subnet mask in decimal = 255.0.0.0      
Subnet mask in binary = 11111111.00000000.00000000.00000000 
Host bit = 00000000.00000000.00000000 = 2 ^ 24 = 16,777,216
Total Class A hosts = 16,777,216
Usable Class A hosts = 16,777,216 - 2 = 16,777,214

For Class B;

Subnet mask in decimal = 255.255.0.0      
Subnet mask in binary = 11111111.11111111.00000000.00000000 
Host bit = 00000000.00000000 = 2 ^ 16 = 65,536
Total Class B hosts = 65,536
Usable Class B hosts = 65,536 - 2 = 65,534

For Class C;

Subnet mask in decimal = 255.255.255.0      
Subnet mask in binary = 11111111.11111111.11111111.00000000 
Host bit = 00000000 = 2 ^ 8 = 256
Total Class C hosts = 256
Usable Class C hosts = 256 - 2 = 254

Here is a quick recap

ClassFirst Octet RangeDefault Subnet MaskNumber of Hosts per NetworkNumber of Networks
A1 - 126255.0.0.0 (/8)16,777,214128 (2⁷) - 2 = 126
B128 - 191255.255.0.0 (/16)65,53416,384 (2¹⁴)
C192 - 223255.255.255.0 (/24)2542,097,152 (2²¹)

Subnets, CIDR notation and Calculating IP Ranges

Subnet stands for sub-network. It is a smaller part of a larger network. They make networking more secure, organised and efficient.

CIDR (Classless Inter-Domain Routing) is a more flexible method for defining network size. CIDR removes the strict class rules (A, B, C) and allows more flexible subnetting.

A typical example of CIDR is 192.168.1.0/24, where /24 indicates that 24 bits are reserved for the network part and the remaining 8 bits (32 - 24 = 8) are allocated for the host part (32 - CIDR).

Calculating Subnet Info and IP Ranges using examples

Before delving into examples, here is a list of how to calculate subnet info and IP ranges:

  • Calculate the network bit from the CIDR block (this is the number after the forward slash).

  • Calculate the host bit: (32 - CIDR).

  • Calculate the number of available hosts (the number of IP addresses): 2 ^ (number of host bits) - 2.

  • Calculate the network address, first assignable IP, last assignable IP, and the broadcast address.

  • N.B.: As the subnet mask gets larger, the IP ranges get smaller.

Example 1: 192.168.1.1/24
IP address class: C
CIDR: /24
Subnet mask(decimal): 255.255.255.0
Subnet mask(binary): 11111111.11111111.11111111.00000000
IP address(binary): 11000000.10101000.00000001.00000001
Network bit: 24
Host bit: 32 - 24 = 8 (a short way to get this is to convert the subnet mask and IP to binary, then match the 1s in the subnet mask with the IP address based on the CIDR, the remaining part with 0s is the host bit)
Number of available hosts: 2 ^ (8 - 2) = 254
Network Address: 192.168.1.0
First Assignable IP: 192.168.1.1
Last Assignable IP: 192.168.1.254
Broadcast Address: 192.168.1.255
Example 2: 205.150.65.0/26
IP address class: C
CIDR: /26
Subnet mask(decimal): 255.255.255.0 now becomes 255.255.255.192
Subnet mask(binary): 11111111.11111111.11111111.11000000 (since the CIDR is /26, the last bit becomes 11000000)
IP address(binary): 11001101.10010110.01000001.00000000
Network bit: 26
Host bit: 32 - 26 = 6 
Number of available hosts: 2 ^ (6 - 2) = 62
Network Address: 205.150.65.0
First Assignable IP: 205.150.65.1
Last Assignable IP: 205.150.65.62
Broadcast Address: 205.150.65.63

OSI Model

The OSI (Open Systems Interconnection) model is a conceptual framework that describes how data travels through a network. It divides network communication into seven layers, each with specific responsibilities.

A mnemonic to remember the 7 layers is All People Seem To Need Data Processing or Please Do Not Throw Sausage Pizza Away from top to bottom or bottom-up, respectively.

LayerOSI LayerWhat Happens HereExamples
7ApplicationThe user initiates a request to the server with a specified protocolHTTP, HTTPS, FTP, DNS, SMTP
6PresentationTranslates, encrypts, and compresses dataSSL/TLS, JPEG, MP4, ASCII
5SessionStarts, manages, and ends sessions. Browser creates a session to avoid multiple authentication with the server.API sessions, NetBIOS, RPC
4TransportBreaks data into chunks (segments); ensures deliveryTCP, UDP, ports (e.g., port 80, 443)
3NetworkFinds path to destination; adds IP addressesIP, ICMP, Routers
2Data LinkRequests are sent to switches, and these switches convert data to frames, which also adds a MAC (informs the switches about other components within the network) from the IP address sent from the previous layerEthernet, MAC address, ARP, Switches
1PhysicalData is transmitted through electronic signals using optical cablesCables, Wi-Fi, Hubs, Network Interface

This is a beginner-friendly article that explains:

  • How computers communicate using IP addressing.

  • Subnets, CIDR notation and calculating IP ranges.

  • How to calculate subnet info and IP ranges with real examples.

  • The OSI model.

At this point, you should have a solid grasp of how IP addressing works, what subnets do, how to calculate hosts and ranges, and how the OSI model fits into the bigger networking picture. These aren’t just theories, they are skills needed in cloud computing, DevOps, and system design. Whether you’re debugging network issues or configuring infrastructure on AWS, understanding these fundamentals gives you confidence and clarity.

In Part 2, I will put this knowledge into practice by building real subnets on AWS and testing traffic flow within a real network infrastructure, all using Terraform.

Share this with someone who is learning DevOps or networking!

Until then, stay curious and happy subnetting! ✌

5
Subscribe to my newsletter

Read articles from Kene Ojiteli directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Kene Ojiteli
Kene Ojiteli

I have experience building highly accessible, scalable, and reliable cloud infrastructure and have experience with AWS, Linux, Git, Docker, and Kubernetes. S3, EC2, CloudFormation, CloudFront, Auto-Scaling Group, Elastic Load Balancer, IAM, Cloud9, VPC, RDS, Route53, and other AWS services are just a few of the ones I am familiar with. I have experience building CI/CD pipelines, high-availability web apps, and websites. I'm excited about designing, implementing, and automating cloud-based apps while utilizing best practices like configuration management, continuous integration, and deployment.