teluzia.Cloud Engineer · Day 16
CHAPTER 03 · NETWORKING FUNDAMENTALS

IPv4, binary math and CIDR

4–5 hours including independent practice3 topics
LET’S MAKE THIS SIMPLE

What you’re learning today

Convert IPv4 addresses into bits and calculate network membership with CIDR. The aim is to understand why a prefix divides an address space, not to memorize a list of masks. Python’s standard ipaddress module will check arithmetic after you first predict the result. An IPv4 address contains 32 bits displayed as four decimal octets. Each octet ranges from zero to 255 because eight bits represent 256 values. Binary positions carry weights 128, 64, 32, 16, 8, 4, 2 and 1. Leading decimal appearance does not determine network membership without a mask. A CIDR prefix /n identifies the first n address bits as network bits. The remaining 32-n bits describe positions inside the block, so the total address count is 2 raised to that remainder. A /24 mask is 255.255.255.0; a /26 contains 64 total addresses. Usable counts depend on context.

Think of it this way

CIDR is a street boundary: the prefix chooses the neighborhood and the remaining bits choose the house within it.

TOPIC 01 / 03Step by step

IPv4 and binary octets

An IPv4 address contains 32 bits displayed as four decimal octets. Each octet ranges from zero to 255 because eight bits represent 256 values. Binary positions carry weights 128, 64, 32, 16, 8, 4, 2 and 1. Leading decimal appearance does not determine network membership without a mask. Decimal 192 equals binary 11000000 because 128 plus 64 is 192; 10.0.0.5 contains four independent eight-bit values. Binary representation explains mask operations and address boundaries and removes guesswork when a subnet prefix cuts through the middle of a displayed decimal octet today. Treating 256 as a valid octet exceeds eight-bit capacity; validate every octet rather than assuming any dotted four-number string is a usable IPv4 address.

WORKED EXAMPLE
Decimal 192 equals binary 11000000 because 128 plus 64 is 192; 10.0.0.5 contains four independent eight-bit values.
Why this matters

Binary representation explains mask operations and address boundaries and removes guesswork when a subnet prefix cuts through the middle of a displayed decimal octet today.

A common trap

Treating 256 as a valid octet exceeds eight-bit capacity; validate every octet rather than assuming any dotted four-number string is a usable IPv4 address.

MAKE IT VISIBLE

Explore a network boundary

CHANGE ONE VALUE. SEE WHAT HAPPENS.

Where does this network begin?

A CIDR prefix reserves the first bits for the network. More network bits means fewer addresses inside each network.

00001010000000000000000100101010
Network bits: 24Host bits: 8
NETWORK10.0.1.0/24
ADDRESS RANGE10.0.1.0 – 10.0.1.255
TOTAL ADDRESSES256
AWS SUBNET USABLE251
✦

AWS reserves five addresses in each subnet. Conventional IPv4 host counting often subtracts two instead. This explorer uses the AWS subnet count. AWS IPv4 subnet sizes range from /16 to /28; values outside that range are shown here to teach CIDR math.

Read all topics in this lesson

A complete reference to revisit alongside the guided steps above.

IPv4 and binary octets

An IPv4 address contains 32 bits displayed as four decimal octets. Each octet ranges from zero to 255 because eight bits represent 256 values. Binary positions carry weights 128, 64, 32, 16, 8, 4, 2 and 1. Leading decimal appearance does not determine network membership without a mask. Decimal 192 equals binary 11000000 because 128 plus 64 is 192; 10.0.0.5 contains four independent eight-bit values. Binary representation explains mask operations and address boundaries and removes guesswork when a subnet prefix cuts through the middle of a displayed decimal octet today. Treating 256 as a valid octet exceeds eight-bit capacity; validate every octet rather than assuming any dotted four-number string is a usable IPv4 address.

WORKED EXAMPLE
Decimal 192 equals binary 11000000 because 128 plus 64 is 192; 10.0.0.5 contains four independent eight-bit values.

Why this matters

Binary representation explains mask operations and address boundaries and removes guesswork when a subnet prefix cuts through the middle of a displayed decimal octet today.

A common trap

Treating 256 as a valid octet exceeds eight-bit capacity; validate every octet rather than assuming any dotted four-number string is a usable IPv4 address.

CIDR prefixes and masks

A CIDR prefix /n identifies the first n address bits as network bits. The remaining 32-n bits describe positions inside the block, so the total address count is 2 raised to that remainder. A /24 mask is 255.255.255.0; a /26 contains 64 total addresses. Usable counts depend on context. 10.0.0.0/26 spans 10.0.0.0 through 10.0.0.63; traditional LAN host rules and AWS subnet reservations do not produce the same usable count. Prefix arithmetic supports capacity planning and makes provider-specific reserved addresses an explicit additional rule rather than an invisible subtraction borrowed from another networking context without checking. Applying the traditional minus-two host formula to AWS subnets is incorrect; AWS reserves five IPv4 addresses in each subnet, and other contexts have exceptions too.

WORKED EXAMPLE
10.0.0.0/26 spans 10.0.0.0 through 10.0.0.63; traditional LAN host rules and AWS subnet reservations do not produce the same usable count.

Why this matters

Prefix arithmetic supports capacity planning and makes provider-specific reserved addresses an explicit additional rule rather than an invisible subtraction borrowed from another networking context without checking.

A common trap

Applying the traditional minus-two host formula to AWS subnets is incorrect; AWS reserves five IPv4 addresses in each subnet, and other contexts have exceptions too.

Network membership and validation

Bitwise masking finds the network address for an interface address. ipaddress.ip_network uses strict validation by default and rejects an address with host bits set. strict=False normalizes such an address to its containing network. Distinguish a host interface specification from a network-block specification when configuring services. ipaddress.ip_network("10.0.0.13/24", strict=False) returns 10.0.0.0/24, while the same input under strict validation raises a host-bits error. Validation catches accidental host addresses used as network declarations and helps prevent inconsistent CIDR descriptions before they enter routing, firewall or cloud network configurations reviewed by others. Silently normalizing every invalid block can hide a planning mistake; inspect the proposed prefix and boundary before choosing strict=False as an intentional conversion for interfaces.

WORKED EXAMPLE
ipaddress.ip_network("10.0.0.13/24", strict=False) returns 10.0.0.0/24, while the same input under strict validation raises a host-bits error.

Why this matters

Validation catches accidental host addresses used as network declarations and helps prevent inconsistent CIDR descriptions before they enter routing, firewall or cloud network configurations reviewed by others.

A common trap

Silently normalizing every invalid block can hide a planning mistake; inspect the proposed prefix and boundary before choosing strict=False as an intentional conversion for interfaces.

KEEP THESE WITH YOU

Today’s takeaways

Calculate blocks from bits.

Distinguish total from usable capacity.

Validate block boundaries.

CLOSE THE LOOP

Ready to complete this day?

Verify the practical steps and pass the knowledge check (at least two thirds correct).

Lab steps verifiedKnowledge check passed