Sitonce
Country: US
Show exams for United States Hong Kong
Sign in

IPv4 Subnetting and Route Selection

Updated 9 min read
Key takeaway

Subnetting divides IPv4 addresses into prefixes; route selection chooses the most specific usable route matching a destination.

  • For 192.168.10.70/26, network is 192.168.10.64, broadcast .127, and usable hosts .65-.126.
  • A router with 10.0.0.0/8 and 10.20.0.0/16 sends 10.20.4.9 using /16, the longer match.
On this page11 sections
  1. Why subnetting and routing belong together
  2. A reliable subnetting method
  3. Worked subnet: 192.168.10.70/26
  4. Common prefix patterns
  5. How a host decides whether to route
  6. Longest-prefix match
  7. Route match is not the whole forwarding decision
  8. Worked route selection scenario
  9. IPv6 connection
  10. Common mistakes
  11. Practice routine

Why subnetting and routing belong together

Subnetting answers which IPv4 addresses belong to a local network. Routing answers how traffic reaches a destination outside that local network. A host first compares its own address and mask with the destination. If the destination is local, it sends directly on the LAN; if it is remote, it sends toward its default gateway. A router then looks up the destination and chooses an appropriate next hop. A wrong mask can create a symptom that looks like a route failure, so learn both steps together.

A reliable subnetting method

An IPv4 address contains 32 bits. The prefix length tells how many leading bits identify the network. For common masks, the block size is 256 minus the interesting octet's mask value. Identify the octet where the mask stops being 255 or 0, count by the block size, then locate the address inside its block. For /26, the mask is 255.255.255.192, so the final-octet block size is 64: ranges begin at .0, .64, .128, and .192.

  1. Write the address and prefix, then convert the prefix to a mask or block size.
  2. Find the block boundary at or below the host address in the changing octet.
  3. That boundary is the network address; the next boundary minus one is the broadcast address.
  4. The ordinary usable host range is between those two addresses for standard subnets.
  5. Compare the configured gateway with the host's local range before investigating remote routes.

Worked subnet: 192.168.10.70/26

A /26 leaves six host bits. It creates four equal blocks in the last octet, each containing 64 addresses. The address .70 falls in the block that starts at .64 and ends at .127. Therefore the network is 192.168.10.64, the broadcast is 192.168.10.127, and usable host addresses are 192.168.10.65 through 192.168.10.126. The subnet contains 64 total addresses, of which 62 are ordinary host addresses.

If this host is configured with gateway 192.168.10.1, the gateway does not fall in the same /26. The host cannot reach it directly at Layer 2 using that mask. A local router interface such as 192.168.10.65 could be a plausible gateway if the topology and address plan support it. Do not change a distant route until the host's local gateway is coherent.

Common prefix patterns

PrefixMaskBlock size in changing octetUsable hosts (ordinary subnet)
/24255.255.255.0256 in the last octet254
/25255.255.255.128128 in the last octet126
/26255.255.255.19264 in the last octet62
/27255.255.255.22432 in the last octet30
/28255.255.255.24016 in the last octet14
/30255.255.255.2524 in the last octet2

These conventional usable-host counts apply to ordinary IPv4 subnets, not every special prefix or point-to-point convention. The exam may ask a basic address-range question; carefully read the prefix and avoid carrying a familiar /24 assumption into a smaller network. When you calculate under time pressure, verify the boundaries by checking that the address lies between the selected network and broadcast.

How a host decides whether to route

A host uses its own address and subnet mask to decide whether a destination is local. If both addresses share the network prefix, it resolves the destination's Layer 2 address and sends locally. Otherwise, it sends the packet to the configured default gateway. A host can have a correct DNS response and still fail to reach the destination if its gateway is missing, outside its subnet, or unavailable.

This creates a useful troubleshooting order: verify the host address and mask, test the local gateway, inspect VLAN and switch access, then examine the router's route to the remote destination. If the host cannot reach a peer in the same subnet, a default route on a distant router is unlikely to be the first fault. If local traffic works but remote traffic fails, continue along the routed path.

Longest-prefix match

A router compares a destination address against its routing table and chooses the most specific matching prefix. More prefix bits mean a narrower network and a longer match. A route for 10.20.0.0/16 is more specific than 10.0.0.0/8. A default route, 0.0.0.0/0, matches any destination but loses to every more-specific usable match.

Suppose a router has connected or learned routes for 10.0.0.0/8, 10.20.0.0/16, and a default route. A packet for 10.20.4.9 matches all three prefixes, but the /16 route is the most specific. A packet for 10.25.4.9 matches 10.0.0.0/8 and the default; the /8 wins. A packet for 172.16.1.5 matches neither private 10.x route, so the default route may be used if it is installed and usable.

Route match is not the whole forwarding decision

A route must be usable. The next hop should resolve through another route or a connected interface, and the outgoing interface should be operational. If a static route points to a next hop that the router cannot reach, it may not be installed or may not forward as intended. Also distinguish the route's administrative selection from longest-prefix match: routing protocols and administrative distance determine which route candidates are placed in the table, while packet forwarding uses the best matching installed prefix.

For CCNA practice, read the displayed routing table carefully. Identify the destination network, the route source code if shown, the prefix length, the next hop, and the outgoing interface. Then compare that entry with the destination address. Do not choose a route only because its metric number looks small; first determine whether it matches and whether it is in the active table.

Worked route selection scenario

A router has these usable routes: 192.168.0.0/16 via Router A, 192.168.40.0/24 via Router B, 192.168.40.128/25 via Router C, and 0.0.0.0/0 via Router D. A packet for 192.168.40.200 matches all four. The /25 covers addresses 192.168.40.128 through 192.168.40.255, so Router C is selected. If the destination were 192.168.40.80, the /24 via Router B is the longest matching route. A destination such as 192.168.50.5 uses the /16 via Router A.

Now suppose the Router C interface goes down and the /25 route is withdrawn. The /24 route can become the best match for 192.168.40.200, assuming it remains installed and usable. This illustrates why routing is dynamic: a packet uses the best currently available route, not necessarily the most specific one that ever existed.

IPv6 connection

IPv6 uses a 128-bit address and prefix length, commonly written after a slash. A /64 is common on a LAN, but candidates should follow the addressing task rather than assume every network uses the same prefix. Link-local addresses support communication on the local link and are not globally routed. IPv6 routing uses prefixes and next hops, so the same general principle of selecting an appropriate specific route applies even though the notation differs.

Do not attempt to convert a full IPv6 address to decimal under time pressure. Learn compression rules, recognize prefix boundaries, and identify whether two addresses share the relevant prefix. When configuring a link-local next hop, the outgoing interface may be necessary to distinguish which link the address belongs to.

Common mistakes

  • Using the wrong block boundary because the address is not aligned to the prefix size.
  • Calling the first or last address an ordinary usable host when the prompt asks for network or broadcast.
  • Assuming a destination is remote without checking the host's mask.
  • Selecting a default route despite a more-specific usable route.
  • Choosing a route based only on metric without checking prefix match and table status.
  • Troubleshooting DNS when the host cannot reach its gateway.
  • Changing a router route before verifying VLAN, trunk, gateway, and next-hop connectivity.

Practice routine

Practice subnetting with several prefixes and write each network, broadcast, and usable range. Then create a routing table with overlapping prefixes and test destinations at the first, middle, and last addresses of each range. Explain which route wins and why. Finally, introduce one fault such as a wrong gateway, missing VLAN, or unavailable next hop and identify the first observation that narrows the cause.

This topic maps to Network Fundamentals and IP Connectivity in the current CCNA outline. It also supports Network Access troubleshooting because VLAN boundaries affect whether a gateway is reachable. The current blueprint's weights are 20% Fundamentals and 25% IP Connectivity, making these skills useful beyond a single isolated question.

For a /27, the final-octet mask is 224 and the block size is 32. The subnet boundaries are .0, .32, .64, .96, .128, .160, .192, and .224. Address .110 is in the .96/27 range, so its network is .96, broadcast is .127, and ordinary usable hosts run from .97 to .126. If its gateway is .65, that gateway belongs to .64/27 and is not local. This is a common trap because both addresses look close and share the first three octets.

For routing, write the matching prefix lengths before considering which next hop is desirable. If destinations match /8, /16, and /24 entries, the /24 wins by longest-prefix match when it is installed and usable. A lower metric on a broader route does not make it more specific for packet forwarding. If the /24 route disappears, the router can fall back to the /16. This makes route-table changes important during troubleshooting.

For a /27, the final-octet mask is 224 and the block size is 32. Boundaries are .0, .32, .64, .96, .128, .160, .192, and .224. Address .110 lies in .96/27, so network is .96, broadcast is .127, and ordinary usable hosts run from .97 to .126. If its gateway is .65, that gateway belongs to .64/27 and is not local. This is a common trap because both addresses share the first three octets.

When a routing table contains equal-length prefixes from multiple sources, route installation criteria such as administrative distance and metric may matter. Do not confuse that comparison with longest-prefix match. Longest-prefix chooses the most specific installed route matching a packet; route selection determines which candidate routes enter the table. Identify which rule the scenario is asking about before comparing values.

A small lab can reinforce the connection between these concepts. Assign two host addresses and masks, configure a gateway, then test local and remote reachability. Add overlapping routes and predict which entry forwards a destination. Break the gateway or remove the specific route and observe the new failure. Write down the test that proves each hypothesis, rather than only saving the final configuration.

Common questions

What is the usable range for 192.168.10.70/26?

192.168.10.65 through 192.168.10.126; network .64 and broadcast .127.

How does longest-prefix match work?

The most specific installed usable route matching the destination is selected.

When does a router use a default route?

When no more-specific usable route matches the destination.