IPv4 addressing, classes and private ranges

Listen to this lesson

Episode 11 · 35:29

This episode is a study companion for CompTIA Network+ N10-009 and is not produced by or endorsed by CompTIA.

Objective 1.7 · Networking Concepts · 23% of the exam

Why this matters

Objective 1.7 is "given a scenario, use appropriate IPv4 network addressing", and use is the operative word. This is not a recall objective — you will be given a situation and asked which address, which mask, or why a host cannot communicate.

It is also the objective that leaks into everything else. A large share of domain 5's troubleshooting questions are addressing problems wearing a disguise: the wrong mask, a duplicate address, an APIPA address that tells you DHCP failed. Get this solid and the rest of the exam gets easier.

The previous lesson covered binary, which this one assumes.

The lesson

The shape of an address

An IPv4 address is 32 bits, written as four decimal octets separated by dots: 192.168.1.10. Each octet is 8 bits, so each ranges 0–255.

Every address is in two parts: a network portion and a host portion. The subnet mask says where the boundary is. A mask of 255.255.255.0 means the first 24 bits identify the network and the last 8 identify the host within it.

The critical consequence: two hosts can only talk directly if they agree they are on the same network. A host ANDs its own address with its mask to find its network, does the same for the destination, and compares. Same result, send directly. Different result, send to the default gateway.

That is why a wrong subnet mask produces such strange symptoms. A host with the wrong mask may reach some destinations and not others, because the boundary it believes in disagrees with reality for some addresses but not all. "Can ping some hosts on the LAN but not others, and the internet works" is a mask problem, and it is an exam staple.

Public versus private

Public addresses are globally unique, allocated through regional registries, and routable on the internet. Private addresses are reserved for internal use, are not routable on the internet, and may be reused by everyone.

The private ranges are defined by RFC1918 (written RFC 1918), and you must know them:

Range CIDR Size
10.0.0.0 – 10.255.255.255 10.0.0.0/8 ~16.7 million
172.16.0.0 – 172.31.255.255 172.16.0.0/12 ~1 million
192.168.0.0 – 192.168.255.255 192.168.0.0/16 ~65,000

The 172 range is the one people get wrong. It is 172.16 through 172.31 — not all of 172.x. 172.15.0.0 and 172.32.0.0 are public addresses that belong to someone else, and an exam question will offer one.

Private addresses reach the internet through NAT, which rewrites the private source address to a public one on the way out and reverses it on the way back. That is what lets a whole household share one public address, and it is the main reason IPv4 has survived long past the point its address space ran out.

Special addresses

Loopback / localhost — 127.0.0.0/8, in practice 127.0.0.1. Traffic sent here never leaves the host; the stack loops it straight back. ping 127.0.0.1 tests that TCP/IP is installed and working locally — it says nothing whatever about your cable, your switch or your network. That distinction is examined: if loopback works but nothing else does, the problem is outside the host's stack.

Note the whole /8 is reserved. 127.5.5.5 is also loopback.

APIPA — 169.254.0.0/16. Automatic Private IP Addressing. When a host is configured for DHCP and gets no response, it assigns itself an address in this range. It can then talk to other APIPA hosts on the same segment and nothing else — no gateway, no DNS, no internet.

This is one of the most useful diagnostic signals on the exam. An address starting 169.254 means DHCP failed. The host is not broken; something between it and the DHCP server is. Check the cable, the switch port, the VLAN, the DHCP scope for exhaustion, and whether a relay is needed because the server is on another subnet.

Also worth knowing: within any subnet, the first address is the network identifier and the last is the broadcast address, and neither can be assigned to a host. That is why a /24 offers 254 usable addresses, not 256.

Subnetting, CIDR and why classes were replaced

Subnetting is dividing one address block into smaller networks. Originally the first bits of an address determined the split between network and host — a rigid scheme called classful addressing, covered in detail in the next lesson. Its problem was waste: an organisation needing 300 addresses had to take a Class B of 65,534, and the unused remainder was gone.

CIDR (Classless Inter-Domain Routing) removed the fixed boundary. The mask is stated explicitly as a prefix length — /24, /26, /30 — and can fall anywhere, so a network can be sized to what is actually needed.

CIDR notation is simply the count of network bits:

  • /24 = 255.255.255.0 = 254 usable hosts
  • /25 = 255.255.255.128 = 126 usable
  • /26 = 255.255.255.192 = 62 usable
  • /27 = 255.255.255.224 = 30 usable
  • /28 = 255.255.255.240 = 14 usable
  • /30 = 255.255.255.252 = 2 usable — the classic point-to-point link

The usable-host formula is 2^h − 2, where h is the number of host bits and the subtraction accounts for the network and broadcast addresses.

CIDR also enables route summarisation: several contiguous networks can be advertised as one larger prefix, so routers carry fewer routes. That is what kept the internet's routing tables manageable.

VLSM

Variable Length Subnet Mask means using different mask lengths within the same address space, sizing each subnet to its actual need.

Without VLSM, splitting 192.168.1.0/24 means every subnet is the same size. With it, you can allocate:

  • 192.168.1.0/25 — 126 hosts, for the user LAN
  • 192.168.1.128/26 — 62 hosts, for servers
  • 192.168.1.192/27 — 30 hosts, for printers and management
  • 192.168.1.224/30 — 2 hosts, for a router-to-router link
  • and still have 192.168.1.228 onward spare

The method is always the same: allocate the largest subnet first, then the next largest, from the remaining space. Doing it smallest-first fragments the space and you run out.

The rule that catches people: subnets must not overlap, and each must start on a valid boundary for its size. A /26 can begin at .0, .64, .128 or .192 — never at .32.

Practise what you just read

1. A workstation set to obtain an address automatically has come up with 169.254.18.7. What does this indicate?

Select one

  1. The workstation has been assigned a public address
  2. The default gateway is unreachable but DHCP succeeded
  3. No DHCP server responded, so the host self-assigned
  4. The subnet mask on the DHCP scope is misconfigured
Show answer

C. An address in 169.254.0.0/16 is APIPA, assigned by the host itself after a DHCP request went unanswered. The host can reach other APIPA hosts on the segment and nothing else. Check the cable, switch port, VLAN, scope exhaustion, and whether a relay is needed.

2. Which of these addresses is a public address rather than RFC 1918 private space?

Select one

  1. 172.32.5.10, which falls outside the private range
  2. 172.20.5.10, which is inside the private range
  3. 10.55.5.10, which is inside the private range
  4. 192.168.5.10, which is inside the private range
Show answer

A. The private ranges are 10.0.0.0/8, 172.16.0.0/12 and 192.168.0.0/16. The 172 block covers only second octets 16 through 31, so 172.20 is private but 172.32 belongs to someone on the internet. This is the trap the exam sets most often.

3. A technician pings 127.0.0.1 successfully but cannot reach anything else on the network. What has that test established?

Select one

  1. The cable and switch port are working correctly
  2. The default gateway is reachable from this host
  3. The DHCP server has issued a valid lease already
  4. Only that the local TCP/IP stack is functioning
Show answer

D. Traffic sent to the loopback range never leaves the host, so a successful reply says the protocol stack is installed and working and nothing whatever about the cable, the switch or the network. The whole 127.0.0.0/8 range is reserved for this.

5 more questions on this objective are part of the full course.

Practise the full question bank in the exam simulator

Hands-on labs

All hands-on labs