ArcLibrary

Subnet & CIDR

Slicing an IP range into subnets — decides who talks directly and who must go through a router.

SubnetCIDRMask
核心 · Key Idea

In one line: A subnet mask tells a host "these high bits are the network part, the rest are the host part". CIDR writes /N for the first N network bits — forget A/B/C classes in modern networking.

What it is#

In 192.168.1.10/24:

  • The leading 24 bits (192.168.1) are the network part — shared by all hosts on that subnet;
  • The last 8 bits (.10) are the host part — distinguishes hosts on that subnet.
192.168.1.10/24 in binary:
  11000000.10101000.00000001 . 00001010
  └────── network (24 bits) ──┘ └ host (8) ┘

The whole subnet 192.168.1.0/24 has 256 addresses; first and last are reserved (.0 = network address, .255 = broadcast). 254 usable.

Analogy#

打个比方 · Analogy

A postal code like 100000 for Beijing — leading digits identify the region, trailing digits the building. The subnet mask is the ruler that tells you how many leading digits represent the region.

Key concepts#

Subnet maskSubnet mask
Same length as the IP (32 bits); 1s = network bits, 0s = host bits. /24 = 255.255.255.0.
CIDR notationClassless Inter-Domain Routing
Write IP/prefix-length, e.g. 10.0.0.0/8, 172.16.0.0/12.
Network addressNetwork address
All host bits zero; identifies the subnet, not assigned to a host.
Broadcast addressBroadcast address
All host bits one; reaches everyone on the subnet.
Usable hostsUsable hosts
2^host_bits - 2 (subtract network + broadcast).

How it works#

A host applies its subnet mask to decide whether the destination is in the same subnet: yes → ARP directly; no → send to the default gateway.

Practical notes#

  • CIDR cheatsheet:
CIDRMaskUsable hosts
/24255.255.255.0254
/25255.255.255.128126
/26255.255.255.19262
/28255.255.255.24014
/30255.255.255.2522 (point-to-point)
  • /32 = a single host — common in routing-table specifics.
  • /0 = "all IPs"; the default route 0.0.0.0/0.
  • Don't compute by hand: use ipcalc 192.168.1.0/26 to print network / broadcast / range.
  • Smaller subnets save addresses but bloat routing tables. In practice, slicing by /24 per business unit balances manageability over conservation.

Easy confusions#

A / B / C classes
Early fixed split: A=/8, B=/16, C=/24.
Too coarse and wasteful — **deprecated**.
CIDR
Arbitrary prefix length /N.
The modern internet's scheme.

Further reading#