IPv4 Addressing and Subnetting
Learning Objectives
Understand the IPv4 address format and classes
Differentiate between classful and classless addressing
Use CIDR notation to calculate the number of hosts
Subnet a network and find valid host and broadcast addresses
Apply IP addressing in real-world network design scenarios
What is an IP Address?
An IP address (Internet Protocol address) is a unique identifier for each device on a
network, similar to a house address in a city. It allows devices to locate and communicate
with each other.
Example:
192.168.1.10 → A device connected to a local Wi-Fi network
IPv4 Address Format
IPv4 uses 32 bits, divided into 4 octets (or bytes).
Each octet is 8 bits long.
Values in each octet range from 0 to 255.
Example IP: 192.168.0.1 → This is a typical private IP address.
Each IP address consists of:
Network Portion – identifies the network
Host Portion – identifies the specific device on that network
IP Address Classes (Classful Addressing)
Historically, IP addresses were divided into classes (A–E), based on the first octet. Though
classful addressing is obsolete, understanding it helps grasp networking concepts.
First Octet Default Subnet
Class Binary Prefix Typical Use
Range Mask
A 0 – 127 Starts with 0 255.0.0.0 (/8) Large organizations
B 128 – 191 Starts with 10 255.255.0.0 (/16) Universities, ISPs
Starts with Small businesses, home
C 192 – 223 255.255.255.0 (/24)
110 networks
Starts with
D 224 – 239 N/A Multicast communication
1110
Starts with
E 240 – 255 N/A Experimental, research
1111
Special Address:
127.0.0.1 is called the loopback address. It points to your own device and is used for
testing.
Limitations of Classful Addressing
Class A and B blocks are too large and wasteful. Class C blocks are too small for medium
organizations. To solve this, we use CIDR.
CIDR – Classless Inter-Domain Routing
CIDR replaces classful addressing by allowing flexible division of IP space.
CIDR Notation
Format: IP_address/prefix_length
Example: 192.168.1.0/24
/24 means the first 24 bits are for the network; the remaining bits are for hosts.
Prefix Table
CIDR Subnet Mask Host Bits Total IPs Usable Hosts
/30 255.255.255.252 2 4 2
/29 255.255.255.248 3 8 6
/28 255.255.255.240 4 16 14
/27 255.255.255.224 5 32 30
/26 255.255.255.192 6 64 62
CIDR Subnet Mask Host Bits Total IPs Usable Hosts
/25 255.255.255.128 7 128 126
/24 255.255.255.0 8 256 254
Note: Always subtract 2 from total IPs to get usable hosts:
1 reserved for network address
1 reserved for broadcast address
Example: CIDR vs Classful
Let’s say we need 400 IPs for an institute.
Option 1 – Classful
Class B → /16 → 65,534 usable IPs
Enough, but Wasteful (over 65,000 unused)
Option 2 – CIDR
What prefix gives us ≥ 400 IPs?
Try /23 → 9 host bits → 2^9 = 512 total IPs → 510 usable
Best fit
Assign: 192.168.0.0/23
Type Value
Network 192.168.0.0
Broadcast 192.168.1.255
Usable Range 192.168.0.1 – 192.168.1.254
Subnetting Basics
Subnetting is dividing one large network into smaller logical networks.
Why Subnet?
Efficient IP usage
Improved security and isolation
Reduces network congestion
Subnetting Example – Divide into 4 Subnets
Given:
Network: 192.168.1.0/24
Goal: Create 4 equal subnets
Step 1: Determine Bits to Borrow
4 subnets → 2^n ≥ 4 → n = 2 bits
Step 2: New Subnet Mask
Original: /24 → Borrow 2 bits → New = /26
Subnet Mask: 255.255.255.192
o 192 in binary = 11000000
Step 3: Subnet Blocks (Using Block Increments)
Each /26 subnet has 2^6 = 64 IP addresses
So the block size is 64
Subnet # Network Address Broadcast Address Usable IPs
1 192.168.1.0 192.168.1.63 192.168.1.1 – 192.168.1.62
2 192.168.1.64 192.168.1.127 192.168.1.65 – 192.168.1.126
3 192.168.1.128 192.168.1.191 192.168.1.129 – 192.168.1.190
4 192.168.1.192 192.168.1.255 192.168.1.193 – 192.168.1.254
Block increment = 64, so each subnet starts at previous network + 64.
Subnetting Example – Class B Network
Given:
Network: 172.16.0.0/16 (Class B)
Goal: Divide into 16 equal subnets
Step 1: Determine Bits to Borrow
We want 16 subnets.
Formula: 2^n ≥ 16
n = 4 bits (since 2⁴ = 16)
Step 2: New Subnet Mask
Original: /16
Borrow 4 bits → New = /20
New subnet mask: 255.255.240.0
Explanation:
In binary, the 4 borrowed bits are in the 3rd octet
240 in binary: 11110000
Step 3: Subnet Blocks
Each /20 subnet = 2^(32–20) = 4096 IPs
Usable hosts per subnet: 4096 – 2 = 4094
Block increment = 4096
In the 3rd octet, 4096 IPs means incrementing by 16 (because 4096 = 16 × 256)
Subnet # Network Address Broadcast Address Usable IPs
1 172.16.0.0 172.16.15.255 172.16.0.1 – 172.16.15.254
2 172.16.16.0 172.16.31.255 172.16.16.1 – 172.16.31.254
3 172.16.32.0 172.16.47.255 172.16.32.1 – 172.16.47.254
4 172.16.48.0 172.16.63.255 172.16.48.1 – 172.16.63.254
... ... ... ...
16 172.16.240.0 172.16.255.255 172.16.240.1 – 172.16.255.254
Block increment = 16 in the third octet
Subnetting Example – Class A Network
Given:
Network: 10.0.0.0/8 (Class A)
Goal: Create 256 subnets
Step 1: Determine Bits to Borrow
We need 256 subnets
2^n ≥ 256 → n = 8 bits
Step 2: New Subnet Mask
Original: /8
Borrow 8 bits → New = /16
New subnet mask: 255.255.0.0
Explanation:
Borrowing 8 bits adds a whole octet to the network portion
Step 3: Subnet Blocks
Each /16 subnet contains:
216=65,536 total IPs
Usable IPs = 65,536−2=65,534 (subtracting 1 for network address, 1 for broadcast
address)
Each new subnet is incremented by 1 in the second octet (because the third and fourth
octets remain within each block of 65,536 addresses).
Subnet # Network Address Broadcast Address Usable IPs
1 10.0.0.0 10.0.255.255 10.0.0.1 – 10.0.255.254
2 10.1.0.0 10.1.255.255 10.1.0.1 – 10.1.255.254
3 10.2.0.0 10.2.255.255 10.2.0.1 – 10.2.255.254
Subnet # Network Address Broadcast Address Usable IPs
4 10.3.0.0 10.3.255.255 10.3.0.1 – 10.3.255.254
... ... ... ...
256 10.255.0.0 10.255.255.255 10.255.0.1 – 10.255.255.254
Home Network Example
Your home router might use:
Network: 192.168.0.0/24
Devices (laptop, phones): 192.168.0.1 – 192.168.0.254
Router’s IP: 192.168.0.1
Broadcast: 192.168.0.255
Practice Problems
Question:
Subnet the network 192.168.10.0/24 into 8 subnets.
Instructions:
Write the new subnet mask
List the network, broadcast, and usable IP range for each subnet
Question:
Subnet the network 172.16.0.0/16 into 16 subnets.
Instructions:
Write the new subnet mask.
List the network, broadcast, and usable IP range for each subnet.
Question:
Subnet the network 10.0.0.0/8 into 64 subnets.
Instructions:
Write the new subnet mask.
List the network, broadcast, and usable IP range for each subnet.