Skip to main content
TACUNS
Module 2 of 5
40% complete
Module 2

Subnetting & CIDR

IPv4 Address Structure

An IPv4 address is a 32-bit number typically written as four decimal octets separated by dots — for example, 192.168.10.25. Each octet represents 8 bits, giving values from 0 to 255. The full 32-bit space theoretically supports about 4.3 billion unique addresses, but that pool was effectively exhausted years ago — which is exactly why subnetting and private addressing exist.

Address Classes (Classful Networking)

Before CIDR, IP addresses were divided into fixed classes based on the leading bits of the first octet. Understanding classes helps you recognize IP ranges at a glance.

ClassFirst Octet RangeDefault MaskUsage
A1 – 126255.0.0.0 (/8)Large enterprises, ISPs
B128 – 191255.255.0.0 (/16)Medium organizations
C192 – 223255.255.255.0 (/24)Small networks
D224 – 239N/AMulticast groups
E240 – 255N/AReserved / experimental

Loopback Range

The 127.0.0.0/8 range is reserved for loopback. The address 127.0.0.1 always refers to the local machine. Traffic sent to this address never leaves the host.

Private Address Ranges (RFC 1918)

  • 10.0.0.0 – 10.255.255.255 (10.0.0.0/8) — large private networks
  • 172.16.0.0 – 172.31.255.255 (172.16.0.0/12) — medium private networks
  • 192.168.0.0 – 192.168.255.255 (192.168.0.0/16) — home/small office networks

Private addresses are not routable on the public internet. Routers at your ISP drop packets sourced from these ranges, which is why NAT (Network Address Translation) is required for private hosts to access the internet.

What Is Subnetting and Why Does It Matter?

Subnetting is the practice of dividing a large IP network into smaller, more manageable sub-networks called subnets. Instead of giving an entire Class B network to a single organization, you carve it into dozens of smaller pieces aligned to actual team sizes.

The three core reasons for subnetting are:

Conserve IP address space: Allocate only as many addresses as a segment needs, rather than wasting a full class block.

Reduce broadcast domains: Broadcasts are confined to their subnet. Smaller domains mean less noise and better performance on large networks.

Improve security: Subnets create natural boundaries. Firewalls and ACLs can enforce policy between subnets — servers on one subnet can be isolated from workstations on another.

CIDR Notation

Classless Inter-Domain Routing (CIDR) replaced the rigid class system. In CIDR, a prefix length (written after a slash) tells you how many bits belong to the network portion. The remaining bits identify hosts.

Reading CIDR

192.168.1.0/24 means the first 24 bits are the network address and the last 8 bits identify individual hosts. A /24 gives 256 addresses (254 usable — subtract network address and broadcast).

Subnet Mask Binary Math

A subnet mask is a 32-bit number where every network bit is 1 and every host bit is 0. To find the network address, apply a bitwise AND between the IP and the subnet mask.

binary
IP address:    192.168.10.200
               11000000.10101000.00001010.11001000

Subnet mask /26: 255.255.255.192
               11111111.11111111.11111111.11000000

Network addr:  192.168.10.192
               11000000.10101000.00001010.11000000

Broadcast:     192.168.10.255
               11000000.10101000.00001010.11111111

Usable hosts:  192.168.10.193 – 192.168.10.254 (62 hosts)

Calculating Key Values

Given a prefix length n, the host portion has (32 – n) bits. Useful formulas:

  • Total addresses = 2^(32 - n)
  • Usable hosts = 2^(32 - n) - 2 (subtract network address and broadcast)
  • Number of subnets from a block = 2^(bits borrowed)

Common Subnet Reference

CIDRSubnet MaskTotal AddressesUsable HostsCommon Use
/8255.0.0.016,777,21616,777,214Large ISP / Class A
/16255.255.0.065,53665,534Campus / data center
/24255.255.255.0256254Standard LAN segment
/25255.255.255.128128126Split /24 into two halves
/26255.255.255.1926462Small department
/27255.255.255.2243230Small team or VLAN
/28255.255.255.2401614Small server cluster
/30255.255.255.25242Point-to-point WAN links
/32255.255.255.25510Host route / loopback

Point-to-Point Links

/30 subnets are the classic choice for WAN links between two routers — only two usable addresses are needed. Modern networks often use /31 (RFC 3021) to save one more address, giving exactly 2 addresses with no network or broadcast waste.

VLSM — Variable Length Subnet Masking

VLSM lets you use different prefix lengths within the same network block. Instead of carving every subnet to the same size, you right-size each one.

VLSM Example

You are given 192.168.1.0/24 and need to allocate subnets for:

  • Engineering: 60 hosts → needs /26 (62 usable) → 192.168.1.0/26
  • Sales: 28 hosts → needs /27 (30 usable) → 192.168.1.64/27
  • Finance: 12 hosts → needs /28 (14 usable) → 192.168.1.96/28
  • Management: 5 hosts → needs /29 (6 usable) → 192.168.1.112/29
  • WAN link Router1–Router2: 2 hosts → needs /30 → 192.168.1.120/30

VLSM is the foundation of efficient IP design. Without it, every subnet wastes unused addresses even when the next subnet is just one address away.

Introduction to IPv6

IPv6 uses 128-bit addresses, written as eight groups of four hexadecimal digits separated by colons — for example, 2001:0db8:85a3:0000:0000:8a2e:0370:7334. The 128-bit space provides approximately 3.4 × 10^38 unique addresses — effectively unlimited for any foreseeable future.

IPv6 Simplification Rules

  • Leading zeros within each group can be omitted: 0db8 → db8
  • One consecutive run of all-zero groups can be replaced with :: (used only once per address)
  • Loopback: ::1 (equivalent to 127.0.0.1 in IPv4)
  • Unspecified: :: (all zeros, equivalent to 0.0.0.0)

IPv6 Address Types

TypePrefixDescription
Global Unicast2000::/3Publicly routable, similar to IPv4 public addresses
Link-Localfe80::/10Automatically assigned, valid only on local link
Unique Localfc00::/7Private IPv6 addresses (similar to RFC 1918)
Multicastff00::/8One-to-many delivery
Loopback::1/128Local loopback address

IPv6 Subnetting

ISPs typically assign a /48 prefix to organizations. Within that /48, you have 16 bits for subnets — giving 65,536 possible /64 subnets. Each /64 subnet supports 2^64 host addresses. The /64 boundary is standard because SLAAC (Stateless Address Autoconfiguration) requires it.