Network Infrastructure and Connectivity · Topic 4 of 9

IPv4 Subnetting Practice

Worked IPv4 subnetting practice with every step shown: find the network and broadcast, check gateways, spot overlaps and plan VLSM from host counts.

  • 7 min
In a nutshell
  • Block size is 256 minus the mask value in the interesting octet.
  • The network is the largest multiple of the block size at or below the address. The broadcast is the next network minus 1.
  • Usable hosts are 2 to the host bits, minus 2.

What it is

Subnetting is a skill you learn by working problems, so this page gives you worked examples with every step shown.

The first problems find a subnet from an address. The later ones use the answer to troubleshoot: is a gateway valid, do two subnets overlap, and how do you plan subnets from host counts.

Cover the answer, work the steps on paper, then compare.

How it works

Every problem uses the same five steps, whatever the prefix.

Address and prefix172.16.45.200/27write the maskMask255.255.255.224256 minus 224Block size32largest multiple that fitsNetwork172.16.45.192
  1. Write the mask in dotted decimal.
  2. Find the interesting octet, the first one that is neither 255 nor 0.
  3. Block size is 256 minus the mask value in that octet.
  4. The network address is the largest multiple of the block size that does not exceed the address in that octet.
  5. The broadcast is the next network address minus 1. Usable hosts run from network plus 1 to broadcast minus 1.

Usable hosts equal 2 to the host bits, minus 2.

Exam tip

For prefixes /17 to /23 the interesting octet is the third. The fourth octet is all host bits, so the network ends in .0 and the broadcast ends in .255.

Problem 1: 172.16.45.200/27

The mask is 255.255.255.224, so the interesting octet is the fourth and the block size is 256 minus 224, which is 32. The multiples of 32 are 0, 32, 64, 96, 128, 160, 192 and 224, and the largest that does not exceed 200 is 192.

  • Network: 172.16.45.192
  • Broadcast: next network 224, minus 1, gives 172.16.45.223
  • Usable range: 172.16.45.193 to 172.16.45.222
  • Usable hosts: 5 host bits, so 32 minus 2 is 30

Problem 2: 192.168.5.77/22

The mask is 255.255.252.0, so the interesting octet is the third and the block size is 4. The multiples of 4 go 0, 4, 8, and the address has 5 in that octet, so the network starts at 4.

  • Network: 192.168.4.0
  • Broadcast: next network 192.168.8.0, minus 1, gives 192.168.7.255
  • Usable range: 192.168.4.1 to 192.168.7.254
  • Usable hosts: 10 host bits, so 1,024 minus 2 is 1,022
Watch out

The subnet spans four third-octet values, 4 to 7. Answering 192.168.5.0 as the network is the classic slip.

Problem 3: 10.200.150.9/20

The mask is 255.255.240.0, so the block size in the third octet is 16. The multiples are 0, 16, ... 128, 144, 160, and the largest that does not exceed 150 is 144.

  • Network: 10.200.144.0
  • Broadcast: 10.200.159.255
  • Usable range: 10.200.144.1 to 10.200.159.254
  • Usable hosts: 12 host bits, so 4,096 minus 2 is 4,094

Problem 4: is the gateway valid?

Host A is 192.168.20.70/28 and its gateway is set to 192.168.20.79. A /28 has block size 16, and 70 sits in the block that starts at 64.

  • Network: 192.168.20.64 and broadcast: 192.168.20.79
  • The usable range is .65 to .78, so the gateway .79 is the broadcast address and cannot work.

Problem 5: a wrong mask hides the fault

A host is 10.1.1.130 with mask 255.255.255.128 and gateway 10.1.1.1. A /25 has block size 128, so 10.1.1.130 is in 10.1.1.128 to 10.1.1.255.

  • The usable range is 10.1.1.129 to 10.1.1.254.
  • The gateway 10.1.1.1 is in 10.1.1.0/25, a different subnet, so the gateway is outside the host's subnet. Either the gateway or the mask is wrong.

Problem 6: do these subnets overlap?

Compare each pair by listing the first and last address.

PairRangesOverlap?
192.168.1.0/25 and 192.168.1.64/26.0 to .127 and .64 to .127Yes, the /26 sits inside the /25
10.0.0.0/22 and 10.0.3.0/2410.0.0.0 to 10.0.3.255 and 10.0.3.0 to 10.0.3.255Yes, the /24 sits inside the /22
172.16.0.0/24 and 172.16.1.0/24172.16.0.0 to .0.255 and 172.16.1.0 to .1.255No

Problem 7: prefix from a host count

Pick the smallest prefix whose usable hosts, 2 to the host bits minus 2, are enough.

Hosts neededPrefixUsable hosts
2/302
30/2730
31/2662
100/25126
500/23510

The step from 30 to 31 hosts doubles the block, because two addresses are lost to the network and broadcast addresses.

Problem 8: split 192.168.1.0/24 into 8 equal subnets

Eight subnets need 3 borrowed bits, because 2 to the power 3 is 8. The prefix becomes /27, with block size 32 and 30 usable hosts.

The networks are 192.168.1.0, .32, .64, .96, .128, .160, .192 and .224, each /27.

Problem 9: a VLSM plan for 192.168.50.0/24

A site needs LAN A with 100 hosts, LAN B with 50, LAN C with 20 and two point-to-point links. Sort from largest to smallest and place each block directly after the one before.

SubnetPrefixNetworkUsable rangeBroadcast
LAN A/25192.168.50.0.1 to .126.127
LAN B/26192.168.50.128.129 to .190.191
LAN C/27192.168.50.192.193 to .222.223
Link 1/30192.168.50.224.225 to .226.227
Link 2/30192.168.50.228.229 to .230.231

The range .232 to .255 is left free for growth. Place the largest block first, because every block must start on a multiple of its own size.

Verifying the result on a router

interface GigabitEthernet0/0
 ip address 192.168.50.1 255.255.255.128
Router# show ip interface brief
Interface              IP-Address      OK? Method Status    Protocol
GigabitEthernet0/0     192.168.50.1    YES manual up        up

Compare the address and the mask with your plan. show ip route connected then shows the connected network as 192.168.50.0/25.

Common mistakes

Using the wrong octet. A /20 changes the third octet, not the fourth.

Forgetting to subtract 2. A /27 has 32 addresses but only 30 usable hosts.

Rounding the network up. The network is the multiple at or below the address.

Accepting the broadcast address as a gateway. It looks like a normal address but never works as one.

Placing small blocks first in a VLSM plan. The larger blocks then do not fit on their boundaries.

What to remember for the exam

  • Block size is 256 minus the mask value in the interesting octet.
  • The network is the largest multiple of the block size at or below the address. The broadcast is the next network minus 1.
  • Usable hosts are 2 to the host bits, minus 2.
  • A gateway must be inside the host's usable range, never the network or broadcast address.
  • Two subnets overlap if their address ranges share any address.
  • In VLSM, allocate the largest subnet first.
  • A /30 serves a point-to-point link. 30 hosts need a /27, and 31 hosts need a /26.

Check yourself

  • What are the network and broadcast addresses of 10.9.200.17/21?

    The network is 10.9.200.0 and the broadcast is 10.9.207.255, because the block size in the third octet is 8.

  • What is the usable range of 192.168.3.100/26?

    192.168.3.65 to 192.168.3.126, because the subnet is 192.168.3.64 with broadcast .127.

  • Do 172.16.8.0/21 and 172.16.12.0/22 overlap?

    Yes. The /21 covers 172.16.8.0 to 172.16.15.255, and the /22 covers 172.16.12.0 to 172.16.15.255.

Topic 4 of 9 in Network Infrastructure and Connectivity

Test yourself on Network Infrastructure and Connectivity

The full Cisco CCNA 200-301 v2.0 question bank has 1,242 questions, with timed practice exams and an explanation for every answer.

This study guide is independent and is not affiliated with, endorsed by, or sponsored by Cisco. Vendor names, certification names and exam codes are trademarks of their respective owners and are used for identification only.