Week 1 · Lesson 7

IPv4 and Subnet Mask

This is where the pieces lock together. A device finds its network by performing a bitwise AND between its address and its mask. In this lesson you do that arithmetic by hand, extract the network and broadcast addresses, and then prove it on a full set of practice problems and exam-style questions.

CCNA 200-301 Domain 1.6 · IPv4 Addressing Verified 2026-10-11
Part 1

The AND operation

AND is a boolean (logic) operation on two bits. Its rule is simple: the result is 1 only when both input bits are 1; otherwise the result is 0.

Learning objectives. By the end of this lesson you can: state the AND truth table and apply it bit by bit; compute the network address as IP AND mask; find the broadcast address and the usable host range; work correctly with masks that are not 255 or 0 (for example /26 and /27); and solve practice and exam-style multiple-choice questions with confidence.
Bit ABit BA AND B
000
010
100
111

AND is applied column by column across all 32 bits. This matters because a mask bit of 1 passes through the corresponding address bit unchanged (x AND 1 = x), while a mask bit of 0 clears it (x AND 0 = 0). So the network bits survive and the host bits are zeroed out — which is precisely how the network address is born.

Shortcut. When a mask octet is 255, the result octet equals the address octet (it passes through). When a mask octet is 0, the result octet is 0. You only need full binary AND for a mask octet that is neither 255 nor 0 (for example 192, 224, or 240).
Octet AND calculator · set two octets

Part 2

Network address = IP AND mask

Definition. The network address is what you get when you AND the host IP address with the subnet mask, bit by bit. The result has all host bits cleared to 0, so it identifies the subnet.
Place values:  128 64 32 16  8  4  2  1

  192 :        1  1  0  0  0  0  0  0    (11000000)
  AND
  255 :        1  1  1  1  1  1  1  1    (11111111)
  =
  192 :        1  1  0  0  0  0  0  0    (11000000)   -> network bit passes through

   45 :        0  0  1  0  1  0  1  0    (00101010)
  AND
    0 :        0  0  0  0  0  0  0  0    (00000000)
  =
    0 :        0  0  0  0  0  0  0  0    (00000000)   -> host bit cleared

Read the two examples together: every address bit under a mask 1 is kept, and every bit under a mask 0 becomes 0. That is the whole mechanism.

Bitwise AND, octet by octet · type an address and set the prefix

Part 3

Worked examples

Three examples, from easy to the tricky one. Work each through before reading the answer underneath it.

Worked example 1 — /24

Question: what is the network address of 192.168.10.45 with mask 255.255.255.0?

IP   : 11000000.10101000.00001010.00101010    (192.168.10.45)
Mask : 11111111.11111111.11111111.00000000    (255.255.255.0)
AND  : 11000000.10101000.00001010.00000000    (192.168.10.0)
OctetIPMaskResultWhy
1192255192mask = 255, pass through
2168255168mask = 255, pass through
31025510mask = 255, pass through
44500mask = 0, cleared

Network = 192.168.10.0. The host part is 45; the broadcast is 192.168.10.255, and the usable range is 192.168.10.1–.254.

Worked example 2 — /16

Question: find the network, broadcast and host count for 172.16.20.200/16 (mask 255.255.0.0).

IP   : 10101100.00010000.00010100.11001000    (172.16.20.200)
Mask : 11111111.11111111.00000000.00000000    (255.255.0.0)
AND  : 10101100.00010000.00000000.00000000    (172.16.0.0)

Worked example 3 — /26

Question: what subnet does 192.168.1.100/26 belong to? Here the mask octet is neither 255 nor 0, so we AND in binary.

Mask 255.255.255.192, which is 11111111.11111111.11111111.11000000. Only the last octet needs real bit math:

Place values:  128 64 32 16  8  4  2  1
  100 :          0  1  1  0  0  1  0  0    (01100100)
  AND
  192 :          1  1  0  0  0  0  0  0    (11000000)
  =
   64 :          0  1  0  0  0  0  0  0    (01000000)

So network = 192.168.1.64. The block size is 256 − 192 = 64, so the /26 subnets step by 64: .0, .64, .128, .192. Our host (100) sits in the .64 block, which runs from .64 to .127.

192.168.1.0/26 — four subnets of 64 addresses .0 – .63 .64 – .127 .128 – .191 .192 – .255 192.168.1.100 lands here network .64   broadcast .127 Block size = 256 − 192 = 64. Subnets step by 64. Usable hosts per subnet = 2⁶ − 2 = 62.
With a /26, each subnet holds 64 addresses. The host .100 is in the second subnet, so its network is .64 and its broadcast is .127.
Subnet finder · network, broadcast and host range

Part 4

Finding the broadcast address

Once you have the network address and the block size, the broadcast is the last address before the next subnet begins. Two reliable methods:

  1. Set all host bits to 1. Take the network address and flip every host bit to 1.
  2. Add block size − 1 to the network address (in the interesting octet).
Exam tip. Block size = 256 − (interesting mask octet). For a /26 the interesting octet is 192, so block size = 64. The network, first host, last host and broadcast of the .64 block are: .64 / .65 / .126 / .127. Learn this four-number pattern — it is what the exam asks for.
Block-size explorer · the four-number pattern

Part 5

Practice problems (with solutions)

Work each one on paper before opening the answer.

P1. Convert 203.0.113.7 to binary.
203 = 11001011; 0 = 00000000; 113 = 01110001; 7 = 00000111. So 11001011.00000000.01110001.00000111.
P2. What class and default mask is 128.10.20.30?
First octet 128 is in 128–191, so Class B; default mask 255.255.0.0 (/16).
P3. Is 172.31.255.254 a private address?
Yes. It lies inside 172.16.0.0/12, which spans 172.16.0.0–172.31.255.255 (RFC 1918). Note 172.32.0.0 would be outside it.
P4. Give the network and broadcast for 10.50.20.130/24.
Mask 255.255.255.0. Network 10.50.20.0; broadcast 10.50.20.255; usable 10.50.20.1–10.50.20.254.
P5. How many usable hosts are in a /27 subnet?
h = 32 − 27 = 5, so 25 − 2 = 30 usable hosts.
P6. AND 192.168.15.200 with 255.255.255.224. Give the network, broadcast, first and last usable host.
Last octet: 200 AND 224. 200 = 11001000, 224 = 11100000, AND = 11000000 = 192. Network 192.168.15.192. Block size = 256 − 224 = 32, so the block ends at .223. Broadcast 192.168.15.223; first host .193; last host .222; usable hosts = 25 − 2 = 30.
P7. Convert 255.255.255.240 to prefix notation and state the usable hosts.
240 = 11110000, so the prefix is /28. h = 4, usable hosts = 24 − 2 = 14.
P8. Is the host 192.0.2.5 routable across the public Internet?
No. 192.0.2.0/24 is RFC 5737 (TEST-NET-1), a documentation block reserved for examples, not for real Internet hosts.
P9. Find the network and broadcast for 172.16.100.25/17 (mask 255.255.128.0).
Third octet AND 128: 100 = 01100100, 128 = 10000000, AND = 0. Network 172.16.0.0. The /17 block spans 172.16.0.0–172.16.127.255, so broadcast = 172.16.127.255. Host bits h = 15, usable hosts = 32,766.
Part 6

Exam-style multiple choice

Choose one answer, then open the item to check.

Q1. How many bits are in an IPv4 address?  A) 8  B) 16  C) 32  D) 64
C) 32. Four octets of 8 bits each.
Q2. Which address is private?  A) 172.15.1.1  B) 172.16.1.1  C) 172.32.1.1  D) 192.169.1.1
B) 172.16.1.1. It is inside 172.16.0.0/12 (RFC 1918); the other three are outside every private block.
Q3. What is 255.255.255.224 in prefix notation?  A) /24  B) /25  C) /27  D) /30
C) /27. 8 + 8 + 8 + 3 = 27.
Q4. How many usable host addresses does a /24 provide?  A) 24  B) 254  C) 255  D) 256
B) 254. 28 − 2 = 254.
Q5. What is the network address of 192.168.10.45 with mask 255.255.255.0?  A) 192.168.10.0  B) 192.168.10.1  C) 192.168.10.45  D) 192.168.10.255
A) 192.168.10.0. The host octet is masked to 0.
Q6. Which block is reserved for loopback?  A) 10.0.0.0/8  B) 127.0.0.0/8  C) 169.254.0.0/16  D) 100.64.0.0/10
B) 127.0.0.0/8. Defined in RFC 1122.
Q7. What is the broadcast address of 192.168.5.0/24?  A) 192.168.5.0  B) 192.168.5.1  C) 192.168.5.254  D) 192.168.5.255
D) 192.168.5.255. All host bits set to 1.
Q8. A host 192.168.1.100/26 belongs to which subnet?  A) 192.168.1.0  B) 192.168.1.64  C) 192.168.1.96  D) 192.168.1.128
B) 192.168.1.64. 100 falls in the .64–.127 block.
Q9. A PC displays the address 169.254.20.5. What is the most likely cause?  A) duplicate address  B) DHCP server unreachable  C) DNS failure  D) wrong subnet mask
B) DHCP server unreachable. The PC self-assigned an APIPA / link-local address (RFC 3927).
Q10. Using 2h − 2 with h = 6 gives:  A) 30  B) 62  C) 64  D) 126
B) 62. 26 = 64, minus 2 = 62.

Key terms

AND

Logical operation returning 1 only when both input bits are 1.

Network address

IP AND mask; all host bits 0; identifies the subnet and is not usable by a host.

Broadcast address

Network address with all host bits set to 1; reaches every host in the subnet.

Block size

256 − (interesting mask octet); the step between consecutive subnets.

Interesting octet

The octet where the mask is neither 255 nor 0, so full binary AND is needed.

Usable range

The addresses between the network address and the broadcast address, inclusive.

Sources & references

  1. Postel, J. RFC 791: Internet Protocol (1981). Address masking and subnet structure.
  2. Braden, R. RFC 1122: Requirements for Internet Hosts — Communication Layers (1989).
  3. Rekhter, Y. et al. RFC 1918: Address Allocation for Private Internets (1996).
  4. Arkko, J., Cotton, M. & Vegoda, L. RFC 5737: IPv4 Address Blocks Reserved for Documentation (2010).
  5. Cotton, M. & Vegoda, L. RFC 5735: Special Use IPv4 Addresses (2010).
  6. Cheshire, S., Aboba, B. & Guttman, E. RFC 3927: Dynamic Configuration of IPv4 Link-Local Addresses (2005).
  7. Weil, J. et al. RFC 6598: IANA-Reserved IPv4 Prefix for Shared Address Space (2012).
  8. IANA. IPv4 Special-Purpose Address Registry.
  9. Cisco. CCNA (200-301) Exam Topics, Network Fundamentals (IP addressing and subnetting).
Part 7 · Your turn

Review

Check what you have learned with these review questions.

Review · 6 questions

Sources

Sources & references

  1. Postel, J. RFC 791: Internet Protocol (1981). Address masking and subnet structure. rfc-editor.org/rfc/rfc791.
  2. Braden, R. RFC 1122: Requirements for Internet Hosts — Communication Layers (1989). rfc-editor.org/rfc/rfc1122.
  3. Rekhter, Y. et al. RFC 1918: Address Allocation for Private Internets (1996). rfc-editor.org/rfc/rfc1918.
  4. Arkko, J., Cotton, M. & Vegoda, L. RFC 5737: IPv4 Address Blocks Reserved for Documentation (2010). rfc-editor.org/rfc/rfc5737.
  5. Cotton, M. & Vegoda, L. RFC 5735: Special Use IPv4 Addresses (2010). rfc-editor.org/rfc/rfc5735.
  6. Cheshire, S., Aboba, B. & Guttman, E. RFC 3927: Dynamic Configuration of IPv4 Link-Local Addresses (2005). rfc-editor.org/rfc/rfc3927.
  7. Weil, J. et al. RFC 6598: IANA-Reserved IPv4 Prefix for Shared Address Space (2012). rfc-editor.org/rfc/rfc6598.
  8. IANA. IPv4 Special-Purpose Address Registry. iana.org.
  9. Cisco. CCNA (200-301) Exam Topics, Network Fundamentals (IP addressing and subnetting). cisco.com.

Target exams: CCNA 200-301 v1.1 · CyberOps Associate 200-201. Last content verification: 2026-10-11.