Calculate IPv4 networks quickly, design subnets with VLSM, and configure and verify host and router addressing.
Learning objectives
- Learn IP addressing (Private and Public IPs).
- Convert prefix lengths and subnet masks.
- Calculate network, broadcast, usable range, and host capacity.
- Create a VLSM plan from largest requirement to smallest.
- Recognize private, public, loopback, link-local, and multicast IPv4 ranges.
An IPv4 (Internet Protocol version 4) address is a unique 32-bit numerical label assigned to a device on a network, used to identify that device and allow it to send/receive data. It's written in dotted-decimal notation — four decimal numbers (0–255) separated by dots, where each number represents 8 bits (one octet).
Example:
192.168.1.10
In binary (32 bits total):
11000000.10101000.00000001.00001010
Every IPv4 address has two logical parts:
- Network ID – identifies which network the device belongs to.
- Host ID – identifies the specific device within that network.
Where the network portion ends and the host portion begins is determined by the subnet mask (covered in detail below).
Types of IPv4 Addresses (by Communication Type)
- Unicast – A single address identifying one specific device. Most traffic (web browsing, file transfer) is unicast — one sender, one receiver.
- Broadcast – An address that sends data to all devices on a local network segment simultaneously (e.g., 255.255.255.255 or the subnet's broadcast address like 192.168.1.255). Used for things like ARP requests.
- Multicast – An address that sends data to a specific group of interested devices (not all, not just one). Uses the reserved range 224.0.0.0 – 239.255.255.255. Used for things like video streaming to multiple subscribers or routing protocol updates (e.g., OSPF uses 224.0.0.5).
IPv4 Address Classes (Classful Addressing — Historical but Exam-Relevant)
Originally, IPv4 addresses were divided into classes, determined by the value of the first octet. This system is largely obsolete today (replaced by classless CIDR), but it's still foundational knowledge for the exam and for understanding default subnet masks.
Class | First Octet Range | Default Subnet Mask | Default CIDR | Purpose |
|---|---|---|---|---|
| A | 1 – 126 | 255.0.0.0 | /8 | Huge networks (few networks, tons of hosts) |
| B | 128 – 191 | 255.255.0.0 | /16 | Medium networks |
| C | 192 – 223 | 255.255.255.0 | /24 | Small networks (many networks, few hosts) |
| D | 224 – 239 | N/A | N/A | Multicast (not for host assignment) |
| E | 240 – 255 | N/A | N/A | Reserved/experimental (research use) |
Notes:
- 127.x.x.x is reserved for loopback testing (e.g., 127.0.0.1 = localhost) — it's technically inside the old Class A range but excluded from normal use.
- How to identify class quickly: Look at the first octet and match it to the table above. E.g., 10.x.x.x → Class A; 172.20.x.x → Class B; 192.168.x.x → Class C.
- Class A supports the most hosts per network (~16 million), Class C the fewest (254), reflecting the different scale of organizations each was designed for.
Why classful addressing became obsolete: It was wasteful — e.g., a company needing 300 hosts would be forced to take an entire Class B network (65,534 hosts), wasting the rest. This led to CIDR (Classless Inter-Domain Routing), which allows subnet masks of any length, not just the fixed class boundaries. This is why subnetting became essential.
2 Subnet Masks and CIDR Notation
What a Subnet Mask Does
A subnet mask is a 32-bit number (same format as an IP address) that marks which bits of the IP address are the network portion (represented by 1s) and which are the host portion (represented by 0s).
Example: 255.255.255.0 in binary:
11111111.11111111.11111111.00000000
The first 24 bits are 1s → network portion. The last 8 bits are 0s → host portion. This is why it's also written as /24.
CIDR (Slash) Notation
CIDR notation is shorthand for the subnet mask — the number after the slash tells you how many bits (from the left) are network bits.
| CIDR | Subnet Mask | Binary (last relevant octet) | Hosts per subnet (2ⁿ−2) |
|---|---|---|---|
| /24 | 255.255.255.0 | 00000000 | 254 |
| /25 | 255.255.255.128 | 10000000 | 126 |
| /26 | 255.255.255.192 | 11000000 | 62 |
| /27 | 255.255.255.224 | 11100000 | 30 |
| /28 | 255.255.255.240 | 11110000 | 14 |
| /29 | 255.255.255.248 | 11111000 | 6 |
| /30 | 255.255.255.252 | 11111100 | 2 |
How Subnetting Works — Step by Step
Subnetting means borrowing bits from the host portion to create smaller, additional networks (subnets) out of one larger network.
The Core Formulas
- Number of subnets created = 2^(number of borrowed bits)
- Number of
usable hosts per subnet = 2^(remaining host bits) − 2
(minus 2 because every subnet reserves one address for the Network ID and one for the Broadcast address — neither can be assigned to a device)
Powers of 2 (memorize this — it's the backbone of every subnetting calculation)
|
n |
2ⁿ |
n |
2ⁿ |
|
1 |
2 |
5 |
32 |
|
2 |
4 |
6 |
64 |
|
3 |
8 |
7 |
128 |
|
4 |
16 |
8 |
256 |
Example 1: Subnetting a /24 Network by Host Requirement
Problem: You're given 192.168.1.0/24. You need subnets that support at least 30 hosts each. Find the new subnet mask, number of subnets, and list them.
Step 1 — Figure out host bits needed:
Try values until 2ⁿ − 2 ≥ 30:
- 2⁴ − 2 = 14 → not enough
- 2⁵ − 2 = 30 → ✅ works exactly
So, you need 5 host bits.
Step 2 — Calculate borrowed bits:
A /24 has 8 host bits available (32 − 24 = 8).
Borrowed bits = 8 total host bits − 5 needed host bits = 3 bits borrowed.
Step 3 — New prefix:
/24 + 3 = /27
/27 in decimal = 255.255.255.224
Step 4 — Number of subnets created:
2³ (borrowed bits) = 8 subnets
Step 5 — Block size (increment between subnets):
256 − 224 (mask value in the 4th octet) = 32
Step 6 — List the subnets (each subnet starts 32 apart):
|
Subnet |
Network ID |
First Usable Host |
Last Usable Host |
Broadcast |
|
1 |
192.168.1.0/27 |
.1 |
.30 |
.31 |
|
2 |
192.168.1.32/27 |
.33 |
.62 |
.63 |
|
3 |
192.168.1.64/27 |
.65 |
.94 |
.95 |
|
4 |
192.168.1.96/27 |
.97 |
.126 |
.127 |
|
5 |
192.168.1.128/27 |
.129 |
.158 |
.159 |
|
6 |
192.168.1.160/27 |
.161 |
.190 |
.191 |
|
7 |
192.168.1.192/27 |
.193 |
.222 |
.223 |
|
8 |
192.168.1.224/27 |
.225 |
.254 |
.255 |
Example 2: Subnetting by Required Number of Subnets
Problem: You have 172.16.0.0/16 and need at least 10 subnets. Find the new mask and the resulting subnets.
Step 1 — Figure out bits to borrow:
Try 2ⁿ ≥ 10:
- 2³ = 8 → not enough
- 2⁴ = 16 → ✅ works (gives 16 subnets, satisfies "at least 10")
So, you borrow 4 bits.
Step 2 — New prefix:
/16 + 4 = /20
/20 in decimal = 255.255.240.0
Step 3 — Block size:
This time the borrowed bits fall in the 3rd octet (since /16 to /20 crosses into the third octet).
256 − 240 = 16 → block size is 16 in the third octet.
Step 4 — List first few subnets:
Subnet | Network ID | Broadcast |
|---|---|---|
| 1 | 172.16.0.0/20 | 172.16.15.255 |
| 2 | 172.16.16.0/20 | 172.16.31.255 |
| 3 | 172.16.32.0/20 | 172.16.47.255 |
| 4 | 172.16.48.0/20 | 172.16.63.255 |
| .......... | (continues by 16s) | ........ |
Hosts per subnet: Remaining host bits = 32 − 20 = 12 bits → 2¹² − 2 = 4,094 usable hosts per subnet.
The "Magic Number" Quick Method (works for any problem)
- Identify the interesting octet — the octet where the subnet mask value is not 0 or 255.
- Magic number = 256 − (mask value in that octet). This is your block size/increment.
- Starting from 0, keep adding the magic number to list every subnet's network address.
- Broadcast address of each subnet = the next subnet's network address minus 1.
- Usable host range = network address +1 to broadcast address −1.
Example: Mask = 255.255.255.192 (/26) → interesting octet = 4th → magic number = 256 − 192 = 64
Subnets: .0, .64, .128, .192 (4 subnets, each with 62 usable hosts: 2⁶−2=62)
3. VLSM (Variable Length Subnet Masking)
VLSM — Variable Length Subnet Masking is a subnetting technique that allows an organization to use different subnet masks within the same major network.
Instead of assigning the same subnet size everywhere, VLSM allows each subnet to be sized according to the actual number of hosts required.
This makes IP address allocation much more efficient.
Example scenario:
- Sales department needs 50 hosts → use a /26 (62 usable hosts)
- IT department needs 20 hosts → use a /27 (30 usable hosts)
- A point-to-point WAN link between two routers needs only 2 hosts → use a /30 (2 usable hosts)
Process: Start by allocating the largest subnet first (to avoid overlap/fragmentation issues), then work down to smaller ones — carving out addresses from the remaining unused space each time.
Configuring IPv4 Addressing (Cisco IOS)
On a router interface: Router> enable Router# configure terminal Router(config)# interface gigabitethernet0/0 Router(config-if)# ip address 192.168.1.1 255.255.255.0 Router(config-if)# no shutdown Router(config-if)# exit
On a switch (management/SVI interface, e.g., VLAN 1): Switch(config)# interface vlan 1 Switch(config-if)# ip address 192.168.1.2 255.255.255.0 Switch(config-if)# no shutdown Assigning a default gateway (needed for hosts/switches to reach other networks): Switch(config)# ip default-gateway 192.168.1.1
Verifying IPv4 Addressing
|
Command |
Purpose |
|
show ip interface brief |
Quick summary of all interfaces — IP address + up/down status |
|
show interfaces [interface] |
Detailed info: IP, MAC, duplex, speed, errors |
|
show running-config interface [interface] |
Confirms the exact configured IP/mask on that interface |
|
ping [ip-address] |
Tests basic Layer 3 connectivity |
|
traceroute [ip-address] |
Shows the hop-by-hop path to a destination |
|
show ip route |
Displays the routing table, confirming the device knows how to reach various subnets |
Example show ip interface brief output:
Switch# show ip interface brief Interface IP-Address OK? Method Status Protocol GigabitEthernet0/0 192.168.1.1 YES manual up up GigabitEthernet0/1 unassigned YES unset administratively down down
This single command is often the first troubleshooting step — it immediately shows which interfaces have IPs configured and whether they're physically/logically up.
4. Private vs. Public IPv4 Addresses
4.1 Public IP Addresses
A public IP address is globally unique and routable on the internet. These are assigned by IANA (Internet Assigned Numbers Authority) down through RIRs (Regional Internet Registries) to ISPs, who then assign them to customers.
Characteristics:
- Must be globally unique — no two devices on the internet can share the same public IP at the same time.
- Routable — internet routers will forward traffic to/from these addresses.
- Typically assigned by your ISP (either statically or dynamically).
- Example: 8.8.8.8 (Google's public DNS server).
4.2 Private IP Addresses (RFC 1918)
Private IP addresses are reserved ranges meant only for use inside private networks (homes, offices, data centers). They are not routable on the public internet — internet backbone routers are configured to drop any packets sourced from or destined to these ranges.
The Three Private Ranges:
Range | CIDR | Historical Class | Total Addresses |
|---|---|---|---|
10.0.0.0 – 10.255.255.255 | 10.0.0.0/8 | Class A | ~16.7 million |
172.16.0.0 – 172.31.255.255 | 172.16.0.0/12 | Class B | ~1 million |
192.168.0.0 – 192.168.255.255 | 192.168.0.0/16 | Class C | 65,536 |
Typical usage:
- 10.0.0.0/8 – Large enterprises needing massive internal address space (big campuses, multiple sites).
- 172.16.0.0/12 – Medium-sized organizations.
- 192.168.0.0/16 – Most common in home networks and small offices (e.g., default home router range 192.168.1.0/24 or 192.168.0.0/24).
Why Private Addressing Exists:
- IPv4 exhaustion – Only ~4.3 billion IPv4 addresses exist total, far short of the number of devices in use worldwide. Private ranges let every organization reuse the same addresses internally without conflict, since these addresses are never exposed to the public internet directly.
- Security by obscurity – Devices with private IPs aren't directly reachable from the internet, adding a layer of protection (though a proper firewall is still required — this alone isn't real security).
Quick Comparison:
Feature | Private IP | Public IP |
|---|---|---|
Routable on internet | No | Yes |
Uniqueness | Only within the local network | Globally unique |
Assigned by | Local admin / DHCP server | ISP / IANA / RIRs |
Example | 192.168.1.10 | 8.8.8.8 |
Cost | Free to use | Usually provided/charged by ISP |
Reachable directly from internet | No (without NAT/port forwarding) | Yes |
Exam-relevant tip: Learn to instantly spot a private address by its first octet(s):
- Starts with 10 → private (Class A range)
- Starts with 172.16 – 172.31 → private (Class B range) — note only this specific range, not all of 172.x
- Starts with 192.168 → private (Class C range)
Anything else (that isn't reserved/special, like 127.x for loopback or 169.254.x for APIPA) is generally a public address.
6. Configure and Verify IPv6 Addressing and Prefix
6.1 IPv6 Address Basics
IPv6 addresses are 128 bits long (vs. 32 bits for IPv4), written as 8 groups of 4 hexadecimal digits, separated by colons.
Full form example:
2001:0db8:0000:0000:0000:ff00:0042:8329
Why IPv6 Exists
IPv4 has only ~4.3 billion addresses — not enough for the modern world of billions of connected devices. IPv6 provides an astronomically larger address space (2^128 addresses — roughly 340 undecillion), solving address exhaustion permanently.
Shortening Rules for Writing IPv6 Addresses
Rule 1 — Omit leading zeros in each group:
2001:0db8:0000:0000:0000:ff00:0042:8329
→ 2001:db8:0:0:0:ff00:42:8329
Rule 2 — Replace one contiguous string of all-zero groups with a double colon :: (only once per address):
2001:db8:0:0:0:ff00:42:8329
→ 2001:db8::ff00:42:8329
Important: :: can only be used once in an address — if used twice, the address becomes ambiguous (you can't tell how many zero groups each: : represents).
6.2 IPv6 Prefix (Subnet Notation)
Like CIDR in IPv4, IPv6 uses a prefix length (slash notation) to indicate the network portion.
Example: 2001:db8:acad:1::/64
- /64 means the first 64 bits are the network portion (the "prefix"), and the remaining 64 bits are the Interface ID (host portion).
- /64 is the standard subnet size for virtually all IPv6 LANs — this is a fixed convention (unlike IPv4, where subnet size varies widely).
Typical IPv6 address structure:
| Global Routing Prefix (48 bits) | Subnet ID (16 bits) | Interface ID (64 bits) |
- Global Routing Prefix – assigned by ISP/provider, identifies your organization's network.
- Subnet ID – used internally to create subnets (similar in purpose to subnetting in IPv4).
- Interface ID – identifies the specific device (like the host portion in IPv4), often auto-generated using EUI-64 (see 1.9.d below).
6.3 Configuring IPv6 Addressing (Cisco IOS)
Enable IPv6 routing globally (required on routers to route between IPv6 networks):
Router(config)# ipv6 unicast-routing
Assign a static IPv6 address to an interface:
Router(config)# interface gigabitethernet0/0 Router(config-if)# ipv6 address 2001:db8:acad:1::1/64 Router(config-if)# no shutdown Enable EUI-64 (auto-generates the interface ID from the MAC address): Router(config-if)# ipv6 address 2001:db8:acad:1::/64 eui-64 Enable a link-local address automatically (happens by default when IPv6 is enabled on an interface), or set manually: Router(config-if)# ipv6 address fe80::1 link-local
Verifying IPv6 Addressing
Command | Purpose |
|---|---|
show ipv6 interface brief | Quick summary of IPv6 addresses and interface status |
show ipv6 interface [interface] | Detailed IPv6 info for a specific interface |
show ipv6 route | Displays the IPv6 routing table |
ping ipv6 [address] or ping [address] | Tests IPv6 connectivity |
show running-config | Confirms configured IPv6 addresses |
Example show ipv6 interface brief output:
Router# show ipv6 interface brief Output Omitted Interface Status Protocol Address GigabitEthernet0/0 up up fe80::12001:db8:acad:1::1
Notice each interface typically shows two IPv6 addresses — a link-local address (always present, starts with fe80::) and a global unicast address (if configured).
6.3 IPv6 Address Types
Unicast (Global, Unique Local, and Link-Local)
Unicast means an address identifies one single interface — traffic sent to it goes to exactly one destination.
Global Unicast Address (GUA)
- The IPv6 equivalent of a public IPv4 address — globally unique and routable on the internet.
- Always starts with 2000::/3 (in practice, most begin with 2xxx or 3xxx).
- Assigned by ISPs/organizations, used for devices that need to communicate on the internet.
- Structure: Global Routing Prefix + Subnet ID + Interface ID (as shown above).
Unique Local Address (ULA)
- The IPv6 equivalent of a private IPv4 address (like RFC 1918 ranges) — used for internal communication only, not routable on the public internet.
- Address range: fc00::/7 (in practice, almost always seen as fd00::/8 since the 8th bit is typically set to 1).
- Used for internal-only addressing, similar in purpose to 10.x.x.x or 192.168.x.x in IPv4 — though unlike IPv4 private ranges, ULA is designed to be statistically unique even across organizations (via a randomly generated Global ID), reducing conflicts if networks merge.
Link-Local Address (LLA)
- Automatically assigned to every IPv6-enabled interface — required for basic IPv6 operations like neighbor discovery, even if no other IPv6 address is configured.
- Address range: fe80::/10.
- Only valid on the local link/segment — never routed beyond the local network, not even by a router.
- Used for things like default gateway communication, routing protocol neighbor relationships (e.g., OSPFv3), and Neighbor Discovery Protocol (NDP).
|
Type |
Range |
Purpose |
Routable Beyond Local Link? |
|
Global Unicast |
2000::/3 |
Internet-routable, like public IPv4 |
Yes |
|
Unique Local |
fc00::/7 (fd00::/8 in practice) |
Internal-only, like private IPv4 |
No (internally routable, not on internet) |
|
Link-Local |
fe80::/10 |
Local segment operations only |
No (not even routed off the local link) |
Anycast
An anycast address is assigned to multiple devices (often in different locations), and traffic sent to that address is delivered to the nearest device (in terms of routing distance/metric) — not all of them.
Key details:
- Anycast addresses are not a separate address format — they're just regular unicast addresses assigned to multiple interfaces/devices intentionally.
- Useful for load distribution and redundancy — e.g., DNS root servers use anycast so that a query is automatically routed to the closest available server.
- Different from multicast: anycast delivers to one (nearest) recipient; multicast delivers to all members of a group.
Multicast
A multicast address represents a group of interfaces, and any packet sent to it is delivered to all members of that group.
Key details:
- Address range: ff00::/8 (all multicast addresses start with ff).
- Replaces broadcast entirely in IPv6 — IPv6 has no broadcast address type at all; multicast serves this purpose instead, making communication more efficient (only interested devices receive the traffic).
- Well-known multicast addresses:
- ff02::1 – All IPv6 devices on the local link ("all-nodes" multicast).
- ff02::2 – All IPv6 routers on the local link ("all-routers" multicast).
- Used heavily for protocols like NDP (Neighbor Discovery Protocol), which replaces ARP in IPv6.
6.4 Modified EUI-64 (Extended Unique Identifier)
EUI-64 is a method for automatically generating the Interface ID (the last 64 bits of an IPv6 address) from a device's 48-bit MAC address, without needing DHCP or manual configuration.
How It Works — Step by Step
Step 1: Take the 48-bit MAC address and split it in half:
MAC: AA:BB:CC:DD:EE:FF
First half: AA:BB:CC | Second half: DD:EE:FF
Step 2: Insert the fixed hex value FFFE in the middle:
AA:BB:CC:FF:FE:DD:EE:FF
Step 3: Flip the 7th bit (the "Universal/Local" or U/L bit) of the first byte. This bit indicates whether the MAC address is globally unique (0) or locally administered (1) — flipping it during EUI-64 generation is a technical formality specified by the standard.
- Original first byte: AA = 10101010 in binary
- Flip the 7th bit (from the left, 0-indexed as bit position 6): 10101000 = A8
Result: The final Interface ID becomes A8BB:CCFF:FEDD:EEFF
Full example:
MAC Address: : AA-BB-CC-DD-EE-FF
Modified EUI-64: : A8BB:CCFF:FEDD:EEFF
Combined with prefix : 2001:db8:acad:1::/64:
Full IPv6 address: : 2001:db8:acad:1:a8bb:ccff:fedd:eeff
Why it matters:
- Allows stateless address autoconfiguration (SLAAC) — a device can generate its own unique IPv6 address without a DHCP server, by combining the prefix advertised by the router (via Router Advertisement messages) with its own EUI-64-derived Interface ID.
- Guarantees uniqueness since it's derived from the (theoretically) globally unique MAC address.
Exam-relevant point: Be able to manually calculate a Modified EUI-64 address from a given MAC address and prefix.
2.1. IPv4 and Binary Foundations
Subnetting becomes much easier when you understand that every IPv4 address is a 32-bit binary value divided into four 8-bit octets. A subnet mask or prefix length tells the device which bits identify the network and which bits identify hosts inside that network.
2.1a IPv4 Address Format
Decimal: 192.168.10.25 |
2.1b Binary Bit Values
Bit Position | 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
Value if bit = 1 | 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
To convert binary to decimal, add the values of the positions containing 1. Example: 11000000 = 128 + 64 = 192.
11000000 = 192 |
2.1c Powers of Two You Should Know
Power | Value | Common Networking Meaning |
2^0 | 1 | One value |
2^1 | 2 | Two subnets / two values |
2^2 | 4 | Four subnets |
2^3 | 8 | Eight subnets |
2^4 | 16 | Sixteen values |
2^5 | 32 | 32 addresses |
2^6 | 64 | 64 addresses |
2^7 | 128 | 128 addresses |
2^8 | 256 | One IPv4 octet of combinations |
Exam Tip |
2.2 Subnet Masks and Prefix Length
A subnet mask is a 32-bit value containing contiguous 1s followed by contiguous 0s. The 1s identify the network/subnet portion; the 0s identify the host portion. CIDR prefix notation expresses the same information as /n.
2.2a Prefix-to-Mask Reference
Prefix | Subnet Mask | Host Bits | Total Addresses | Traditional Usable Hosts |
/8 | 255.0.0.0 | 24 | 16,777,216 | 16,777,214 |
/16 | 255.255.0.0 | 16 | 65,536 | 65,534 |
/20 | 255.255.240.0 | 12 | 4,096 | 4,094 |
/21 | 255.255.248.0 | 11 | 2,048 | 2,046 |
/22 | 255.255.252.0 | 10 | 1,024 | 1,022 |
/23 | 255.255.254.0 | 9 | 512 | 510 |
/24 | 255.255.255.0 | 8 | 256 | 254 |
/25 | 255.255.255.128 | 7 | 128 | 126 |
/26 | 255.255.255.192 | 6 | 64 | 62 |
/27 | 255.255.255.224 | 5 | 32 | 30 |
/28 | 255.255.255.240 | 4 | 16 | 14 |
/29 | 255.255.255.248 | 3 | 8 | 6 |
/30 | 255.255.255.252 | 2 | 4 | 2 |
/31 | 255.255.255.254 | 1 | 2 | Point-to-point special case |
/32 | 255.255.255.255 | 0 | 1 | Single host route |
2.2b Mask Values in One Octet
Binary Mask | Decimal | Block Size (256 - mask) |
00000000 | 0 | 256 |
10000000 | 128 | 128 |
11000000 | 192 | 64 |
11100000 | 224 | 32 |
11110000 | 240 | 16 |
11111000 | 248 | 8 |
11111100 | 252 | 4 |
11111110 | 254 | 2 |
11111111 | 255 | 1 |
Fast Method |
3. Subnetting Fundamentals
3.1 What Subnetting Does
Subnetting borrows bits from the host portion to create additional network/subnet bits. This creates more subnets, but each subnet supports fewer hosts.
Original: 192.168.10.0/24 |
3.2 Four Addresses You Must Identify
• Network address — first address in the subnet; all host bits are 0.
• First usable host — network address + 1 (traditional subnet behavior).
• Last usable host — broadcast address - 1.
• Broadcast address — last address in the subnet; all host bits are 1.
3.3 Host Formula
Traditional usable hosts = 2^h - 2 |
/31 Exception |
3.4 Subnet Formula
If b bits are borrowed from the original host portion: |
Modern subnetting uses subnet zero, so there is no need to subtract two from the number of subnets.
4. Fast Subnetting Methods
4.1 Method A — Block Size / Magic Number
1. Write the subnet mask.
2. Find the interesting octet: the first octet that is neither 255 nor 0.
3. Calculate block size = 256 - mask value.
4. List subnet boundaries by adding the block size.
5. Find the boundary containing the target IP.
6. The next boundary minus 1 is the broadcast address.
7. Network + 1 is the first usable host; broadcast - 1 is the last usable host.
4.2 Example: 192.168.10.77/26
Prefix /26 = 255.255.255.192 |
Item | Answer |
Network | 192.168.10.64/26 |
First host | 192.168.10.65 |
Last host | 192.168.10.126 |
Broadcast | 192.168.10.127 |
Usable hosts | 62 |
4.3 Method B — Binary AND
A device determines the network address by performing a bitwise AND between the IP address and subnet mask. For each bit position, 1 AND 1 = 1; all other combinations produce 0.
IP: 192.168.10.77 = 11000000.10101000.00001010.01001101 |
4.4 Method C — Host-Bit Calculation
Need 50 hosts: |
4.5 Quick Host-to-Prefix Table
Hosts Needed | Smallest Traditional Prefix | Usable Hosts |
2 | /30 | 2 |
3-6 | /29 | 6 |
7-14 | /28 | 14 |
15-30 | /27 | 30 |
31-62 | /26 | 62 |
63-126 | /25 | 126 |
127-254 | /24 | 254 |
255-510 | /23 | 510 |
511-1022 | /22 | 1022 |
4.6 Full IPv4 Subnetting — Step-by-Step Process
The easiest way to master subnetting is to use the same process every time. Do not guess the subnet. Work through the prefix, mask, block size, subnet boundary, network address, broadcast address, and usable host range in a fixed order.
MASTER RULE |
4.6.1 Step 1 — Write the IP Address and Prefix
Example:
192.168.10.77/27 |
• IP address = 192.168.10.77.
• Prefix = /27, so 27 bits identify the network/subnet.
• Host bits = 32 - 27 = 5.
4.6.2 Step 2 — Convert the Prefix to a Subnet Mask
11111111.11111111.11111111.11100000 |
Prefix bits in octet | Binary | Decimal mask | Block size |
1 | 10000000 | 128 | 128 |
2 | 11000000 | 192 | 64 |
3 | 11100000 | 224 | 32 |
4 | 11110000 | 240 | 16 |
5 | 11111000 | 248 | 8 |
6 | 11111100 | 252 | 4 |
7 | 11111110 | 254 | 2 |
8 | 11111111 | 255 | 1 |
4.6.3 Step 3 — Find the Interesting Octet
The interesting octet is the first mask octet that is neither 255 nor 0. That octet controls the subnet boundaries.
IP Address: 192.168.10.77 |
• For /27, the interesting octet is the fourth octet.
• For /20 = 255.255.240.0, the interesting octet is the third octet.
4.6.4 Step 4 — Calculate the Block Size
Block Size = 256 - Interesting Mask Value |
Every /27 subnet begins 32 addresses after the previous subnet.
4.6.5 Step 5 — List the Subnet Boundaries
0 |
These are the valid /27 network boundaries in the fourth octet.
4.6.6 Step 6 — Locate the Given IP Address
64 <= 77 < 96 |
So 192.168.10.77 belongs to 192.168.10.64/27.
4.6.7 Step 7 — Find Network, Host Range, and Broadcast
1. Network address = current subnet boundary.
2. First usable host = network + 1.
3. Broadcast address = next subnet - 1.
4. Last usable host = broadcast - 1.
Network: 192.168.10.64 |
Item | Result | Rule |
Network | 192.168.10.64 | Lower boundary |
First Host | 192.168.10.65 | Network + 1 |
Last Host | 192.168.10.94 | Broadcast - 1 |
Broadcast | 192.168.10.95 | Next subnet - 1 |
Next Subnet | 192.168.10.96 | 64 + block size 32 |
4.6.8 Step 8 — Verify Host Capacity
Host bits = 32 - 27 = 5 |
FINAL ANSWER — 192.168.10.77/27 |
4.7 Full Example — Subnetting in the Third Octet
Find the subnet details for 172.16.35.200/20.
1. Mask: /20 = 255.255.240.0.
2. Interesting octet = third octet (240).
3. Block size = 256 - 240 = 16.
4. Third-octet boundaries: 0, 16, 32, 48, 64, ...
5. 35 lies between 32 and 47.
6. Network = 172.16.32.0.
7. Next subnet = 172.16.48.0, so broadcast = 172.16.47.255.
8. First host = 172.16.32.1; last host = 172.16.47.254.
IP: 172.16.35.200/20 |
4.8 When the Question Gives a Host Requirement
Example: A LAN requires at least 50 usable hosts.
1. Use 2^h - 2 >= required hosts.
2. 5 host bits: 2^5 - 2 = 30 — not enough.
3. 6 host bits: 2^6 - 2 = 62 — enough.
4. Prefix = 32 - 6 = /26.
5. Mask = 255.255.255.192.
6. Block size = 64.
50 hosts required |
Hosts Needed | Smallest Prefix | Usable Hosts |
2 | /30 | 2 |
3-6 | /29 | 6 |
7-14 | /28 | 14 |
15-30 | /27 | 30 |
31-62 | /26 | 62 |
63-126 | /25 | 126 |
127-254 | /24 | 254 |
255-510 | /23 | 510 |
511-1022 | /22 | 1022 |
4.9 When the Question Gives a Number of Subnets
Example: Divide 192.168.20.0/24 into at least 8 equal-size subnets.
1. Original prefix = /24.
2. Use 2^n >= required subnets.
3. 2^3 = 8, so borrow 3 host bits.
4. New prefix = /24 + 3 = /27.
5. Block size = 32.
6. Subnet networks: .0, .32, .64, .96, .128, .160, .192, .224.
192.168.20.0/27 |
4.10 When Both Subnets and Hosts Are Required
Example: From 192.168.30.0/24, create at least 4 subnets with at least 50 usable hosts each.
1. Need 4 subnets: 2^2 = 4, so borrow 2 bits.
2. New prefix = /26.
3. Remaining host bits = 6.
4. 2^6 - 2 = 62 usable hosts, so the design satisfies both requirements.
192.168.30.0/26 Hosts .1-.62 Broadcast .63 |
4.11 The 30-Second CCNA Subnetting Method
Example: 10.20.30.141/28
1. /28 = 255.255.255.240.
2. Block size = 256 - 240 = 16.
3. Boundaries: 0,16,32,48,64,80,96,112,128,144,...
4. 141 lies inside 128-143.
5. Network = 10.20.30.128.
6. Broadcast = 10.20.30.143.
7. Usable range = 10.20.30.129-10.20.30.142.
8. /28 = 14 usable hosts.
FAST MENTAL PATTERN |
2.2 VLSM — Variable Length Subnet Masking
VLSM uses different prefix lengths inside the same address block. It allows each LAN or point-to-point segment to receive the smallest subnet that satisfies its requirement, reducing address waste.
2.2a VLSM Design Rules
1. List every subnet and required host count.
2. Sort requirements from largest to smallest.
3. Choose the smallest prefix that supports each requirement.
4. Allocate the largest subnet at the first valid boundary.
5. Move to the next unused address and verify that it is a valid boundary for the next prefix.
6. Continue until all requirements are allocated.
7. Check for overlap and record network, usable range, broadcast, gateway, and reserved capacity.
2.2b Full VLSM Calculation — Step-by-Step Process
VLSM questions become much easier when you treat them as an allocation problem. For each requirement, calculate the smallest suitable subnet, then place that subnet at the next valid boundary. Always work from the largest requirement to the smallest.
VLSM MASTER RULE |
2.2b Example Requirements
Parent network:
192.168.10.0/24 |
Segment | Hosts Required |
Sales | 100 |
IT | 50 |
HR | 25 |
Management | 10 |
WAN Point-to-Point | 2 |
6.2b Step 1 — Sort Requirements from Largest to Smallest
Sort before assigning any addresses:
Sales 100 hosts |
• This prevents a small subnet from occupying address space that a larger subnet needs.
• Do not allocate subnets in department-name order unless that already matches largest-to-smallest order.
2.2b Step 2 — Choose the Smallest Prefix for Each Requirement
Use 2^h - 2 >= required hosts.
Segment | Need | Calculation | Smallest Prefix | Usable Hosts |
Sales | 100 | 2^7 - 2 = 126 | /25 | 126 |
IT | 50 | 2^6 - 2 = 62 | /26 | 62 |
HR | 25 | 2^5 - 2 = 30 | /27 | 30 |
Management | 10 | 2^4 - 2 = 14 | /28 | 14 |
WAN | 2 | 2^2 - 2 = 2 | /30 | 2 |
WHY NOT USE A LARGER SUBNET? |
2.2b Step 3 — Allocate the Largest Subnet First
Sales needs 100 hosts, so use /25.
Parent network: 192.168.10.0/24 |
• The next allocation must start at or after 192.168.10.128.
2.2b Step 4 — Allocate the Next-Largest Subnet
IT needs 50 hosts, so use /26.
Next free address = 192.168.10.128 |
2.2b Step 5 — Continue with the Remaining LANs
HR needs 25 hosts:
Required prefix = /27 |
Management needs 10 hosts:
Required prefix = /28 |
2.2b Step 6 — Allocate the Point-to-Point Link
The WAN link requires two traditional usable IPv4 addresses, so use /30.
Required prefix = /30 |
Modern point-to-point links can also use /31 when both endpoints support RFC 3021. For introductory VLSM calculations, /30 remains common because it clearly demonstrates network and broadcast addresses.
2.2b Step 7 — Build the Final VLSM Table
Segment | Network/Prefix | Mask | Usable Range | Broadcast | Usable |
Sales | 192.168.10.0/25 | 255.255.255.128 | .1 - .126 | .127 | 126 |
IT | 192.168.10.128/26 | 255.255.255.192 | .129 - .190 | .191 | 62 |
HR | 192.168.10.192/27 | 255.255.255.224 | .193 - .222 | .223 | 30 |
Management | 192.168.10.224/28 | 255.255.255.240 | .225 - .238 | .239 | 14 |
WAN | 192.168.10.240/30 | 255.255.255.252 | .241 - .242 | .243 | 2 |
2.2b Step 8 — Identify the Remaining Free Address Space
Used through: 192.168.10.243 |
The remaining addresses are not automatically one valid subnet of any arbitrary size. Future allocations must still start on valid boundaries for the prefix being assigned.
• 192.168.10.244/30 is valid: .244-.247.
• 192.168.10.248/29 is valid: .248-.255.
• 192.168.10.244/28 is not a valid /28 network boundary because /28 boundaries occur every 16 addresses: .0, .16, .32, ..., .240.
2.2b Step 9 — Verify No Subnets Overlap
Check that the broadcast of one subnet is lower than the network address of the next subnet:
Sales broadcast .127 |
OVERLAP CHECK |
2.2b Step 10 — Verify Every Requirement Is Satisfied
Segment | Required | Provided | Result |
Sales | 100 | 126 | PASS |
IT | 50 | 62 | PASS |
HR | 25 | 30 | PASS |
Management | 10 | 14 | PASS |
WAN | 2 | 2 | PASS |
If any subnet provides fewer usable addresses than required, increase that subnet size and repeat the allocation from that point onward.
2.2c VLSM Boundary Rule
The next unused address must also be a valid network boundary for the next prefix. This is one of the most important VLSM checks.
Prefix | Block Size | Valid 4th-Octet Boundaries |
/25 | 128 | 0, 128 |
/26 | 64 | 0, 64, 128, 192 |
/27 | 32 | 0, 32, 64, 96, 128, 160, 192, 224 |
/28 | 16 | 0, 16, 32, 48, 64, ... 224, 240 |
/29 | 8 | 0, 8, 16, 24, ... 240, 248 |
/30 | 4 | 0, 4, 8, 12, ... 248, 252 |
2.2c Worked Example with a /23 Parent Network
A larger parent prefix is useful for learning how VLSM crosses octet boundaries. Use parent network 10.20.0.0/23 with these requirements:
Segment | Hosts |
LAN-A | 200 |
LAN-B | 100 |
LAN-C | 50 |
LAN-D | 20 |
WAN | 2 |
Calculate the prefixes:
Requirement | Smallest Prefix | Capacity |
200 | /24 | 254 |
100 | /25 | 126 |
50 | /26 | 62 |
20 | /27 | 30 |
2 | /30 | 2 |
Allocate from the start of 10.20.0.0/23:
LAN-A: 10.20.0.0/24 |
2.3 Complete VLSM Example
Given 192.168.10.0/24, allocate address space for Sales 100 hosts, IT 50 hosts, HR 25 hosts, Management 10 hosts, and a 2-host WAN link.
Segment | Hosts | Prefix | Mask | Network | Usable Range | Broadcast |
Sales | 100 | /25 | 255.255.255.128 | 192.168.10.0 | 192.168.10.1-.126 | 192.168.10.127 |
IT | 50 | /26 | 255.255.255.192 | 192.168.10.128 | 192.168.10.129-.190 | 192.168.10.191 |
HR | 25 | /27 | 255.255.255.224 | 192.168.10.192 | 192.168.10.193-.222 | 192.168.10.223 |
Management | 10 | /28 | 255.255.255.240 | 192.168.10.224 | 192.168.10.225-.238 | 192.168.10.239 |
WAN | 2 | /30 | 255.255.255.252 | 192.168.10.240 | 192.168.10.241-.242 | 192.168.10.243 |
Design Check |
2.4 VLSM Example with a Larger Parent Prefix
Parent network: 10.20.0.0/16. Requirements: HQ 900 hosts, Branch-A 400, Branch-B 200, Voice 100, Management 50, two WAN links.
Segment | Need | Chosen Prefix | Capacity | Example Allocation |
HQ | 900 | /22 | 1022 | 10.20.0.0/22 |
Branch-A | 400 | /23 | 510 | 10.20.4.0/23 |
Branch-B | 200 | /24 | 254 | 10.20.6.0/24 |
Voice | 100 | /25 | 126 | 10.20.7.0/25 |
Management | 50 | /26 | 62 | 10.20.7.128/26 |
WAN-1 | 2 | /30 | 2 | 10.20.7.192/30 |
WAN-2 | 2 | /30 | 2 | 10.20.7.196/30 |
6.4a /31 on Point-to-Point Links
RFC 3021 allows a /31 on point-to-point IPv4 links. A /31 contains exactly two addresses, and both can be assigned to the two endpoints. This improves address efficiency compared with /30.
Example link: 10.1.1.0/31 |
CCNA Note |
Exam and operations tips
- Subnetting is a speed skill: practice without a calculator.
- Longest prefix match uses the most specific route, independent of the classful boundary.
Quick knowledge check
How many usable addresses are normally available in a /26?
62.
What is the private range beginning with 172?
172.16.0.0/12.