CCNA curriculum / Module 01 / Lesson 05

Free lesson · CCNA 200-301 v1.1

IPv4 Addressing and Subnetting

An address identifies an interface; its subnet mask tells the device which addresses are local. A correct address with the wrong mask can lead to incorrect forwarding decisions. Learn the calculation before configuring devices.

Basic familiarity with routers, switches, endpoints, and transport protocols is helpful. Start with paper; use an emulator for the configuration practice.

Learning objectives

  • Interpret the 32-bit IPv4 structure and its network and host portions.
  • Convert subnet masks to CIDR prefixes and back.
  • Find network, broadcast, and usable host addresses.
  • Calculate host capacity and subnet boundaries using block size.
  • Divide a network equally and recognize VLSM allocations.
  • Configure router and PC addressing and verify settings and reachability.

IPv4 addresses, masks, and CIDR

IPv4 uses 32 bits, written as four dotted-decimal octets. Each octet contains eight bits and ranges from 0 to 255. For example, 10.0.0.2 is 00001010.00000000.00000000.00000010.

A subnet mask has contiguous leading 1 bits for the network portion, followed by 0 bits for the host portion. Interfaces in the same subnet share the network bits; host bits distinguish addresses within it. The address alone does not tell you where that split occurs.

CIDR means classless inter-domain routing. Its slash notation counts leading network bits, allowing boundaries beyond whole octets. A /26 has 26 network bits and 32 − 26 = 6 host bits.

  • /8 = 255.0.0.0; /16 = 255.255.0.0; /24 = 255.255.255.0.
  • /25 = 255.255.255.128; /26 = 255.255.255.192.
  • /27 = 255.255.255.224; /28 = 255.255.255.240.

For /26, the final mask octet is binary 11000000: 128 + 64 = 192. The first three octets contribute 24 ones and the final octet contributes two. Count 26 ones to convert back to /26.

Calculate a subnet step by step

For conventional broadcast subnets in these exercises, setting all host bits to zero gives the network address; setting them all to one gives the broadcast address. Neither is assigned to a host. First usable is network + 1; last usable is broadcast − 1.

With h host bits, there are 2^h total addresses and 2^h − 2 conventional usable host addresses. A /24 has 256 total and 254 usable; a /26 has 64 total and 62 usable. This subtraction is not universal: a /31 on a point-to-point link can use both addresses, and a /32 identifies one address. Those exceptional cases do not use the conventional network/broadcast reservation model.

Find the subnet containing 10.0.0.66/26:

  1. Convert /26 to 255.255.255.192. The changing boundary is in the fourth octet.
  2. Calculate block size: 256 − 192 = 64 addresses.
  3. List fourth-octet boundaries: 0, 64, 128, 192. Since 64 ≤ 66 < 128, the network is 10.0.0.64.
  4. The next boundary is 10.0.0.128, so broadcast is one address before it: 10.0.0.127.
  5. Usable hosts run from 10.0.0.65 through 10.0.0.126, inclusive. Capacity is 2^6 − 2 = 62.

The block-size shortcut applies in the mask octet containing the partial boundary. Keep preceding network octets fixed and include all following host octets. Whole-octet boundaries such as /24 need no partial octet: 10.0.0.0/24 spans 10.0.0.0 through 10.0.0.255.

Worked example: four /26 subnets

Start with 10.0.0.0/24. Four equal subnets require two borrowed host bits because 2^2 = 4. Add them to /24 to get /26. Six host bits remain; every subnet uses mask 255.255.255.192 and advances by 64 addresses.

10.0.0.0/26
Usable hosts: 10.0.0.1–10.0.0.62; broadcast: 10.0.0.63; capacity: 62 usable hosts.
10.0.0.64/26
Usable hosts: 10.0.0.65–10.0.0.126; broadcast: 10.0.0.127; capacity: 62 usable hosts.
10.0.0.128/26
Usable hosts: 10.0.0.129–10.0.0.190; broadcast: 10.0.0.191; capacity: 62 usable hosts.
10.0.0.192/26
Usable hosts: 10.0.0.193–10.0.0.254; broadcast: 10.0.0.255; capacity: 62 usable hosts.

Each broadcast is just before the next network. The final block ends at 10.0.0.255; the next boundary is 10.0.1.0, outside the original /24. Four blocks of 64 cover all 256 addresses without gaps or overlap. Reserving two addresses per subnet leaves 4 × 62 = 248 usable addresses.

VLSM: match subnet size to demand

Variable-length subnet masks (VLSM) allocate different-sized subnets within a parent network. This differs from the equal /26 split above. Choose enough host bits for each requirement and allocate the largest block first, respecting boundaries and avoiding overlap.

As a separate example within 10.0.0.0/24, 120 hosts fit in 10.0.0.0/25 (126 usable, .1–.126, broadcast .127). Next, 25 hosts fit in 10.0.0.128/27 (30 usable, .129–.158, broadcast .159). Finally, 10 hosts fit in 10.0.0.160/28 (14 usable, .161–.174, broadcast .175). Addresses .176–.255 remain unallocated. These blocks are aligned, non-overlapping, and contained in the parent network.

Practice: calculate before looking

  1. Recreate the four-/26 table on paper, including mask and capacity.
  2. Find the network, broadcast, usable range, and capacity for 10.0.0.45/27.
  3. Can PC-B use 10.0.0.127/26? Can a PC at 10.0.0.66/26 use gateway 10.0.0.1?
  4. What is the smallest conventional subnet that holds 25 hosts?

Answers and explanations

  1. Use the worked table to check: mask .192, block 64, boundaries .0, .64, .128, .192, and 62 usable per subnet.
  2. /27 is 255.255.255.224; block = 256 − 224 = 32. 45 lies between boundaries 32 and 64. Network is 10.0.0.32, broadcast 10.0.0.63, usable 10.0.0.33–10.0.0.62, capacity 30.
  3. No: .127 is the broadcast of 10.0.0.64/26. Gateway .1 is outside PC-B's subnet; use the local router interface, 10.0.0.65, in this plan.
  4. /27: five host bits provide 30 usable. /28 provides only 14, so it cannot meet the requirement.

Practice: configure and verify addressing

In an emulator, use one router with four routed Ethernet interfaces. Connect PC-A through SW1 to the first interface and PC-B through SW2 to the second; connect PC-C and PC-D directly to the remaining interfaces. Keep these four local segments separate. Choose hardware with enough interfaces; substitute its actual interface names in the commands.

Assign router addresses .1, .65, .129, and .193 in 10.0.0.0/24, each with mask 255.255.255.192. For example, configure the first interface:

  1. enable
  2. configure terminal
  3. interface gigabitethernet0/0/0
  4. ip address 10.0.0.1 255.255.255.192
  5. no shutdown
  6. end

Repeat on each remaining interface with its corresponding address. Each connected subnet then has a local router interface.

  • PC-A: 10.0.0.2, mask 255.255.255.192, gateway 10.0.0.1.
  • PC-B: 10.0.0.66, mask 255.255.255.192, gateway 10.0.0.65.
  • PC-C: 10.0.0.130, mask 255.255.255.192, gateway 10.0.0.129.
  • PC-D: 10.0.0.194, mask 255.255.255.192, gateway 10.0.0.193.

The gateway is the router interface on the PC's own subnet. It consumes one of the 62 usable addresses; it is not an extra reserved address.

  1. Run show ip interface brief on the router. Check assigned addresses and interface state; connected active links should be up/up. An administratively down interface needs no shutdown.
  2. Run ipconfig on each PC and compare its address, mask, and gateway with the plan.
  3. Ping each PC's gateway. Then from PC-A run ping 10.0.0.66 and ping 10.0.0.130; from PC-B run ping 10.0.0.194. Record the actual results. If a test fails, check the local settings, cables, and router interface states.

Interface status verifies interface addressing and state, not end-to-end connectivity. A successful ping demonstrates reachability for that tested exchange; it does not prove that every network service works.

Common mistakes

  • Confusing 64 total addresses with 62 usable hosts in a /26.
  • Doing block-size arithmetic in the wrong octet or treating a host address as a network boundary.
  • Using the next boundary as the broadcast: subtract one first.
  • Assuming every .0 is a network or every .255 is a broadcast regardless of prefix.
  • Assigning the network or broadcast to a host in a conventional subnet.
  • Choosing an overlapping VLSM block or a gateway outside the local subnet.

Knowledge check

  1. What determines the network/host split of a 32-bit IPv4 address?
  2. What mask, host-bit count, block size, and usable capacity correspond to /26?
  3. Why does dividing /24 into four equal subnets produce /26?
  4. What is the first usable address in 10.0.0.128/26?
  5. How does VLSM differ from equal-size subnetting?
  6. Which tools verify router interface state, PC settings, and reachability?

Answers and explanations

  1. The subnet mask, equivalently its CIDR prefix length, marks the leading network bits.
  2. 255.255.255.192; six host bits; block 64; 62 conventional usable hosts.
  3. Two borrowed bits provide four combinations; 24 + 2 = 26 network bits.
  4. 10.0.0.129: add one to the network address. .128 identifies the network.
  5. VLSM uses different prefix lengths to match host requirements; equal-size subnets share one prefix length.
  6. show ip interface brief, ipconfig, and ping, respectively. Each answers a different verification question.

Rework any missed calculation from mask to block size to boundaries, then check the usable range. Accuracy comes before speed.

Return to the CCNA curriculum