LESSON OVERVIEW

IPv4 addressing provides the logical addressing system used to identify hosts and networks so that devices can communicate across local and routed networks. Every IPv4 address contains a network portion and a host portion, determined by the subnet mask or CIDR prefix length.


In this lesson, you will learn how IPv4 addresses are structured, how subnet masks define network boundaries, and how routers determine whether a destination is local or remote. You will also learn how to divide larger IPv4 networks into smaller subnets based on host and network requirements.

 

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.

1. ​IPv4 Addressing - Full Foundation

IPv4 addressing provides a logical addressing system that allows devices to communicate across local and routed IP networks.

Every IPv4 address is 32 bits long and is normally written in dotted-decimal notation.

 

1.1 What Is an IPv4 Address?

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 and  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.

Classful addressing was inefficient because it allocated IP addresses based on fixed network classes, often resulting in significant address wastage. For example, an organization requiring 300 host addresses would need a Class B network supporting 65,534 usable hosts, leaving most addresses unused.


To overcome this limitation, Classless Inter-Domain Routing (CIDR) was introduced, allowing flexible subnet masks instead of fixed class-based boundaries. This enabled more efficient IP address allocation and made subnetting an essential part of modern network design.


2 Subnet Masks and CIDR Notation

A subnet mask identifies which portion of an IPv4 address represents the network and which portion represents the host.


2.1 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 a simplified way of representing a subnet mask. The number following the slash (/) indicates how many bits, starting from the left, are used to identify the network portion of an IP address.

Example: 192.168.1.0/24:  The /24 indicates that the first 24 bits represent the network portion, equivalent to the subnet mask 255.255.255.0.

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 – Essential Values to Memorize for Accurate and Efficient Subnetting Calculations

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)

1. Identify the Interesting Octet: Locate the octet in the subnet mask whose value is neither 0 nor 255.
2. Calculate the Magic Number: Subtract the interesting octet's subnet mask value from 256. The result determines the subnet block size or increment.
3. Determine the Network Addresses: Start at 0 and repeatedly add the magic number to identify each subnet's network address.
4. Calculate the Broadcast Address: Subtract 1 from the next subnet's network address to determine the broadcast address of the current subnet.
5. Identify the Usable Host Range: Add 1 to the network address to find the first usable host IP, and subtract 1 from the broadcast address to find the last usable host IP.

Note: The usable host calculation applies to conventional IPv4 subnets. /31 point-to-point links and /32 host routes are special cases.


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)

Variable Length Subnet Masking (VLSM) is an IP subnetting technique that allows multiple subnet masks of different lengths to be used within the same network.

Unlike traditional fixed-length subnetting, where every subnet has the same size, VLSM enables network administrators to create subnets based on the specific number of hosts required.


This approach optimizes IP address utilization, minimizes address wastage, and provides greater flexibility and scalability in network design.

 

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: Begin by allocating the largest subnet to ensure efficient IP address utilization and prevent overlapping address ranges. Then, progressively allocate smaller subnets from the remaining available address space until all subnet requirements are satisfied.

 

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

IPv4 addresses can be broadly classified as private or public depending on where they are used and whether they are routable across the Internet.


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 of Public IP Addresses

  1. Globally Unique: Each public IP address must be unique across the Internet.

  2. Internet Routable: Public IP addresses allow communication across the Internet.

  3. ISP Assigned: Typically assigned by an Internet Service Provider (ISP).

  4. Static or Dynamic: Can be permanently assigned or automatically allocated.

  5. Example: 8.8.8.8 – Google's Public DNS server.

4.2 Private IP Addresses (RFC 1918)

Private IP addresses are reserved IP address ranges used within internal networks, such as homes, offices, and data centers. These addresses are not publicly routable on the Internet, as Internet service providers and backbone routers generally filter traffic originating from or destined for private IP address 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.


5. Configure and Verify IPv6 Addressing and Prefix

IPv6 provides a 128-bit addressing system designed to support a very large address space and simplify modern IP networking. For CCNA, you should understand IPv6 address structure, prefix notation, common address types, interface configuration, and verification.

 

5.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: The double colon (::) can be used only once in an IPv6 address to compress consecutive groups of zeros. Using it more than once creates ambiguity because the number of omitted zero groups cannot be determined.

 

5.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).

5.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).


5.4 IPv6 Address Types

Unicast Addresses (Global, Unique Local, and Link-Local)

An IPv6 unicast address uniquely identifies a single network interface. Traffic sent to a unicast address is delivered to the specific interface associated with that address, enabling one-to-one communication between devices.

 

1. Global Unicast Address (GUA)

  1. Globally Unique: Similar to a public IPv4 address, a Global Unicast Address is designed for globally unique identification and communication across the Internet.

  2. Address Range: Uses the 2000::/3 address block, typically beginning with 2xxx or 3xxx.

  3. Internet Routable: Can be routed across the public Internet, subject to routing and security policies.

  4. Address Allocation: Generally allocated through ISPs or organizations for devices requiring global connectivity.

  5. Address Structure: Consists of three main components: Global Routing Prefix, Subnet ID, and Interface ID.

2. Unique Local Address (ULA)

  1. Private IPv6 Addressing: Similar in purpose to private IPv4 addresses, ULAs are designed for communication within internal networks.

  2. Address Range: Uses fc00::/7, with locally assigned addresses typically belonging to fd00::/8.

  3. Not Internet Routable: ULAs are not intended to be routed across the public Internet.

  4. Internal Communication: Commonly used for private networks, internal applications, and communication between organizational sites.

  5. Reduced Address Conflicts: Uses a randomly generated Global ID to provide a high probability of uniqueness, helping minimize address conflicts when networks are interconnected or merged.

3. Link-Local Address (LLA)

  1. Automatic Configuration: IPv6-enabled interfaces normally have a link-local address, even when no Global Unicast Address is configured.

  2. Address Range: Uses the fe80::/10 address block.

  3. Local-Link Communication: Used only within the local network segment and cannot be forwarded by routers to other networks.

  4. Neighbor Discovery: Supports essential IPv6 functions such as Neighbor Discovery Protocol (NDP) and router discovery.

  5. Routing Protocol Communication: Used for communication between directly connected routing neighbors, including protocols such as OSPFv3.

  6. Default Gateway: IPv6 hosts commonly use a router's link-local address as their default gateway.

Key Difference: GUA provides global connectivity, ULA supports private internal communication, and LLA enables communication between devices on the same local link.

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 an IPv6 address assigned to multiple devices or interfaces, often located in different geographical locations. Traffic sent to an anycast address is delivered to the nearest available device based on the network's routing topology and metrics.


Key Characteristics of Anycast

  1. Multiple Devices: The same anycast address can be assigned to multiple devices or interfaces.

  2. Nearest Destination: Traffic is routed to one of the nearest available devices based on routing metrics.

  3. Standard Address Format: Anycast uses regular unicast address formats rather than a separate IPv6 address range.

  4. Load Distribution: Helps distribute network traffic across multiple servers or locations.

  5. High Availability: Provides redundancy by allowing traffic to reach another available device when routing changes.

  6. Common Use Case: DNS services use anycast to direct queries to nearby available DNS servers.

Multicast

A Multicast address identifies a group of IPv6 interfaces. Packets sent to a multicast address are delivered to the members of that multicast group within the applicable multicast scope.


Key Characteristics of Multicast

  1. Group Communication: Allows a single packet to be delivered to multiple devices belonging to the same multicast group.

  2. Address Range: IPv6 multicast addresses use FF00::/8, meaning they begin with FF.

  3. No Broadcast: IPv6 does not support broadcast addresses; multicast is used for functions previously handled by broadcast in IPv4.

  4. Efficient Communication: Delivers traffic to the intended multicast group rather than every device on the network.

  5. All-Nodes Multicast: FF02::1 identifies all IPv6 nodes on the local link.

  6. All-Routers Multicast: FF02::2 identifies all IPv6 routers on the local link.

  7. Neighbor Discovery: IPv6 uses multicast for Neighbor Discovery Protocol (NDP) operations, replacing IPv4 ARP functionality.

Anycast vs Multicast

Feature

Anycast

Multicast

Communication Type

One-to-one-of-many

One-to-many

Destination

One selected device

Multiple group members

Address Format

Uses unicast address format

Uses FF00::/8

Routing Behavior

Selects a destination based on routing

Delivers traffic to multicast group members

Primary Purpose

Load distribution and redundancy

Efficient group communication

Common Example

DNS anycast servers

IPv6 Neighbor Discovery

Key Takeaway: Anycast delivers traffic to one selected destination among multiple devices sharing an address, while multicast delivers traffic to multiple members of a designated group.


5.5 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 Modified EUI-64 Works – Step by Step

Step 1: Identify and Split the MAC Address
Take the 48-bit MAC address and divide it into two equal parts of 24 bits each.MAC: AA:BB:CC:DD:EE:FF

First half: AA:BB:CC | Second half: DD:EE:FF


Step 2: Insert FFFE in the Middle

Insert the hexadecimal value FFFE between the two halves to expand the 48-bit MAC address into a 64-bit identifier.

AA:BB:CC:FF:FE:DD:EE:FF


Step 3: Invert the Universal/Local (U/L) Bit

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.

 

Pasted content image

Figure 5.5 - Modified EUI-64 (Extended Unique Identifier)


6. IPv4 Subnetting, VLSM & Supernetting

IPv4 subnetting divides a larger IP network into smaller logical networks. It improves address utilization, routing efficiency, broadcast control, and network organization.


The three related concepts are:

Subnetting = divide a network

VLSM = divide it using different subnet sizes

Supernetting = combine multiple networks into one summary route

 

6.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.

Pasted content image

Figure 6.1 - IPv4 and Binary conversion


6.1a IPv4 Address Format

Decimal: 192.168.10.25

Binary: 11000000.10101000.00001010.00011001

Length: 32 bits = 4 octets = 4 bytes

6.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

10101000 = 168

00001010 = 10

00011001 = 25

6.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

Memorize powers of two from 2^0 through 2^8. Most CCNA subnet calculations reduce to these values.


6.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.


6.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


6.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

Find the interesting octet (the first mask octet that is not 255 or 0). Block size = 256 - mask value in that octet. Subnet boundaries increase by the block size.

 

7. Subnetting Fundamentals

Subnetting is the process of dividing a larger IP network into smaller logical networks called subnets. It allows network administrators to use IPv4 address space efficiently, separate different groups of devices, reduce broadcast domains, and design networks that are easier to manage and troubleshoot.

 

7.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

Borrow 2 host bits

New prefix: /26

Number of new subnets: 2^2 = 4

Host bits remaining: 32 - 26 = 6

Usable hosts/subnet: 2^6 - 2 = 62

Pasted content image

Figure 7.1 - Process of subnetting of the ip address


7.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.

 

7.3 Host Formula

Traditional usable hosts = 2^h - 2

 

h = number of host bits

Subtract 2 for the network and broadcast addresses.

/31 Exception

RFC 3021 permits /31 prefixes on point-to-point links. Both addresses are used as endpoints; the traditional network/broadcast subtraction does not apply in the same way.


7.4 Subnet Formula

If b bits are borrowed from the original host portion:

Number of equal-size subnets = 2^b

Modern subnetting uses subnet zero, so there is no need to subtract two from the number of subnets.

 

8. Fast Subnetting Methods

Fast subnetting is the ability to determine the network address, broadcast address, usable host range, subnet mask, and next subnet quickly without converting an entire IPv4 address into binary.

 

8.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.

 

8.2 Example: 192.168.10.77/26

Prefix /26 = 255.255.255.192

Interesting octet = 192

Block size = 256 - 192 = 64

 

Subnet boundaries:

0, 64, 128, 192

 

77 falls between 64 and 127.

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


8.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

Mask: 255.255.255.192= 11111111.11111111.11111111.11000000

AND: 192.168.10.64 = 11000000.10101000.00001010.01000000

8.4 Method C - Host-Bit Calculation

Need 50 hosts:

2^5 - 2 = 30 -> Not enough

2^6 - 2 = 62 -> Enough

Host bits = 6

Prefix = 32 - 6 = /26

 

8.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


8.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

For almost every CCNA IPv4 subnetting question, identify these four values: Network Address → First Usable Host → Last Usable Host → Broadcast Address. The 8-step method below produces those values consistently.

Pasted content image

Figure 8.6 - Full IPv4 Subnetting - Step-by-Step Process


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.

 

Step 2 - Convert the Prefix to a Subnet Mask

11111111.11111111.11111111.11100000

255 .255 .255 .224

 

/27 = 255.255.255.224

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


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

Subnet Mask: 255.255.255.224

 ^^^

 Interesting octet

• For /27, the interesting octet is the fourth octet.

• For /20 = 255.255.240.0, the interesting octet is the third octet.

 

Step 4 - Calculate the Block Size

Block Size = 256 - Interesting Mask Value

256 - 224 = 32

Block size = 32

Every /27 subnet begins 32 addresses after the previous subnet.

 

Step 5 - List the Subnet Boundaries

0

32

64

96

128

160

192

224

These are the valid /27 network boundaries in the fourth octet.

 

Step 6 - Locate the Given IP Address

64 <= 77 < 96

Therefore:

Current subnet = 64

Next subnet = 96

So 192.168.10.77 belongs to 192.168.10.64/27.

 

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

First Host: 192.168.10.65

Last Host: 192.168.10.94

Broadcast: 192.168.10.95

Next Subnet: 192.168.10.96

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

Step 8 - Verify Host Capacity

Host bits = 32 - 27 = 5

Total addresses = 2^5 = 32

Usable hosts = 2^5 - 2 = 30

FINAL ANSWER — 192.168.10.77/27

Mask 255.255.255.224 | Network 192.168.10.64 | First 192.168.10.65 | Last 192.168.10.94 | Broadcast 192.168.10.95 | 30 usable hosts


8.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

Mask: 255.255.240.0

Block Size: 16 in the 3rd octet

 

Network: 172.16.32.0

First Host: 172.16.32.1

Last Host: 172.16.47.254

Broadcast: 172.16.47.255

 

Host bits = 12

Usable hosts = 2^12 - 2 = 4094

 

8.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

/27 = 30 usable -> too small

/26 = 62 usable -> correct

 

Answer: /26

Mask: 255.255.255.192

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

 

8.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

192.168.20.32/27

192.168.20.64/27

192.168.20.96/27

192.168.20.128/27

192.168.20.160/27

192.168.20.192/27

192.168.20.224/27

 

8.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

192.168.30.64/26 Hosts .65-.126 Broadcast .127

192.168.30.128/26 Hosts .129-.190 Broadcast .191

192.168.30.192/26 Hosts .193-.254 Broadcast .255

 

8.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.
    1. Usable range = 10.20.30.129-10.20.30.142.
  7. /28 = 14 usable hosts.

FAST MENTAL PATTERN

Mask → Block Size → Boundaries → Locate IP → Network = lower boundary → Broadcast = next boundary - 1 → Hosts are between network and broadcast.


9. 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.

 

9.1 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.

9.2 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

Largest requirement first → smallest suitable prefix → allocate at the next valid boundary → calculate network/host/broadcast → move to the next unused address → repeat.

Pasted content image

Figure 9.2 - VLSM Calculation step by step


9.3 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

Step 1 - Sort Requirements from Largest to Smallest

Sort before assigning any addresses:

Sales 100 hosts

IT 50 hosts

HR 25 hosts

Management 10 hosts

WAN 2 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.

 

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?

A /24 would work for 100 hosts, but it would waste far more addresses. VLSM chooses the smallest prefix that still satisfies the host requirement.


Step 3 - Allocate the Largest Subnet First

Sales needs 100 hosts, so use /25.

Parent network: 192.168.10.0/24

 

Sales:

Required prefix = /25

Mask = 255.255.255.128

Block size = 128

 

Network = 192.168.10.0

First Host = 192.168.10.1

Last Host = 192.168.10.126

Broadcast = 192.168.10.127

 

Next free IP = 192.168.10.128

The next allocation must start at or after 192.168.10.128.

 

Step 4 - Allocate the Next-Largest Subnet

IT needs 50 hosts, so use /26.

Next free address = 192.168.10.128

 

/26 mask = 255.255.255.192

Block size = 64

 

Network = 192.168.10.128

First Host = 192.168.10.129

Last Host = 192.168.10.190

Broadcast = 192.168.10.191

 

Next free IP = 192.168.10.192

 

Step 5 - Continue with the Remaining LANs

HR needs 25 hosts:

Required prefix = /27

Mask = 255.255.255.224

Block size = 32

 

Network = 192.168.10.192

First Host = 192.168.10.193

Last Host = 192.168.10.222

Broadcast = 192.168.10.223

 

Next free IP = 192.168.10.224

Management needs 10 hosts:

Required prefix = /28

Mask = 255.255.255.240

Block size = 16

 

Network = 192.168.10.224

First Host = 192.168.10.225

Last Host = 192.168.10.238

Broadcast = 192.168.10.239

 

Next free IP = 192.168.10.240

 

Step 6 - Allocate the Point-to-Point Link

The WAN link requires two traditional usable IPv4 addresses, so use /30.

Required prefix = /30

Mask = 255.255.255.252

Block size = 4

 

Network = 192.168.10.240

R1 = 192.168.10.241

R2 = 192.168.10.242

Broadcast = 192.168.10.243

 

Next free IP = 192.168.10.244

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.

 

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

 

Step 8 - Identify the Remaining Free Address Space

Used through: 192.168.10.243

Unused range: 192.168.10.244 - 192.168.10.255

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.

 

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

IT network .128 -> no overlap

 

IT broadcast .191

HR network .192 -> no overlap

 

HR broadcast .223

Management network .224 -> no overlap

 

Management broadcast .239

WAN network .240 -> no overlap

OVERLAP CHECK

For adjacent allocations, the next subnet should normally begin immediately after the previous broadcast when packing the address block efficiently.

 

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.


9.4 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

 

9.5 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

 Hosts 10.20.0.1 - 10.20.0.254

 Broadcast 10.20.0.255

 Next free 10.20.1.0

 

LAN-B: 10.20.1.0/25

 Hosts 10.20.1.1 - 10.20.1.126

 Broadcast 10.20.1.127

 Next free 10.20.1.128

 

LAN-C: 10.20.1.128/26

 Hosts 10.20.1.129 - 10.20.1.190

 Broadcast 10.20.1.191

 Next free 10.20.1.192

 

LAN-D: 10.20.1.192/27

 Hosts 10.20.1.193 - 10.20.1.222

 Broadcast 10.20.1.223

 Next free 10.20.1.224

 

WAN: 10.20.1.224/30

 Hosts 10.20.1.225 - 10.20.1.226

 Broadcast 10.20.1.227

 

9.6 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.

Pasted content image

Figure 9.6 - Complete VLSM step by step 


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

The remaining addresses 192.168.10.244-192.168.10.255 are not one arbitrary 12-address subnet. They can be allocated only in valid CIDR-aligned blocks such as /30, /29, etc., without crossing boundaries.


9.7 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


9.7a /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

R1 = 10.1.1.0/31

R2 = 10.1.1.1/31

CCNA Note

Know the traditional /30 calculation and understand that /31 is valid for point-to-point links when supported. Do not use /31 on a normal multiaccess LAN.

Quick knowledge check

Q1. How many usable IP addresses are normally available in a /26 subnet?

Answer: 62 usable IP addresses.

Q2. What is the private IPv4 address range beginning with 172?

Answer: 172.16.0.0/12.