IP Addresses & Ports
How the network finds the right machine, and the right program on it.
To deliver a message, the network needs two things: which machine (the IP address) and which program on that machine (the port). Get these two ideas and a huge amount of networking suddenly makes sense.
π― Learning Objectives
By the end of this lesson you will:
- Understand IPv4 addresses and the idea of private vs public IPs
- Know what a port is and why it matters
- Recognise common ports used in DevOps
- Understand the difference between TCP and UDP
IP Addresses β the Machineβs Location
An IP address is the address of a device on a network, like a street address for a house.
The most common form, IPv4, looks like 192.168.1.10 β four numbers (0β255) separated by dots.
Private vs Public
| Type | Reachable from | Example ranges |
|---|---|---|
| Private | Only inside your local network | 10.x.x.x, 172.16β31.x.x, 192.168.x.x |
| Public | Anywhere on the internet | Anything not in the private ranges |
π‘ Why this matters in the cloud
Inside a cloud VPC, servers usually talk to each other over private IPs. Only a load balancer or gateway gets a public IP. This is the foundation of a secure network design.
Ports β the Programβs Door
One machine runs many programs at once β a web server, a database, an SSH service. A port (a number from 0β65535) tells the network which program should receive the message.
An address plus a port is called a socket: 192.168.1.10:443.
Common ports to memorise
| Port | Service |
|---|---|
| 22 | SSH |
| 80 | HTTP |
| 443 | HTTPS |
| 53 | DNS |
| 3306 | MySQL |
| 5432 | PostgreSQL |
| 6379 | Redis |
β Firewalls block ports
If your app βwonβt connect,β a closed port in a firewall or cloud security group is one of the most common causes. Always check: is the port open, and is the service actually listening on it?
TCP vs UDP
Both live at the Transport layer, but they make different promises:
| TCP | UDP | |
|---|---|---|
| Reliable? | Yes β confirms delivery, resends lost data | No β fire and forget |
| Ordered? | Yes | No |
| Speed | Slightly slower (more checks) | Faster, lighter |
| Used for | Web, SSH, databases | DNS, video calls, gaming, metrics |
π‘ Rule of thumb
Use TCP when every byte must arrive correctly (a web page, a bank transaction). Use UDP when speed matters more than perfection (a live video frame thatβs already out of date if itβs late).
See It Yourself
Check which ports are listening on your machine:
ss -tulnp # show listening TCP/UDP ports (Linux)
curl -v http://localhost:80 # connect to a program on port 80Here SSH (22) and a web server (80) accept connections from anywhere, while PostgreSQL (5432) only listens on 127.0.0.1 β localhost only. Thatβs a deliberate security choice.
π§ͺ Hands-on Lab
Map the Ports on Your Machine
- List all listening ports
- Identify which service each open port belongs to
- Note which ones are bound to
127.0.0.1(local only) vs0.0.0.0(all interfaces)
π§ Knowledge Check
What does a port number identify?
Which protocol would you choose for a live video call where speed matters more than perfect delivery?
πΌ Interview Preparation
A user reports they can't reach your service. How do you approach it?
Summary
You now understand IP addresses (which machine), ports (which program), private vs public addressing, and the TCP/UDP trade-off. Next, weβll see how human-friendly names like google.com turn into IP addresses using DNS.