IP Addressing
& Routing
Understand how devices find each other on the internet using IP addresses, subnets, and routing protocols.
What Is an IP Address?
An IP address (Internet Protocol address) is a unique numerical label assigned to every device connected to a network. Think of it as a home address for your computer: it tells the network where to deliver data.
The IPv4 Address Structure
An IPv4 address consists of 4 octets (groups of 8 bits), separated by dots. Each octet ranges from \(0\) to \(255\), giving a total of \(2^{32}\) possible addresses.
Why IP Addressing Matters
Understanding Subnets
A subnet (subnetwork) divides a larger network into smaller, more manageable segments. A subnet mask determines which bits of the IP address represent the network vs. the host.
The Subnet Mask
A subnet mask is a \(32\)-bit number that separates the network portion from the host portion. A /24 mask means the first \(24\) bits are the network, leaving \(8\) bits for hosts.
IPv4 vs IPv6
| IPv4 | IPv6 | |
|---|---|---|
| Address Size | 32 bits | 128 bits |
| Format | Dotted decimal (192.168.1.1) | Hex with colons (2001:db8::1) |
| Total Addresses | \(2^{32} \approx 4.3 \times 10^9\) | \(2^{128} \approx 3.4 \times 10^{38}\) |
| Security | Optional (IPsec add-on) | Built-in IPsec support |
| Status | Addresses exhausted | Expanding adoption |
Public vs Private IP Addresses
How Routing Works
Routing is the process of selecting the best path for data packets to travel from source to destination across interconnected networks. Routers examine the destination IP and consult their routing table.
The Routing Table
Every router maintains a routing table: a map that lists known network destinations and the best next hop (next router) to reach each one.
| Destination Network | Subnet Mask | Next Hop | Interface |
|---|---|---|---|
| 192.168.1.0 | /24 | Direct | eth0 |
| 10.0.2.0 | /24 | 192.168.1.1 | eth1 |
| 0.0.0.0 | /0 | 203.0.113.1 | eth2 |
Static vs Dynamic Routing
How to Calculate a Subnet
Example 1: A /24 Subnet
Given the address 192.168.5.0/24, find the usable host range and total number of hosts.
Example 2: A /26 Subnet
Given the address 10.0.0.0/26, how many usable hosts and what is the range?
Example 3: Packet Routing in Action
A device at 192.168.1.10 wants to reach 10.0.2.50. Trace the packet's journey:
Common Mistakes
Summary: Key Concepts
| Concept | What It Does | Example |
|---|---|---|
| IP Address | Unique device identifier | 192.168.1.10 |
| Subnet Mask | Separates network from host | 255.255.255.0 (/24) |
| Default Gateway | Router to exit local network | 192.168.1.1 |
| Routing Table | Maps destinations to next hops | 0.0.0.0/0 → ISP router |
| NAT | Shares one public IP for many | Home router |
Question 1 of 5
How many usable host addresses are available in a /24 subnet?
Question 2 of 5
Which of the following is a private IP address range?
Question 3 of 5
What does a router use to decide where to send a packet?
Question 4 of 5
Given the subnet 10.0.0.0/26, what is the broadcast address?
Question 5 of 5
What is the primary advantage of IPv6 over IPv4?