Documentation Index
Fetch the complete documentation index at: https://resources.devweekends.com/llms.txt
Use this file to discover all available pages before exploring further.
Module 9: IP Addressing Deep Dive
This module takes you from basic IP understanding to complete mastery. You’ll learn to calculate subnets, understand CIDR notation, and deeply grasp how IP addressing works in real networks. Think of IP addressing like the postal addressing system for the entire internet. Just as a mailing address has a country, city, street, and house number — each narrowing down the location — an IP address has a network portion and a host portion that do the same thing for data. CIDR notation is the system that defines where the “city” ends and the “street address” begins.Difficulty: Intermediate
Prerequisites: Module 4 (Network Layer basics)
9.1 The Complete Picture of IP Addresses
What is an IP Address Really?
An IP address is a logical address assigned to a device on a network. Unlike MAC addresses (which are burned into hardware), IP addresses are:- Configurable: Can be changed
- Hierarchical: Contain network and host portions
- Routable: Used to find paths across networks
IPv4 Address Structure
A 32-bit number, typically shown in dotted-decimal notation:9.2 Network ID vs Host ID
Every IP address has two parts:| Part | Purpose | Analogy |
|---|---|---|
| Network ID | Identifies the network | Street name |
| Host ID | Identifies the specific device | House number |
Example
9.3 CIDR Notation Explained
CIDR (Classless Inter-Domain Routing) replaced the old class-based system. It uses a prefix length to indicate how many bits belong to the network portion.The Notation
Common CIDR Blocks
| CIDR | Subnet Mask | # of Hosts | Use Case |
|---|---|---|---|
| /32 | 255.255.255.255 | 1 | Single host |
| /31 | 255.255.255.254 | 2 | Point-to-point links |
| /30 | 255.255.255.252 | 2 | Point-to-point (with network/broadcast) |
| /29 | 255.255.255.248 | 6 | Tiny subnet |
| /28 | 255.255.255.240 | 14 | Small subnet |
| /27 | 255.255.255.224 | 30 | Small office |
| /26 | 255.255.255.192 | 62 | Medium subnet |
| /25 | 255.255.255.128 | 126 | Large subnet |
| /24 | 255.255.255.0 | 254 | Standard LAN |
| /16 | 255.255.0.0 | 65,534 | Large organization |
| /8 | 255.0.0.0 | 16,777,214 | Massive network |
Calculating Hosts
Practical scenario: choosing the right CIDR block
Suppose you are designing a VPC for a startup. You need subnets for web servers (20 instances max), application servers (50 instances max), and databases (5 instances max). Here is how to think through it:9.4 Subnetting Step-by-Step
Problem: Divide 192.168.1.0/24 into 4 equal subnets
Step 1: Determine bits needed| Subnet | Network Address | First Host | Last Host | Broadcast |
|---|---|---|---|---|
| 1 | 192.168.1.0/26 | 192.168.1.1 | 192.168.1.62 | 192.168.1.63 |
| 2 | 192.168.1.64/26 | 192.168.1.65 | 192.168.1.126 | 192.168.1.127 |
| 3 | 192.168.1.128/26 | 192.168.1.129 | 192.168.1.190 | 192.168.1.191 |
| 4 | 192.168.1.192/26 | 192.168.1.193 | 192.168.1.254 | 192.168.1.255 |
Quick Subnet Cheat Sheet
For /24 networks being subnetted:| New Prefix | Subnets | Hosts/Subnet | Block Size |
|---|---|---|---|
| /25 | 2 | 126 | 128 |
| /26 | 4 | 62 | 64 |
| /27 | 8 | 30 | 32 |
| /28 | 16 | 14 | 16 |
| /29 | 32 | 6 | 8 |
| /30 | 64 | 2 | 4 |
9.5 Private vs Public IP Addresses
The Problem
There are only ~4.3 billion IPv4 addresses (2^32), but billions of devices need to connect.The Solution: Private IP Ranges
RFC 1918 reserved three blocks for private use:| Range | CIDR | # of Addresses | Typical Use |
|---|---|---|---|
| 10.0.0.0 - 10.255.255.255 | 10.0.0.0/8 | 16,777,216 | Large enterprises, Cloud VPCs |
| 172.16.0.0 - 172.31.255.255 | 172.16.0.0/12 | 1,048,576 | Medium organizations |
| 192.168.0.0 - 192.168.255.255 | 192.168.0.0/16 | 65,536 | Home/Small office |
Key Rules
Private IPs
- Not routable on the public internet
- Can be reused by any organization
- Need NAT to reach the internet
- Free to use, no registration needed
Public IPs
- Globally unique and routable
- Assigned by IANA → RIRs → ISPs
- Must be purchased/leased
- Required for internet-facing services
Can Multiple Organizations Use the Same Private IP?
Yes! This is exactly the point. Consider:192.168.1.5 internally, but that’s fine because:
- Private IPs never leave their local network
- NAT translates them to unique public IPs before packets hit the internet
- The internet only sees the public IPs
9.6 Special IP Addresses
| Address/Range | Purpose |
|---|---|
| 0.0.0.0 | ”This network” / Default route |
| 127.0.0.0/8 | Loopback (localhost) |
| 169.254.0.0/16 | Link-local (APIPA) - when DHCP fails |
| 224.0.0.0/4 | Multicast |
| 255.255.255.255 | Broadcast |
9.7 IPv6 Addressing
Why IPv6?
IPv4 has ~4.3 billion addresses. IPv6 has:IPv6 Format
Simplification Rules
-
Leading zeros can be omitted:
-
Consecutive zero groups can be replaced with
::(once per address):
IPv6 Address Types
| Type | Prefix | Description | IPv4 Equivalent |
|---|---|---|---|
| Global Unicast | 2000::/3 | Public, routable | Public IPv4 addresses |
| Link-Local | fe80::/10 | Auto-configured, not routable beyond local segment | 169.254.x.x (APIPA) |
| Unique Local | fc00::/7 | Private, not routable on internet | 10.x.x.x, 172.16.x.x, 192.168.x.x |
| Loopback | ::1 | Localhost | 127.0.0.1 |
fe80::), even without any manual configuration or DHCP. This is useful for neighbor discovery and local communication. However, these addresses cannot be routed beyond the local network segment — for internet connectivity, you need a global unicast address.9.8 Practice Problems
Problem 1: Given 10.0.0.0/8, how many /24 networks can you create?
Problem 1: Given 10.0.0.0/8, how many /24 networks can you create?
Problem 2: What subnet does 172.16.45.130/26 belong to?
Problem 2: What subnet does 172.16.45.130/26 belong to?
Problem 3: Design subnets for an office with 3 departments
Problem 3: Design subnets for an office with 3 departments
- Engineering: 50 hosts
- Sales: 20 hosts
- HR: 10 hosts
- Starting block: 192.168.10.0/24
| Dept | Hosts Needed | Subnet Size | CIDR | Range |
|---|---|---|---|---|
| Engineering | 50 | /26 (62 hosts) | 192.168.10.0/26 | .1 - .62 |
| Sales | 20 | /27 (30 hosts) | 192.168.10.64/27 | .65 - .94 |
| HR | 10 | /28 (14 hosts) | 192.168.10.96/28 | .97 - .110 |
9.9 Key Takeaways
CIDR is Essential
Private IPs are Infinite
Always Plan for Growth
IPv6 is Coming
Next Module
Module 10: NAT & PAT Deep Dive
Interview Deep-Dive
You are designing the network for a new AWS VPC that will host 500 microservices. How do you plan your CIDR blocks and subnet strategy?
You are designing the network for a new AWS VPC that will host 500 microservices. How do you plan your CIDR blocks and subnet strategy?
- I would start with a large VPC CIDR like 10.0.0.0/16, providing 65,534 usable addresses with room for growth. The most common mistake is choosing a /24 “because we only have 10 servers today” and running out within a year.
- For subnet strategy, I create at least three tiers across multiple AZs: public subnets (load balancers, bastion hosts), private application subnets (microservices), and private data subnets (databases). Each tier gets a /20 or /19 per AZ. With 3 AZs and 3 tiers, that is 9 subnets with thousands of IPs each.
- I account for AWS’s 5-address reservation per subnet. A /24 in AWS gives 251 usable IPs, not 254. For microservices on EKS with VPC CNI, each node consumes multiple addresses (one per pod), so a /24 can be exhausted with just 15 nodes running 40 pods each.
- I ensure the VPC CIDR does not overlap with any other VPCs that might need peering, on-premises networks via VPN, or third-party networks. I coordinate ranges centrally: 10.1.0.0/16 for production, 10.2.0.0/16 for staging, 10.3.0.0/16 for dev.
Given 172.16.45.130/26, tell me the network address, broadcast address, and usable range. Walk through your calculation.
Given 172.16.45.130/26, tell me the network address, broadcast address, and usable range. Walk through your calculation.
- A /26 means 26 network bits and 6 host bits. Block size is 2^6 = 64 addresses per subnet. Subnets start at multiples of 64: .0, .64, .128, .192.
- 172.16.45.130 falls in the .128 block (130 is between 128 and 191). Network address: 172.16.45.128/26.
- Broadcast address: 172.16.45.128 + 64 - 1 = 172.16.45.191.
- Usable range: 172.16.45.129 through 172.16.45.190, giving 62 usable hosts.
- Subnet mask: 255.255.255.192 (last octet: 128 + 64 = 192).
- My shortcut: divide the host octet by the block size and take the floor. 130 / 64 = 2.03, floor 2, start at 2 x 64 = 128.
What is the significance of 0.0.0.0, 127.0.0.1, and 169.254.169.254? When would you encounter each in production?
What is the significance of 0.0.0.0, 127.0.0.1, and 169.254.169.254? When would you encounter each in production?
- 0.0.0.0 has two meanings. In routing, 0.0.0.0/0 is the default route matching everything. In socket binding, it means “listen on all interfaces.” Binding to 0.0.0.0:8080 accepts connections on every network interface. A common “works locally” bug is binding to 127.0.0.1 — reachable locally but invisible from other machines.
- 127.0.0.1 (and the entire 127.0.0.0/8 range) is the loopback address. Traffic never leaves the kernel’s network stack. Used for local IPC, testing, and same-host service communication. The full /8 is reserved — 127.0.0.2 also loops back, which some apps use to distinguish local services.
- 169.254.0.0/16 is the link-local (APIPA) range. Devices self-assign from this range when DHCP fails. Not routable across routers. In AWS, 169.254.169.254 is the instance metadata service (IMDS) endpoint — every EC2 instance queries it for IAM role credentials, instance identity, and user data.
http://169.254.169.254/latest/meta-data/iam/security-credentials/role-name and steal temporary AWS credentials. This was the exact vector in the 2019 Capital One breach — SSRF through a misconfigured WAF yielded IAM credentials that unlocked S3 buckets with customer data. The defense is IMDSv2, which requires a session token from a PUT request before metadata access. Since SSRF typically only supports GET, IMDSv2 blocks this vector. Always enforce IMDSv2 and disable IMDSv1.