CompTIA Review

Network+ · Chapter 8

IP Subnetting, Troubleshooting IP, and NAT

Why you subnet, default masks and CIDR, the big five subnetting questions, worked /25 example, Class C mask table, classful vs classless and VLSM, the /30 WAN mask, and an introduction to NAT and PAT.

Exam objectives covered

  • Domain 1.0 Networking Concepts, 1.4: explain common networking ports, protocols, services, and traffic types. Traffic types are unicast, multicast, anycast, and broadcast.
  • Domain 1.0 Networking Concepts, 1.7: use appropriate IPv4 network addressing. This covers public vs. private (APIPA, RFC 1918, loopback/localhost), subnetting (VLSM and CIDR), and IPv4 address classes A to E.
  • Domain 2.0 Network Implementation, 2.1: explain characteristics of routing technologies, including address translation with NAT and port address translation (PAT).

Why you subnet

  • Add a router to a physical network and you have an internetwork. The hosts on it must now have a logical network addressing scheme to communicate.
  • IPv6 could be used, but IPv4 is still the most popular, and it is what this chapter covers.
  • The key to understanding subnetting is understanding the very reason you need to do it. Subnetting splits one network into smaller networks, so each segment on a router gets its own network ID.

Default subnet masks and CIDR notation

ClassFormatDefault subnet maskCIDR
Anetwork.host.host.host255.0.0.0/8
Bnetwork.network.host.host255.255.0.0/16
Cnetwork.network.network.host255.255.255.0/24
  • CIDR notation writes how many bits of the mask are turned on, after a slash. 255.255.255.0 has 24 bits on, so it is /24.
  • The network ID is the part of the address covered by the mask. The host ID is the rest.

The big five subnetting questions

  • 1. How many subnets? 2 to the power of the number of subnet bits (mask bits turned on in the interesting octet). For 255.255.255.128 that is 1 bit, so 2^1 = 2.
  • 2. How many hosts per subnet? 2 to the power of the host bits, minus 2. For /25 there are 7 host bits, so 2^7 - 2 = 126. The 2 removed are the subnet address (all host bits off) and the broadcast address (all host bits on).
  • 3. What are the valid subnets? Block size = 256 minus the mask value in the interesting octet. 256 - 128 = 128. Start at zero and count in the block size: 0, 128.
  • 4. What is the broadcast address of each subnet? The number right before the next subnet, with all host bits turned on. The next subnet after 0 is 128, so the broadcast of the 0 subnet ends in 127.
  • 5. What are the valid hosts? The numbers between the subnet address and its broadcast address.

Write the subnet address and the broadcast address first. The valid hosts are then obvious: everything in between.

Worked example: 192.168.10.0 /25

Network address 192.168.10.0 with subnet mask 255.255.255.128 (/25). The number 128 is 10000000 in binary, so 1 bit is used for subnetting and 7 bits are left for hosts.

ItemSubnet 0Subnet 128
Subnet address192.168.10.0192.168.10.128
First host192.168.10.1192.168.10.129
Last host192.168.10.126192.168.10.254
Broadcast192.168.10.127192.168.10.255

/25 on a Class C gives 2 subnets with 126 hosts each. Subnets: 0 and 128. Broadcasts: 127 and 255.

Class C masks at a glance

The same five steps work for every Class C mask. Compare each row with the /25 example.

MaskCIDRSubnet bitsBlock sizeSubnetsHosts per subnet
255.255.255.0/2402561254
255.255.255.128/2511282126
255.255.255.192/26264462
255.255.255.224/27332830
255.255.255.240/284161614
255.255.255.248/2958326
255.255.255.252/3064642

Quick check: subnets times block size always equals 256 in a Class C network.

Classful, classless, and VLSM

  • A classful network uses the same subnet mask on every host and router interface.
  • Classless routing lets you use different size masks in the same network. Giving each link a mask that fits its need is called variable length subnet masking (VLSM).
  • CIDR (classless inter-domain routing) is the slash notation used to write those masks, such as /25 or /30.

Real world: the /30 mask for WAN links

  • Scenario: you administer Acme Corporation in San Francisco with dozens of WAN links to the corporate office. Every host and router interface uses the same mask, and you must pick a mask for point-to-point links.
  • A /24 (255.255.255.0) gives each WAN network 254 hosts, but a WAN link uses only 2 addresses. That wastes 252 addresses per link.
  • A /30 (255.255.255.252) leaves 2 host bits, so 2^2 - 2 = 2 hosts per subnet. That is exactly enough for the two ends of a link, and no precious addresses are wasted.

Point-to-point WAN links: use 255.255.255.252 (/30). Two usable hosts, nothing wasted.

Introduction to NAT and PAT

  • Network address translation (NAT) is introduced at the end of the chapter, with the difference between static NAT, dynamic NAT, and NAT overloading, which is port address translation (PAT).
  • Static NAT: a fixed one-to-one mapping between an inside address and a public address.
  • Dynamic NAT: inside addresses are mapped to public addresses taken from a pool as they are needed.
  • NAT overloading (PAT): many inside hosts share a single public address, and the translating device tells their conversations apart by port number.

NAT overloading and PAT are the same thing. The chapter lists both names, and the exam objectives use PAT.

Exercise 8.1: Examine your IP address and subnet mask

  • Open a command prompt (Start, type cmd, press Enter).
  • Type ipconfig /all and note the IP address and subnet mask. On Linux or macOS the command is ifconfig.
  • Count how many bits your subnet mask uses and write it in CIDR notation.
  • Identify the network ID portion of your IP address and write it down.
  • Identify the host ID portion of the IP address and write it down.
  • Identify the class of the address by examining the first octet.
  • Compare the mask with the class: you should know the network the host belongs to and its CIDR notation.

Exam essentials

  • Know the default masks: Class A 255.0.0.0, Class B 255.255.0.0, Class C 255.255.255.0.
  • Answer the big five for any mask: subnets, hosts per subnet, valid subnets, broadcast of each, valid hosts.
  • Hosts per subnet is 2^h - 2. Block size is 256 minus the interesting octet.
  • Use /30 (255.255.255.252) for point-to-point WAN links.
  • Be able to find valid IP addresses and subnet masks by reading a network diagram.
  • Know the difference between static NAT, dynamic NAT, and NAT overloading (PAT).