Master IP Subnetting: From Binary Conversion to CIDR Calculations
This guide explains core concepts of IP subnetting, including binary‑decimal conversion, network and host counts for A/B/C classes, default masks, valid mask rules, CIDR notation, and a step‑by‑step example solving a /18 subnet problem.
Fundamental Concepts
Subnet : Division of a larger network into equal‑size smaller networks.
Binary‑to‑decimal conversion for IP calculations : Count the number of "1" bits and use 2^n for each position rather than summing low‑order powers.
Number of networks : A‑class 2^7 − 2 usable, B‑class 2^14 − 2 usable, C‑class 2^21 − 2 usable.
Total IPs per class : A = 2^24, B = 2^16, C = 2^8; usable = total − 2.
Mask purpose : Indicates how many subnets a large network is split into; the mask’s 1‑bits define the network portion.
Decimal‑to‑8‑bit binary table (0‑255): 128 = 10000000, 64 = 01000000, …, 1 = 00000001.
Default Masks
A‑class: 255.0.0.0 (11111111.00000000.00000000.00000000)
B‑class: 255.255.0.0 (11111111.11111111.00000000.00000000)
C‑class: 255.255.255.0 (11111111.11111111.11111111.00000000)
Valid Mask Rules
A mask is valid if, after conversion to binary, all leading bits are 1 and no 0 appears between 1s. Example: 255.255.248.0 → 11111111.11111111.11111000.00000000 (valid); 254.255.248.0 → 11111110… (invalid).
CIDR Notation
Mask 255.255.248.0 equals /21 because it contains 21 leading 1s. Conversely, /21 expands to the dotted‑decimal mask.
Unusable Addresses
Each network (including subnets) has two unusable addresses: the network address and the broadcast address.
Determining Subnet Count from a Mask
Identify the default‑mask class the given mask falls under, then count the extra leading 1s beyond the default. Example: 202.117.12.36/30 → mask 255.255.255.252 (binary 11111111.11111111.11111111.11111100) is within the C‑class range, giving 6 extra 1s → 2⁶ = 64 subnets, each with 4 IPs (2 usable).
Comprehensive Example
Given IP 172.31.128.255/18:
Subnet count: /18 adds two 1s to the B‑class default (/16), so 2² = 4 subnets.
Network address: IP AND mask → 172.31.128.0.
Host portion: IP AND inverse mask → 0.0.0.255 (host number 255).
Broadcast address: set host bits to 1 → 172.31.191.255.
Usable IP range: 172.31.128.1 – 172.31.191.254.
These steps illustrate binary‑decimal conversion, mask application, and derivation of network details for any subnetting problem.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Liangxu Linux
Liangxu, a self‑taught IT professional now working as a Linux development engineer at a Fortune 500 multinational, shares extensive Linux knowledge—fundamentals, applications, tools, plus Git, databases, Raspberry Pi, etc. (Reply “Linux” to receive essential resources.)
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
