Computer Networks

Understanding IP Addressing and Subnetting

A practical, from-scratch guide to IPv4 addresses, subnet masks and CIDR — with worked examples you can follow along.

Abdullah IslamAbdullah Islam·
Illustration of IPv4 addressing and subnet masks

Every device on a network needs a way to be identified, and on an IP network that identifier is the IP address. In this guide we’ll break down how IPv4 addresses are structured, what a subnet mask actually does, and how to carve a network into smaller pieces using CIDR notation.

What an IPv4 address really is

An IPv4 address is a 32-bit number, almost always written as four octets separated by dots — for example 192.168.1.10. Each octet is 8 bits, so each part can range from 0 to 255.

Under the hood it is just a single integer. The dotted form is purely a convenience for humans:

192.168.1.10  ->  11000000.10101000.00000001.00001010

An address is split into two halves: the network portion identifies the subnet, and the host portion identifies the specific device inside that subnet.

The subnet mask

The subnet mask tells the device which bits belong to the network and which belong to the host. A mask of 255.255.255.0 means the first 24 bits are the network and the last 8 bits are the host.

Mask CIDR Hosts per subnet
255.255.255.0 /24 254
255.255.0.0 /16 65,534
255.255.255.128 /25 126

The number of usable hosts is 2^(host bits) - 2 — we subtract the network address itself and the broadcast address.

Working out the network address

You find the network address by logically AND-ing the IP with the mask. If our host is 192.168.1.10/24, the network is 192.168.1.0 and the broadcast is 192.168.1.255.

Subnetting is really just a bitwise exercise. Once you can picture the address as bits, the “magic numbers” people memorize start to make sense.

A quick CIDR example

Say you are given 10.0.0.0/26. A /26 borrows 2 extra bits from the host portion, creating 4 subnets:

  • 10.0.0.0/26 — hosts 10.0.0.1 through 10.0.0.62
  • 10.0.0.64/26
  • 10.0.0.128/26
  • 10.0.0.192/26

Each subnet has 62 usable host addresses.

Why this matters in practice

Understanding subnetting helps you:

  1. Design networks without wasting addresses.
  2. Read routing tables with confidence.
  3. Debug “why can’t these two devices talk” problems quickly.
  4. Work comfortably with cloud VPCs and their CIDR blocks.

Take it slowly and work a handful of examples by hand. The intuition comes faster than you might expect.

Newsletter

Learn with me

Join the newsletter to receive my latest articles. No spam, unsubscribe anytime.

You'll get a confirmation email. Check your inbox to complete your subscription.

Share this post

About the author

Abdullah Islam

Abdullah Islam

Abdullah Islam is a computer networking learner, tech blogger, and enthusiast who shares simple, practical guides to help others understand networking concepts and build real-world skills.

Comments

Similar posts

More articles on related topics.