Subnetting: CIDR ↔ Mask ↔ Usable Hosts ↔ Block Size (+ quick tips)

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Steve
    Administrator
    • Sep 2025
    • 7

    #1

    Guide Subnetting: CIDR ↔ Mask ↔ Usable Hosts ↔ Block Size (+ quick tips)

    Subnetting Cheat Sheet (IPv4)
    Quick reference for CIDR, subnet masks, usable hosts, wildcard masks, and the “magic number” block size.

    Fast rules to remember
    • Usable hosts = 2^(32 − prefix) − 2 (except /31 and /32 special cases)
    • Block size (magic number) = 256 − (mask value in the first non-255 octet)
    • Wildcard mask = 255.255.255.255 − (subnet mask) (handy for ACLs)
    • /31 is point-to-point (both addresses usable per RFC 3021). /32 = single host.


    Common small LAN subnets (last octet changes)
    Code:
    CIDR   Mask               Usable  Block  Wildcard
    /30    255.255.255.252    2       4      0.0.0.3
    /29    255.255.255.248    6       8      0.0.0.7
    /28    255.255.255.240    14      16     0.0.0.15
    /27    255.255.255.224    30      32     0.0.0.31
    /26    255.255.255.192    62      64     0.0.0.63
    /25    255.255.255.128    126     128    0.0.0.127
    /24    255.255.255.0      254     256    0.0.0.255
    Aggregating / larger subnets (3rd octet changes)
    Code:
    CIDR   Mask               Usable   Block (3rd octet)   Wildcard
    /23    255.255.254.0      510      2                   0.0.1.255
    /22    255.255.252.0      1022     4                   0.0.3.255
    /21    255.255.248.0      2046     8                   0.0.7.255
    /20    255.255.240.0      4094     16                  0.0.15.255
    /19    255.255.224.0      8190     32                  0.0.31.255
    /18    255.255.192.0      16382    64                  0.0.63.255
    /17    255.255.128.0      32766    128                 0.0.127.255
    /16    255.255.0.0        65534    256 (2nd octet)     0.0.255.255
    Binary weights (quick mental math)
    Code:
    128  64  32  16   8   4   2   1   ← bit values in an octet
    Examples:
    • Mask octet 224 → bits 128+64+32 → /27 → block size 32
    • Mask octet 252 → bits 128+64+32+16+8+4 → /30 → block size 4


    How to use the “magic number”
    Find the first mask octet that isn’t 255. Subnets start at multiples of 256 − mask_octet in that octet.
    Example: 192.168.10.0/26 → mask octet = 192 → block size = 64 → networks at .0, .64, .128, .192
    Example: 10.20.0.0/20 → mask = 255.255.240.0 → block size = 16 in the 3rd octet → networks at 10.20.0,16,32,48.0/20

    /31 and /32 special cases
    Code:
    /31  255.255.255.254  → 2 addresses, both usable (point-to-point links)
    /32  255.255.255.255  → single host route (no network/broadcast)
    Mini-exercises
    • How many usable hosts in /27? What’s the block size? (Answer: 30, block 32)
    • What networks does 172.16.40.0/21 cover? (Hint: block 8 in 3rd octet → 172.16.40–47.0/21)
    • You need ~60 hosts. Which prefix fits best? (Answer: /26)


    Tip: Save this post or print it. If you want a printable 1-page PDF version, reply here and we’ll attach one.
Working...