CHAPTER 9 — PRESENTATION

The IPv4 Protocol

Master the TCP/IP stack, IP addressing, subnetting, CIDR notation, and routing table management. Learn to configure gateways and routes using the ip command on Linux.

Slide 1 — IPv4 Overview & Address Structure

What Is IPv4?

IPv4 (Internet Protocol version 4) is the fourth version of the Internet Protocol — the fundamental communications protocol for routing traffic across networks. It uses 32-bit addresses written as four decimal octets separated by dots (dotted-decimal notation).

Every device that communicates on an IP network requires three things: an IP address, a subnet mask, and (for off-network communication) a default gateway.

IP Address Anatomy: 192.168.5.69/24

192
11000000
NETWORK
.
168
10101000
NETWORK
.
5
00000101
NETWORK
.
69
01000101
HOST

With a /24 subnet mask (255.255.255.0), the first three octets identify the network and the last octet identifies the host. All devices in the 192.168.5.0/24 network can communicate directly without a router.

BINARY CONVERSION: 69

Bit positions: 128 + 64 + 32 + 16 + 8 + 4 + 2 + 1. The value 69 = 64 + 4 + 1 = 01000101 in binary. Each octet ranges from 0 (00000000) to 255 (11111111). IP routers convert to binary to perform AND operations with the subnet mask.

Slide 2 — Subnet Masks & the AND Operation

How ANDing Extracts the Network ID

To determine if two devices are on the same network, routers perform a bitwise AND of the IP address with the subnet mask. Where the mask has 255, the network bits pass through. Where the mask has 0, the host bits are zeroed out — revealing the network ID.

# Example: Is 192.168.5.100 on the same network as 192.168.5.69? # Device A: IP: 192.168.5.69 = 11000000.10101000.00000101.01000101 Mask: 255.255.255.0 = 11111111.11111111.11111111.00000000 AND: 192.168.5.0 = 11000000.10101000.00000101.00000000 # Device B: IP: 192.168.5.100 = 11000000.10101000.00000101.01100100 Mask: 255.255.255.0 = 11111111.11111111.11111111.00000000 AND: 192.168.5.0 = 11000000.10101000.00000101.00000000 # Both produce network ID 192.168.5.0 → same network → direct communication
Slide 3 — IPv4 Address Classes

Classful Addressing (Legacy but Still Tested)

ClassRangeDefault MaskCIDRMax HostsUse Case
A 1.0.0.0 – 126.255.255.255 255.0.0.0 /8 16,777,214 ISPs, large enterprises
B 128.0.0.0 – 191.255.255.255 255.255.0.0 /16 65,534 Universities, mid-size orgs
C 192.0.0.0 – 223.255.255.255 255.255.255.0 /24 254 Small networks, LANs
D 224.0.0.0 – 239.255.255.255 N/A N/A N/A Multicast groups
E 240.0.0.0 – 254.255.255.255 N/A N/A N/A Reserved / Experimental

Special IPv4 Addresses

Reserved/Special Addresses

127.0.0.1 — Loopback address. Traffic sent here stays on the local machine. Used for testing the TCP/IP stack.

0.0.0.0 — Represents "all networks" or "any address." Used in routing and as a source address for DHCP.

255.255.255.255 — Limited broadcast. Sent to all hosts on local network. Not routed.

Private Address Ranges (RFC 1918)

10.0.0.0/8 — Class A private (10.0.0.0 – 10.255.255.255)

172.16.0.0/12 — Class B private (172.16.0.0 – 172.31.255.255)

192.168.0.0/16 — Class C private (192.168.0.0 – 192.168.255.255)

Private addresses require NAT to reach the internet.

Slide 4 — CIDR Notation & Subnetting

CIDR — Classless Inter-Domain Routing

CIDR notation expresses the subnet mask as the number of network bits after a slash: 192.168.1.0/24 means 24 bits are network bits (equivalent to mask 255.255.255.0). CIDR enables flexible subnetting without being bound to class boundaries.

# Common CIDR masks and their properties: /8 → 255.0.0.0 → 16,777,214 hosts (Class A) /16 → 255.255.0.0 → 65,534 hosts (Class B) /24 → 255.255.255.0 → 254 hosts (Class C) /25 → 255.255.255.128 → 126 hosts (half a /24) /26 → 255.255.255.192 → 62 hosts (quarter of /24) /27 → 255.255.255.224 → 30 hosts /28 → 255.255.255.240 → 14 hosts /30 → 255.255.255.252 → 2 hosts (point-to-point links) # Host count formula: 2^(host bits) - 2 # Subtract 2 for network address and broadcast address # Subnetting example: 3.0.0.0/8 → borrow 4 bits → /12 # New mask: 255.240.0.0 (/12) # Hosts per subnet: 2^20 - 2 = 1,048,574 # First subnet: 3.0.0.1 – 3.15.255.254 (network: 3.0.0.0, broadcast: 3.15.255.255) # Second subnet: 3.16.0.1 – 3.31.255.254
Slide 5 — Routing Tables & Default Gateway

Understanding the Linux Routing Table

The routing table tells the kernel where to send packets. Each entry matches a destination network to a gateway (next-hop router) and an outgoing interface. The default route (0.0.0.0/0) catches all traffic not matched by more specific routes.

# View the routing table ip route show ip route # shorthand route -n # legacy command (requires net-tools) # Example ip route output: # default via 192.168.1.1 dev enp0s3 proto dhcp src 192.168.1.100 # 192.168.1.0/24 dev enp0s3 proto kernel scope link src 192.168.1.100 # Add default gateway (persistent via netplan/NM; temporary with ip) sudo ip route add default via 192.168.1.1 # Add a specific route (e.g., reach 10.0.0.0/8 via VPN gateway) sudo ip route add 10.0.0.0/8 via 192.168.1.254 # Delete a route sudo ip route del default via 192.168.1.1 # Verify which route a packet will take to a destination ip route get 8.8.8.8
GATEWAY RULE

The default gateway must be on the same subnet as the device. A machine on 192.168.1.0/24 cannot use 10.0.0.1 as its gateway — the router must be reachable directly on the local network (192.168.1.1, 192.168.1.254, etc.). Misconfigured gateways are one of the most common networking errors.

Slide 6 — The TCP/IP Stack

Four-Layer Model vs OSI Seven-Layer Model

TCP/IP LayerOSI EquivalentProtocolsLinux Commands
Application Application / Presentation / Session HTTP, SSH, DNS, FTP, SMTP curl, wget, ssh, dig
Transport Transport TCP (reliable), UDP (fast) ss, netstat, nc
Internet Network IPv4, IPv6, ICMP, ARP ip route, ping, traceroute
Link Data Link / Physical Ethernet, Wi-Fi, ARP ip link, ethtool, iwconfig
# Useful diagnostic commands by layer: # Link layer: verify physical interface ip link show ethtool enp0s3 # speed, duplex, link status # Internet layer: IP connectivity ping -c 4 192.168.1.1 # ICMP echo ip route get 8.8.8.8 # routing path # Transport layer: open connections and listening ports ss -tulnp # sockets: TCP/UDP listening/established # Application layer: name resolution dig google.com # detailed DNS query nslookup google.com # simple DNS lookup

Chapter 9 Complete

Mark this presentation complete to record your progress and unlock the quiz.

Progress saved. Head to the quiz to test your knowledge.