Book an info sessionInfo session

IPv4 subnetting: CIDR notation, subnet masks, network/broadcast/host addresses

CompTIA Network+ Preparation · lesson 7 of 30 · 25 min

IPv4 Addressing Review

An IPv4 address is 32 bits written as four octets in dotted-decimal notation: 192.168.1.100. Each octet is 8 bits (0–255).

Address classes (legacy, still tested):

Class A: 1.0.0.0 – 126.255.255.255. Default mask /8. Large networks (16 million hosts).

Class B: 128.0.0.0 – 191.255.255.255. Default mask /16. Medium networks (65,534 hosts).

Class C: 192.0.0.0 – 223.255.255.255. Default mask /24. Small networks (254 hosts).

Private address ranges (RFC 1918): 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16. Not routable on the public internet.

Loopback: 127.0.0.1 (localhost). APIPA: 169.254.0.0/16 (auto-assigned when DHCP fails).

CIDR and Subnet Masks

CIDR (Classless Inter-Domain Routing) notation uses a slash followed by the number of network bits: 192.168.1.0/24. This replaced classful addressing and allows flexible subnet sizes.

Subnet mask — 32-bit value where 1s represent the network portion and 0s represent the host portion. /24 = 255.255.255.0.

Key calculations for any subnet:

Number of hosts = 2^(host bits) – 2. Subtract 2 for network address and broadcast address.

Network address — all host bits set to 0. First address in the subnet.

Broadcast address — all host bits set to 1. Last address in the subnet.

Usable host range — network address + 1 to broadcast address – 1.

Example — 192.168.1.0/26:

Host bits = 32 – 26 = 6. Usable hosts = 2^6 – 2 = 62. Subnet mask = 255.255.255.192.

Network address: 192.168.1.0. Broadcast: 192.168.1.63. Usable range: 192.168.1.1 – 192.168.1.62.

Subnetting a /24 into /26s: 2^2 = 4 subnets. Each has 62 usable hosts. Subnets: .0/26, .64/26, .128/26, .192/26.

Quick Method

Block size = 256 – subnet mask last octet. For /26: 256 – 192 = 64. Subnets start at 0, 64, 128, 192. The broadcast of each subnet is one less than the next subnet’s start.

Key Terms

Key Terms

Knowledge Check — 10 Questions

Network+ — IPv4 Subnetting

How many usable hosts does a /28 subnet provide?

  • 30
  • 16
  • 14
  • 12

Answer: 14
/28 = 4 host bits. 2^4 = 16 addresses. 16 – 2 = 14 usable hosts (subtract network and broadcast).

What is the subnet mask for /26?

  • 255.255.255.128
  • 255.255.255.192
  • 255.255.255.224
  • 255.255.255.240

Answer: 255.255.255.192
/26 = 26 network bits. Last octet: 11000000 = 128+64 = 192. Mask = 255.255.255.192.

For 192.168.10.0/27, what is the broadcast address?

  • 192.168.10.30
  • 192.168.10.31
  • 192.168.10.32
  • 192.168.10.63

Answer: 192.168.10.31
/27 = 5 host bits. Block size = 32. Subnet 0: network=.0, broadcast=.31, hosts=.1–.30.

Which address range is an RFC 1918 private range?

  • 172.32.0.0/12
  • 192.168.0.0/16
  • 10.0.0.0/16
  • 169.254.0.0/16

Answer: 192.168.0.0/16
RFC 1918 private ranges: 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16. Note: 172.16–172.31 (not 172.32). 169.254 is APIPA.

APIPA addresses (169.254.x.x) indicate:

  • A successful DHCP assignment
  • DHCP failed — the device assigned itself an address
  • A static IP configuration
  • A public IP address
  • Answer: DHCP failed — the device assigned itself an address

APIPA (169.254.0.0/16) is auto-assigned when a device cannot reach a DHCP server. It only allows local subnet communication.

How many /26 subnets can be created from a /24 network?

  • 2
  • 4
  • 8
  • 16

Answer: 4
Borrowing 2 bits from a /24 gives /26. 2^2 = 4 subnets. Each has 62 usable hosts.

The loopback address 127.0.0.1 is used for:

  • Default gateway
  • Testing the local TCP/IP stack without sending traffic on the network
  • DHCP server
  • DNS server
  • Answer: Testing the local TCP/IP stack without sending traffic on the network

127.0.0.1 (localhost) loops back to the local machine — used to test that TCP/IP is working without network hardware. A /30 subnet is commonly used for:

  • Large office networks
  • Point-to-point WAN links — only 2 usable hosts needed
  • Server farms
  • Wireless networks
  • Answer: Point-to-point WAN links — only 2 usable hosts needed

/30 = 2 usable hosts — perfect for point-to-point links between two routers where only 2 IPs are needed.

What is the network address of 10.0.0.130/25?

  • 10.0.0.0
  • 10.0.0.128
  • 10.0.0.129
  • 10.0.0.255

Answer: 10.0.0.128
/25 block size = 128. Subnets: 10.0.0.0 (hosts .1–.126) and 10.0.0.128 (hosts .129–.254). .130 falls in the second subnet.

The formula for usable hosts in a subnet is 2^n – _____, where n is the number of host bits.

Answer: 2
Subtract 2: one for the network address (all host bits 0) and one for the broadcast address (all host bits 1).

Try it: IPv4 subnetting drill


Previous lesson: Network topologies: star, mesh, bus, ring, hybrid; IP addressing and subnetting
Back to CompTIA Network+ Preparation
Next lesson: IPv6 addressing: types, notation, autoconfiguration (SLAAC), DHCPv6