Skip to content
Study Hall
Lesson 3 of 4Networking
Unit 3 · Lesson 3 of 4

IP Addressing and Subnetting

How every device on a network gets a unique address, and how the subnet mask decides which devices can reach each other directly.

4 min read10 practice questionsInteractiveAsk AI about this →

Key things to remember

  1. 1An IPv4 address is 32 bits, written as four octets of 0–255.
  2. 2The subnet mask is always contiguous 1s then 0s; /24 = 255.255.255.0.
  3. 3Usable hosts = .
  4. 4Network address: all host bits 0. Broadcast address: all host bits 1. Neither is assignable.
  5. 5Private ranges: 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16.
  6. 6169.254.x.x (APIPA) means DHCP failed.
  7. 7DHCP sequence: Discover, Offer, Request, Acknowledge (DORA).
  8. 8IPv6 is 128 bits, written in hex groups, with :: replacing one run of zeros.

An IPv4 address is a 32-bit number, written as four decimal numbers from 0 to 255 so people can say it out loud. That is the whole format. What makes addressing interesting is that the address is really two addresses joined together: part of it names the network, and the rest names a specific host on that network. The subnet mask is what says where the split falls.

The mask, not the address, decides where the network part ends.192110000001681010100010000010103700100101NETWORK — 24 bitsHOST — 8 bitsmask 255.255.255.0 = /24 = 11111111.11111111.11111111.00000000network address (all host bits 0) 192.168.10.0broadcast address (all host bits 1) 192.168.10.255usable hosts 2⁸ − 2 = 254 (.1 through .254)
Fig 1The mask cuts the address into a network part and a host part.

The mask and CIDR notation

A subnet mask is 32 bits too, but it is always a run of 1s followed by a run of 0s — never mixed. The 1s mark network bits and the 0s mark host bits. Because the 1s are always contiguous, you only need to say how many there are, which is what CIDR notation does: /24 means 24 network bits, which is the mask 255.255.255.0.

CIDRSubnet maskHost bitsUsable hosts
/24255.255.255.08254
/25255.255.255.1287126
/26255.255.255.192662
/27255.255.255.224530
/28255.255.255.240414
/29255.255.255.24836
/30255.255.255.25222
Usable hosts = 2^(host bits) − 2. The two lost addresses are the network and broadcast addresses.
Subtract 2: the all-zeros network address and the all-ones broadcast address are never assigned.
Three addresses to identify in any subnet
Network address: every host bit set to 0 — this names the subnet itself. Broadcast address: every host bit set to 1 — reaches every host on that subnet at once. Usable hosts: everything strictly between them. Neither the network nor the broadcast address can be assigned to a device.
Loading interactive…
Slide the prefix and watch the split move through the bits.

Private addresses and NAT

IPv4 has about 4.3 billion addresses, which ran out. Three ranges are reserved as private: they can be reused inside any organization and are never routed on the public internet. Your home network almost certainly uses one of them right now.

  • 10.0.0.0/8 — 10.0.0.0 to 10.255.255.255. Around 16.7 million addresses; used by large organizations.
  • 172.16.0.0/12 — 172.16.0.0 to 172.31.255.255. Around 1 million addresses.
  • 192.168.0.0/16 — 192.168.0.0 to 192.168.255.255. Around 65 000 addresses; the home-router default.
  • 169.254.0.0/16 — APIPA. Not a configured private range but a symptom: a host assigns itself one of these when it cannot reach a DHCP server.
NAT
Network Address Translation lets many private addresses share one public address. The router rewrites the source address of outgoing packets to its own public address, records which internal host and port the connection belongs to, and reverses the translation on the way back. It is why your whole house browses the internet through a single public IP.
A 169.254.x.x address is a diagnosis
If a machine shows an address starting 169.254, it never got a DHCP reply. Look at the cable, the switch port, the Wi-Fi association, or the DHCP server itself — but do not waste time on DNS or the gateway, because the host never got that far.

DHCP and static addressing

DHCP hands out addresses automatically. A client broadcasts a discovery, a server offers an address, the client requests it and the server acknowledges — DORA: Discover, Offer, Request, Acknowledge. The lease includes the address, the subnet mask, the default gateway and DNS server addresses, and it expires so that addresses return to the pool. Servers, printers and network equipment usually get static addresses or DHCP reservations instead, because other devices need to find them at a predictable address.

IPv6, briefly

IPv6 uses 128-bit addresses written as eight groups of four hex digits, for example 2001:0db8:0000:0000:0000:ff00:0042:8329. Runs of zeros can be shortened with a double colon, once per address, giving 2001:db8::ff00:42:8329. The address space is large enough that NAT becomes unnecessary and every device can hold a globally unique address. Adoption has been slow because NAT made IPv4 workable enough for long enough.

Worked examples

Reveal one step at a time and try to beat it to the next line.

Example 1
A host is configured as 192.168.20.77/26. Find the subnet mask, the network address, the broadcast address, and the range of usable host addresses.
Example 2
A department needs 100 hosts on one subnet. What is the smallest CIDR prefix that works, and how many addresses are wasted?
Example 3
Two computers are configured as 192.168.1.10/24 and 192.168.1.200/25. Can they communicate directly? Explain.

Where marks get lost

  • Forgetting to subtract 2 when counting usable hosts.
  • Assigning the network address or broadcast address to a device.
  • Assuming two addresses on the same first three octets are on the same subnet. The mask decides, not the digits.
  • Reading /26 as "26 hosts". It is 26 network bits, leaving 6 host bits and 62 usable addresses.
  • Trying to fix a 169.254 address by changing DNS settings. It means DHCP never replied at all.
  • Writing a subnet mask with non-contiguous 1s, such as 255.255.0.255. Masks are always 1s then 0s.

Flashcards 10

How many bits in an IPv4 address?
Usable hosts formula
Mask for /26
How do you find the network address?
+ 6 more

Practice

1
How many usable host addresses does a /27 subnet provide?
2
What is the network address of the host 10.4.7.200/24?
3
What is the broadcast address for the subnet 192.168.5.64/26?
4
A laptop shows the address 169.254.12.88. What does this indicate?
5
Which address is NOT usable as a host address on the subnet 172.16.8.0/24?
6
A subnet must hold at least 500 hosts. What is the smallest number of host bits required?
bits
7
Why do private IP ranges exist?
8
Put the DHCP process in order.
  1. 1Server sends Offer
  2. 2Server sends Acknowledge
  3. 3Client sends Request
  4. 4Client broadcasts Discover
9
Match each prefix to its subnet mask.
/24
/25
/26
/28
10
Two hosts are 10.1.1.5/24 and 10.1.2.5/24 with no router between them. Can they communicate?

Spot a mistake on this page? Let us know