๐
- ๐ช What is a Port?
- ๐ฆ Why Ports are Needed
- ๐ข Port Range (Very Important)
- โญ Common Ports You MUST Remember (AWS + Interviews)
- ๐ง How Ports Work (Simple Flow)
- ๐ TCP vs UDP Ports
- โ๏ธ Ports in AWS (Very Important)
- ๐งช Real AWS Example
- ๐ Important AWS Exam Traps
- ๐ Check Open Ports (Linux)
- ๐ง One-Line Exam Definition
- ๐ Quick Memory Trick
๐ช What is a Port?
A port is like a door on a computer or server.
- IP address โ identifies the machine
- Port number โ identifies the application/service on that machine
๐ IP = building address ๐ Port = flat/room number
๐ฆ Why Ports are Needed
One server runs many services at the same time:
| Service | Port |
|---|---|
| Website | 80 |
| Secure Website | 443 |
| SSH | 22 |
| Database | 3306 |
Without ports: โ Computer wouldnโt know which service should receive the data.
๐ข Port Range (Very Important)
Ports range from:
0 โ 65535
Categories:
1๏ธโฃ Well-Known Ports (0โ1023)
Reserved for common services.
2๏ธโฃ Registered Ports (1024โ49151)
Used by applications.
3๏ธโฃ Dynamic / Ephemeral Ports (49152โ65535)
Temporary ports used by clients.
โญ Common Ports You MUST Remember (AWS + Interviews)
| Port | Service | Use |
|---|---|---|
| 22 | SSH | Login to Linux EC2 |
| 80 | HTTP | Website |
| 443 | HTTPS | Secure website |
| 21 | FTP | File transfer |
| 25 | SMTP | Send emails |
| 53 | DNS | Domain resolution |
| 3306 | MySQL | Database |
| 5432 | PostgreSQL | Database |
| 27017 | MongoDB | Database |
| 3389 | RDP | Windows login |
๐ง How Ports Work (Simple Flow)
Example: You open a website.
1๏ธโฃ Your browser uses a random client port
Example: 52344
2๏ธโฃ It connects to server:
Server IP : 443
3๏ธโฃ Server replies back to:
Your IP : 52344
โ Server port is fixed โ Client port is temporary
๐ TCP vs UDP Ports
Ports work with protocols.
๐งฑ TCP (Reliable)
- Connection-oriented
- Slower but safe
Used for:
- HTTP (80)
- HTTPS (443)
- SSH (22)
โก UDP (Fast)
- No connection
- Faster but not guaranteed
Used for:
- DNS (53)
- Video streaming
- Gaming
โ๏ธ Ports in AWS (Very Important)
Security Group = Firewall
Security Groups control:
- Which ports are allowed
- From which IP
Example:
Allow inbound:
Port 22 โ My IP
Port 80 โ 0.0.0.0/0
If port is closed: โ Service is running โ But cannot be accessed
๐งช Real AWS Example
You launch EC2 and install Apache.
Apache listens on:
Port 80
But you forget to open port 80 in Security Group.
Result: โ Website not accessible
๐ Security Group must allow the port
๐ Important AWS Exam Traps
โ EC2 not accessible? Check:
- Security Group
- NACL
- Correct port
- Correct protocol (TCP/UDP)
๐ Check Open Ports (Linux)
Check listening ports:
ss -tuln
or
netstat -tuln
๐ง One-Line Exam Definition
A port is a logical communication endpoint that allows multiple services to run on the same IP address.
๐ Quick Memory Trick
- 22 โ SSH
- 80 โ Web
- 443 โ Secure Web
- 3306 โ MySQL
- 5432 โ PostgreSQL