In one minute
- The basics of how computers find each other: IP addresses (a machine's address), subnets (a block of addresses), CIDR (a short way to write a block, like
10.0.1.0/24) and ports (which program on the machine). - Every DevOps task ends up as a network question. Why can't the app reach the database? Which subnet should this server go in? Why does the Kubernetes network clash with the office VPN?
- Data is sent in small packets. Each packet carries the address of the machine it is going to (the IP) and the program it is for (the port). Routers pass packets along until they arrive.
- 👉 Designing a cloud network, writing firewall or security group rules, and fixing "can't connect" problems.
Think of it like: posting a letter to a big apartment building. The IP is the building's street address. The port is the flat number. A subnet is one street, with all the buildings on it.
The layers, in practice
Networking is built in layers. Each layer does one job and relies on the layer below it.
When something breaks, knowing the layer tells you which tool to use and where to look.
👉 Troubleshooting. Start at the bottom and work up.
| Layer | What it handles | Examples | Tools to check it |
|---|---|---|---|
| 7 Application | The actual conversation | HTTP, DNS, SSH, gRPC | curl, dig |
| 4 Transport | Ports and reliable delivery | TCP, UDP | ss, nc |
| 3 Network | IP addresses and finding the way (routing) | IPv4, IPv6, ICMP | ip route, ping, traceroute |
| 2 Data link | Delivery on the local network by hardware (MAC) address | Ethernet, ARP | ip neigh |
| 1 Physical | Cables, Wi-Fi, virtual network cards | ip link |
Check from the bottom up: Is the network card up? Does it have an IP? Is there a route? Is the port open? Does the app answer?
Remember it: You do not need all seven OSI layers. Know 3 = IP, 4 = port, 7 = app.
IPv4 addresses
An IPv4 address is four numbers from 0 to 255, separated by dots. Under the hood it is 32 bits.
10.0.1.2500001010.00000000.00000001.00011001Each number is 8 bits, called an octet. That makes about 4.3 billion addresses in total. That is not enough for the whole world, which is why private ranges and NAT exist.
Private ranges
Three ranges are reserved for private networks. They are never used on the public internet.
👉 Every cloud network (VPC), home network and Kubernetes cluster uses them.
| Range | CIDR | Size | Typical use |
|---|---|---|---|
| 10.0.0.0 – 10.255.255.255 | 10.0.0.0/8 | 16.7 million | AWS VPCs, company networks |
| 172.16.0.0 – 172.31.255.255 | 172.16.0.0/12 | 1 million | Docker's default networks |
| 192.168.0.0 – 192.168.255.255 | 192.168.0.0/16 | 65,536 | Home routers |
Remember it: Private starts with 10, 172.16–31 or 192.168.
Other special addresses:
| Address | Meaning |
|---|---|
127.0.0.1 | Loopback: this machine itself (localhost) |
0.0.0.0 | "Every network card", when a server listens on it |
169.254.169.254 | The cloud's metadata service on AWS, Azure and GCP |
100.64.0.0/10 | Used by some internet providers and some Kubernetes networks |
Subnets and CIDR
A subnet is a block of addresses that sit together. CIDR writes it as address/number.
The number after the slash says how many bits are fixed (the network part). The bits left over are for machines (hosts).
10.0.1.0/24network part: first 24 bits (10.0.1)host part: last 8 bits (0 – 255)The formula: number of addresses = 2 to the power of (32 − the number).
| CIDR | Netmask | Addresses | Common use |
|---|---|---|---|
/32 | 255.255.255.255 | 1 | One single machine in a firewall rule |
/28 | 255.255.255.240 | 16 | Smallest AWS subnet |
/24 | 255.255.255.0 | 256 | A typical subnet |
/20 | 255.255.240.0 | 4,096 | A large subnet (Kubernetes nodes and pods) |
/16 | 255.255.0.0 | 65,536 | A whole VPC |
/8 | 255.0.0.0 | 16.7 million | The entire 10.x range |
/0 | 0.0.0.0 | Everything | "Anywhere" in security groups |
Remember it: Smaller number = bigger network. The slash number is how much is locked. Lock less, get more. A
/16is 256 times bigger than a/24.
In every subnet, the first address names the network and the last is the broadcast address. So a /24 has 254 usable addresses. AWS keeps 5 for itself (the first four and the last one), leaving 251.
Worked example: is this IP in that subnet?
Is 10.0.1.200 inside 10.0.1.0/25?
/25gives 2⁷ = 128 addresses:10.0.1.0to10.0.1.127.- 200 is bigger than 127, so no. It belongs to the next block,
10.0.1.128/25.
You will do this in your head when reading security group rules and route tables.
Worked example: splitting a VPC
You get 10.20.0.0/16 for a new VPC. You need public and private subnets in three availability zones. Splitting it into /20 blocks gives 16 subnets of 4,096 addresses each:
| Subnet | CIDR | Range |
|---|---|---|
| public-a | 10.20.0.0/20 | 10.20.0.0 – 10.20.15.255 |
| public-b | 10.20.16.0/20 | 10.20.16.0 – 10.20.31.255 |
| public-c | 10.20.32.0/20 | 10.20.32.0 – 10.20.47.255 |
| private-a | 10.20.48.0/20 | 10.20.48.0 – 10.20.63.255 |
| private-b | 10.20.64.0/20 | 10.20.64.0 – 10.20.79.255 |
| private-c | 10.20.80.0/20 | 10.20.80.0 – 10.20.95.255 |
Notice that each block starts 16 higher in the third number (0, 16, 32...). That leaves room for ten more subnets later. You will write this exact layout in Terraform in the AWS course.
Do not let ranges overlap
Networks that need to connect (VPC peering, VPN, Transit Gateway) must not overlap. If two teams both pick 10.0.0.0/16, they can never be connected without renumbering everything. Keep one company-wide IP plan.
Seeing your addresses: ip addr
👉 "What is this machine's IP, and which network is it on?"
ip addrip -br addrlo UNKNOWN 127.0.0.1/8eth0 UP 10.0.1.25/24docker0 DOWN 172.17.0.1/16This machine is 10.0.1.25 in a /24, so its local network is 10.0.1.0 to 10.0.1.255.
Ports and protocols
The IP finds the machine. A port (a number from 0 to 65535) finds the program on that machine.
| Port | Service |
|---|---|
| 22 | SSH |
| 53 | DNS (UDP and TCP) |
| 80 / 443 | HTTP / HTTPS |
| 3306 / 5432 | MySQL / PostgreSQL |
| 6379 | Redis |
| 6443 | Kubernetes API server |
| 8080 | Common app port |
| 9090 / 3000 | Prometheus / Grafana |
| 30000–32767 | Kubernetes NodePort range |
TCP or UDP? These are the two ways to send data:
| TCP | UDP | |
|---|---|---|
| Connection | Says hello first (a 3-step handshake: SYN, SYN-ACK, ACK) | Just sends |
| Delivery | Reliable, in order, re-sends lost packets | Best effort, no re-sending |
| Used by | Websites, SSH, databases | DNS lookups, metrics, video calls |
Think of it like: TCP is a phone call (you connect first and confirm you heard). UDP is shouting across a room (fast, but nobody checks).
Ports below 1024 need root to listen on. That is why apps often listen on 8080, with a proxy on port 80 in front.
NAT in one paragraph
NAT (Network Address Translation) lets private machines reach the internet.
Private addresses cannot travel on the internet. So a NAT device swaps the private address for a public one on the way out, and swaps it back on the way in.
Where you meet it: In AWS, servers in private subnets reach the internet through a NAT gateway. Servers in public subnets use an internet gateway and their own public IP. Docker uses NAT too: containers on 172.17.0.0/16 reach out through the host's address.
IPv6 essentials
IPv6 addresses are 128 bits, written in hex: 2001:db8:12::25/64. There are so many that NAT is rarely needed. The loopback is ::1. Cloud providers and Kubernetes increasingly support IPv4 and IPv6 together ("dual-stack"). Learn to recognise the format, even if you mostly use IPv4.
Real-world scenario: the app cannot reach the database
The app on 10.20.48.15 times out when connecting to the database on 10.20.64.30:5432. Check from the bottom up:
ip -br addrip routeping -c 2 10.0.2.10ss -tn- The network card is up, with the expected IP.
- Both addresses are inside the VPC's
10.20.0.0/16, so the VPC's local route covers them. pingmay be blocked by security groups, so test the real port (next lesson, withncorcurl).- The cause: the database security group allows
10.20.48.0/24, but the app subnet is10.20.48.0/20. Servers above.48.255are left out. Fixing the CIDR fixes the outage.
Common mistakes
- Getting the size backwards, thinking
/28is bigger than/24. - Opening
0.0.0.0/0(the whole internet) on a database port "just for now". - Overlapping ranges between VPCs, Docker networks and VPNs.
- Forgetting reserved addresses and running out of IPs in small subnets. This happens a lot with EKS, where every pod takes a VPC IP.
Practice
- How many addresses are in a
/26? A/22? - Is
172.20.5.9a private address? Which range? - Is
10.0.1.130inside10.0.1.0/25? - Split
10.50.0.0/16into four equal subnets and write their CIDRs. - Run
ip -br addrand say which network the machine is on.
Cheat sheet
| Fact | Value |
|---|---|
| Addresses in a /n | 2 to the power of (32 − n) |
| /24 | 256 addresses, mask 255.255.255.0 |
| /16 | 65,536 addresses |
| Private ranges | 10/8, 172.16/12, 192.168/16 |
| Loopback | 127.0.0.1 and ::1 |
| Show IPs | ip -br addr |
Key takeaways
- An IP address finds the machine. A port finds the program on it.
- A subnet is a block of addresses, written like
10.0.1.0/24. - The smaller the number after the slash, the bigger the network.
- Private networks use 10.x, 172.16–31.x or 192.168.x.
- TCP is careful and reliable. UDP is fast and does not check.