C.W.K.
Stream
Lesson 02 of 12 · published

Subnets & CIDR

~15 min · subnet, cidr, subnet-mask, routing

Level 0Pinger
0 XP0/101 lessons0/12 achievements
0/150 XP to next level150 XP to go0% complete

Splitting a network into rooms

A subnet is a logical division of an IP network. Subnetting lets you break a large address space into smaller, manageable groups for organization, security, and routing. Every IP has two parts: the network portion (which subnet it belongs to) and the host portion (which device within that subnet). The subnet mask draws the line between the two halves.

Subnet masks, decoded

A subnet mask looks like an IP address: 255.255.255.0. The 255 octets mark the network portion; the 0 octets mark the host portion. With 255.255.255.0:

  • Network: first 3 octets (e.g. 192.168.1)
  • Host: last octet (.0–.255)
  • Total addresses: 256 — but two are reserved: .0 = network address, .255 = broadcast.
  • Usable hosts: 254

CIDR — the compact form

CIDR (Classless Inter-Domain Routing) replaces the dotted mask with a single number after a slash: the number of network bits. 255.255.255.0 becomes /24 — 24 network bits, 8 host bits.

CIDRMaskTotalUsable hosts
/32255.255.255.25511 (a single address)
/30255.255.255.25242 (point-to-point)
/24255.255.255.0256254
/16255.255.0.065,53665,534
/8255.0.0.016,777,21616,777,214

192.168.1.0/24 means "every address from 192.168.1.0 through 192.168.1.255." Your home router almost certainly hands out a /24. If you ever build VLANs, mesh VPNs, or a homelab, you'll juggle multiple subnets to keep traffic separated — server LAN at 10.0.1.0/24, IoT at 10.0.2.0/24, guests at 10.0.3.0/24, and so on.

Code

Inspect your subnet·bash
# Linux: full interface table
ip addr show

# macOS: en0 details, look for 'inet' and 'netmask'
ifconfig en0

# Routing table — your default route shows the gateway and subnet
netstat -rn | head -20

External links

Exercise

Run ifconfig en0 (macOS) or ip addr show (Linux) and find the netmask. Translate it to CIDR notation (e.g. 0xffffff00 = 255.255.255.0 = /24). Then calculate: how many usable host addresses does your LAN have? If your IP is 192.168.1.42, what's the network address (first IP) and broadcast (last IP)?

Progress

Progress is local-only — sign in to sync across devices.
Spotted a bug or have feedback on this page?Report an Issue

Comments 0

🔔 Reply notifications (sign in)
Sign inPlease sign in to comment.

No comments yet — be the first.