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.
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.
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.
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.
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.
| Class | Range | Default Mask | CIDR | Max Hosts | Use 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 |
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.
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.
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.
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.
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.
| TCP/IP Layer | OSI Equivalent | Protocols | Linux 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 |