Ultimate IPv4 Cheat Sheet: Subnetting, Addressing, and Configuration Reference

Ultimate IPv4 Cheat Sheet

Subnetting is one of those skills that feels impossible until it suddenly clicks, and then you can’t understand why it ever felt hard. I’ve spent enough years explaining CIDR notation on whiteboards and debugging “why can’t these two devices see each other” tickets that I finally put everything into one reference — the tables I actually use, the commands I actually run, and the mental math shortcuts that make subnetting fast instead of painful.

This is built for quick scanning. Whether you’re studying for a certification, configuring a router at 2am, or just trying to remember what a /27 gives you, everything you need is below.

Table of Contents

  1. IPv4 Address Structure Basics
  2. IPv4 Address Classes (Legacy Reference)
  3. CIDR Notation and Subnet Mask Reference Table
  4. Binary-to-Decimal Conversion Reference
  5. Subnetting Step-by-Step Method
  6. VLSM (Variable Length Subnet Masking) Explained
  7. Private, Public, and Reserved Address Ranges
  8. Special and Reserved IPv4 Addresses
  9. Essential IP Configuration Commands by Platform
  10. Network Troubleshooting Commands
  11. IPv4 Troubleshooting Playbook
  12. Security Best Practices for IPv4 Networks
  13. Real-World Subnetting Workflows
  14. Common Subnetting Mistakes to Avoid
  15. FAQs
  16. Interview Questions and Answers
  17. Printable Quick-Reference Summary
  18. Official Documentation Links

1. IPv4 Address Structure Basics

An IPv4 address is a 32-bit number, written as four 8-bit octets separated by dots — what’s called dotted-decimal notation.

192   .   168   .   1    .   10
11000000.10101000.00000001.00001010

Each octet ranges from 0 to 255 (since 8 bits gives you 2^8 = 256 possible values). The address is split conceptually into a network portion and a host portion, and where that split happens is exactly what subnetting controls.

2. IPv4 Address Classes (Legacy Reference)

Classful addressing is mostly obsolete now that CIDR is standard, but it still shows up in exams, legacy documentation, and default subnet mask assumptions — so it’s worth keeping straight.

ClassLeading BitsFirst Octet RangeDefault MaskDefault CIDRTypical Use
A01 – 126255.0.0.0/8Very large networks
B10128 – 191255.255.0.0/16Medium-large networks
C110192 – 223255.255.255.0/24Small networks
D1110224 – 239N/AN/AMulticast
E1111240 – 255N/AN/AExperimental/reserved

Note that 127.x.x.x is technically inside the Class A range but is reserved entirely for loopback, so it’s excluded from usable Class A assignments.

3. CIDR Notation and Subnet Mask Reference Table

This is the table worth memorizing, or at minimum bookmarking. It covers every practical prefix length.

CIDRSubnet MaskWildcard MaskTotal AddressesUsable Hosts
/24255.255.255.00.0.0.255256254
/25255.255.255.1280.0.0.127128126
/26255.255.255.1920.0.0.636462
/27255.255.255.2240.0.0.313230
/28255.255.255.2400.0.0.151614
/29255.255.255.2480.0.0.786
/30255.255.255.2520.0.0.342
/31255.255.255.2540.0.0.122 (point-to-point, RFC 3021)
/32255.255.255.2550.0.0.011 (host route)
/23255.255.254.00.0.1.255512510
/22255.255.252.00.0.3.25510241022
/21255.255.248.00.0.7.25520482046
/20255.255.240.00.0.15.25540964094
/16255.255.0.00.0.255.2556553665534
/8255.0.0.00.255.255.2551677721616777214

Usable hosts is always total addresses minus 2 (network address and broadcast address reserved) — except at /31 and /32, which have special-case rules for point-to-point links and host routes.

4. Binary-to-Decimal Conversion Reference

Subnetting fundamentally comes down to binary math, so having the octet bit values memorized speeds everything up:

Bit Position12345678
Value1286432168421

Any subnet mask octet is just a sum of these values from left to right, with no gaps:

128            = 10000000  -> /1 in that octet
128+64         = 11000000  -> /2
128+64+32      = 11100000  -> /3
128+64+32+16   = 11110000  -> /4
... and so on up to /8 = 11111111 = 255

That’s why valid subnet mask octets are only ever: 0, 128, 192, 224, 240, 248, 252, 254, 255 — nothing else is possible in a contiguous mask.

5. Subnetting Step-by-Step Method

Here’s the method I actually use when subnetting on the fly, using an example: Subnet 192.168.10.0/24 into blocks of at least 30 usable hosts each.

  1. Find the required host bits. 30 usable hosts needs 2^n – 2 ≥ 30, so n = 5 (2^5 – 2 = 30). That means 5 host bits, leaving 3 bits borrowed from the network portion.
  2. Determine the new prefix. /24 + 3 borrowed bits = /27.
  3. Find the block size (increment). With 5 host bits remaining, block size = 2^5 = 32.
  4. List the subnets by counting up in that increment from the original network address:
SubnetNetwork AddressUsable RangeBroadcast Address
1192.168.10.0.1 – .30192.168.10.31
2192.168.10.32.33 – .62192.168.10.63
3192.168.10.64.65 – .94192.168.10.95
4192.168.10.96.97 – .126192.168.10.127
5192.168.10.128.129 – .158192.168.10.159
6192.168.10.160.161 – .190192.168.10.191
7192.168.10.192.193 – .222192.168.10.223
8192.168.10.224.225 – .254192.168.10.255

That single /24 becomes eight usable /27 subnets, each supporting 30 hosts.

6. VLSM (Variable Length Subnet Masking) Explained

VLSM lets you subnet a network into unequal-sized blocks, matching each subnet to its actual host requirement instead of wasting addresses on a uniform size. This is standard practice in any real-world network design.

Example scenario: You have 192.168.20.0/24 and need to support:

Work from largest requirement to smallest:

SegmentHosts NeededPrefix UsedNetworkUsable RangeBroadcast
Sales60/26 (62 usable)192.168.20.0/26.1 – .62192.168.20.63
Engineering28/27 (30 usable)192.168.20.64/27.65 – .94192.168.20.95
Router link2/30 (2 usable)192.168.20.96/30.97 – .98192.168.20.99

This is the efficient, professional way to allocate address space — always sort requirements largest to smallest before assigning, so you don’t fragment your available block prematurely.

7. Private, Public, and Reserved Address Ranges

RangeCIDRTypeNotes
10.0.0.0 – 10.255.255.25510.0.0.0/8PrivateCommon in large enterprise networks
172.16.0.0 – 172.31.255.255172.16.0.0/12PrivateCommon in mid-size networks, Docker defaults
192.168.0.0 – 192.168.255.255192.168.0.0/16PrivateMost common in home/small office routers
100.64.0.0 – 100.127.255.255100.64.0.0/10Shared/CGNATUsed by ISPs for carrier-grade NAT
All other unicast ranges—PublicGlobally routable on the internet

These private ranges are defined in RFC 1918 and are never routed on the public internet — devices using them reach the internet through NAT.

8. Special and Reserved IPv4 Addresses

Address / RangePurpose
127.0.0.0/8Loopback (localhost)
169.254.0.0/16APIPA — auto-assigned when DHCP fails
0.0.0.0“This network” / default route in routing tables
255.255.255.255Limited broadcast
224.0.0.0/4Multicast range
192.0.2.0/24, 198.51.100.0/24, 203.0.113.0/24TEST-NET ranges reserved for documentation/examples
198.18.0.0/15Reserved for network benchmarking

I use the TEST-NET ranges constantly when writing documentation or examples specifically so I don’t accidentally reference a real, live IP address.

9. Essential IP Configuration Commands by Platform

TaskWindowsLinuxmacOS
Show IP configurationipconfig /allip addr show or ifconfigifconfig or ipconfig getifaddr en0
Release DHCP leaseipconfig /releasesudo dhclient -rsudo ipconfig set en0 DHCP
Renew DHCP leaseipconfig /renewsudo dhclientsudo ipconfig set en0 DHCP
Set static IPvia Network Settings / netshsudo ip addr add 192.168.1.50/24 dev eth0via System Settings / networksetup
Show routing tableroute printip route or route -nnetstat -rn
Add a static routeroute addsudo ip route addsudo route add
Flush DNS cacheipconfig /flushdnssudo systemd-resolve --flush-cachessudo dscacheutil -flushcache
Show ARP tablearp -aip neigh or arp -aarp -a

10. Network Troubleshooting Commands

TaskCommandWhat It Tells You
Test reachabilityping <ip>Basic connectivity and latency
Trace the pathtracert <ip> (Windows) / traceroute <ip> (Linux/macOS)Every hop between you and the destination
Check open connectionsnetstat -anActive connections and listening ports
Modern netstat replacementss -tulnp (Linux)Faster, more detailed socket info
Check a specific porttelnet <ip> <port> or nc -zv <ip> <port>Whether a port is open/reachable
Continuous ping statsping -t (Windows) / ping (Linux, runs continuously by default)Ongoing packet loss/latency monitoring
Path MTU discoveryping -f -l <size> (Windows) / ping -M do -s <size> (Linux)Finding the maximum packet size that isn’t fragmented

11. IPv4 Troubleshooting Playbook

When a device can’t reach something, I work outward in layers rather than guessing:

  1. Check local IP configuration. Confirm the device actually has a valid IP, correct subnet mask, and default gateway — not a 169.254.x.x APIPA address, which signals a failed DHCP request. ipconfig /all (or) ip addr show
  2. Ping the default gateway. If this fails, the problem is local — cabling, switch port, Wi-Fi association, or VLAN misconfiguration.
  3. Ping a known external IP (like 1.1.1.1). If the gateway works but this doesn’t, it’s a routing or ISP-side issue.
  4. Ping a domain name. If the IP ping works but the domain doesn’t, that isolates the issue to DNS rather than connectivity.
  5. Check the subnet math. A device with an IP correctly assigned but the wrong subnet mask will “see” other devices as being on a different network than they actually are, causing intermittent or one-directional connectivity issues.
  6. Trace the route to see exactly where packets stop or start showing high latency.
  7. Check for IP conflicts. Two devices with the same static IP on one network cause sporadic, hard-to-reproduce connectivity issues — the ARP table (arp -a) can reveal duplicate entries.
  8. Verify firewall/ACL rules aren’t silently dropping traffic on a specific port, especially after a recent change.

12. Security Best Practices for IPv4 Networks

13. Real-World Subnetting Workflows

Designing subnets for a small office (3 departments, 1 router link): Start with the total address block you’ve been given (say, a /24), sort departments by host count, and assign VLSM subnets from largest to smallest — exactly as shown in Section 6. This avoids the common beginner mistake of dividing everything into equal-sized chunks regardless of actual need.

Migrating a network from a flat /24 to segmented VLANs:

  1. Inventory current device count per functional group (workstations, servers, printers, guest Wi-Fi, VoIP).
  2. Calculate required host bits per group with headroom for growth — I typically double the current count before calculating.
  3. Assign VLSM subnets and matching VLAN IDs.
  4. Update DHCP scopes and gateway addresses per VLAN.
  5. Update firewall rules to reflect new subnet boundaries before decommissioning the old flat network.

Troubleshooting “can’t reach a device on the same subnet”: Check the subnet mask on both devices first — a mismatched mask is the single most common cause of this exact symptom, since one device may calculate a different network boundary than the other even with IPs that look like they’re close together.

14. Common Subnetting Mistakes to Avoid

15. FAQs

Q: What’s the difference between a subnet mask and a wildcard mask? A subnet mask defines the network/host boundary and its octets increase from the left (255.255.255.0). A wildcard mask, used in ACLs and OSPF, is essentially its inverse (0.0.0.255) and defines which bits are allowed to vary.

Q: Why do we lose 2 addresses per subnet? The first address in any subnet is reserved as the network address (identifies the subnet itself), and the last is reserved as the broadcast address (used to reach every host on that subnet at once). Neither can be assigned to a device.

Q: What is CIDR and why did it replace classful addressing? CIDR (Classless Inter-Domain Routing) allows arbitrary prefix lengths instead of rigid class-based boundaries, which drastically reduced address waste and slowed the exhaustion of the IPv4 address space.

Q: Can two devices on different subnets communicate directly? No — they need a router (or a Layer 3 switch) to route traffic between subnets. Devices only communicate directly at Layer 2 when they’re on the same subnet.

Q: What’s a /31 actually used for if it only has 2 addresses? RFC 3021 specifically allows /31 for point-to-point links (like router-to-router WAN links), where you don’t need a separate network and broadcast address since there are only ever two devices involved.

Q: How do I quickly tell if two IPs are on the same subnet? Convert both to binary along with the subnet mask, and compare the network portion (the bits covered by the mask). If those bits match, they’re on the same subnet regardless of how different the host portion looks.

Q: Is IPv4 address exhaustion still a real problem? Yes — the global pool of available public IPv4 addresses has effectively been fully allocated for years, which is exactly why CGNAT, IPv6 adoption, and efficient VLSM subnetting all matter as much as they do today.

16. Interview Questions and Answers

Q: How many usable hosts are in a /27 subnet, and how do you calculate it? A: 30 usable hosts. A /27 leaves 5 host bits (32 – 27 = 5), so 2^5 = 32 total addresses, minus 2 for network and broadcast = 30 usable.

Q: What’s the difference between a public and private IP address? A: Public IPs are globally unique and routable across the internet. Private IPs (from ranges like 10.0.0.0/8 or 192.168.0.0/16) are only valid within a local network and require NAT to reach the internet.

Q: Explain VLSM and why it’s preferred over fixed-length subnetting. A: VLSM allows different subnet sizes within the same address block, matched to actual host requirements, which avoids the address waste that comes from forcing every subnet to the same size regardless of need.

Q: What happens if two devices have mismatched subnet masks? A: They may calculate different network boundaries for the same IP range, leading to devices believing they’re on different networks even when they’re physically on the same segment — causing intermittent or one-way connectivity issues.

Q: What’s the purpose of the default gateway? A: It’s the router address a device sends traffic to when the destination isn’t on its own local subnet — effectively the exit point to reach other networks, including the internet.

Q: What is APIPA and when does it appear? A: Automatic Private IP Addressing — a 169.254.x.x address a Windows device self-assigns when it can’t reach a DHCP server, letting local link communication continue but signaling no valid network configuration was obtained.

Q: How would you subnet a /24 to support 6 subnets with at least 25 hosts each? A: 25 hosts needs 5 host bits (2^5 – 2 = 30 usable), giving a /27, which yields 8 possible subnets from a /24 — comfortably covering the requirement for 6.

17. Printable Quick-Reference Summary

CIDR QUICK TABLE
/24 = 255.255.255.0     = 254 hosts
/25 = 255.255.255.128   = 126 hosts
/26 = 255.255.255.192   = 62 hosts
/27 = 255.255.255.224   = 30 hosts
/28 = 255.255.255.240   = 14 hosts
/29 = 255.255.255.248   = 6 hosts
/30 = 255.255.255.252   = 2 hosts
/31 = 255.255.255.254   = 2 hosts (point-to-point)
/32 = 255.255.255.255   = 1 host

PRIVATE RANGES (RFC 1918)
10.0.0.0/8
172.16.0.0/12
192.168.0.0/16

SPECIAL ADDRESSES
127.0.0.0/8      loopback
169.254.0.0/16   APIPA
0.0.0.0          default route
255.255.255.255  limited broadcast

CORE COMMANDS
ipconfig /all              Windows IP config
ip addr show               Linux IP config
ifconfig                   macOS/legacy IP config
ping <ip>                  connectivity test
tracert / traceroute <ip>  path trace
arp -a                     ARP table
netstat -an / ss -tulnp    connection state

SUBNETTING METHOD
1. Determine host bits needed (2^n - 2 >= required hosts)
2. New prefix = 32 - host bits
3. Block size = 2^(host bits)
4. Count subnets in that increment from the base network

18. Official Documentation Links


Subnetting stops being intimidating the moment the binary math becomes muscle memory instead of a lookup exercise. Work through the step-by-step method a few times with real numbers, keep the CIDR table nearby until you don’t need it anymore, and the rest falls into place. Save this page — between the tables and the troubleshooting playbook, it covers the situations that come up again and again.

Exit mobile version