What is a Port?
- A port is a virtual endpoint used for communication between devices over a network.
- Ports help in identifying specific services running on a system.
- Each port is associated with a protocol (TCP/UDP).
Categories of Ports
| Category | Range | Description |
|---|---|---|
| 1οΈβ£ Well-Known Ports | 0 - 1023 | Used by standard services (e.g., HTTP, SSH, DNS). |
| 2οΈβ£ Registered Ports | 1024 - 49151 | Used by applications (e.g., MySQL, PostgreSQL). |
| 3οΈβ£ Dynamic / Ephemeral Ports | 49152 - 65535 | Temporary ports for client connections. |
Important Ports to Remember π₯
| Port | Service | Protocol | Use Case |
|---|---|---|---|
| π 22 | SSH (Secure Shell) | TCP | Secure remote access to servers |
| π 80/443 | HTTP/HTTPS | TCP | Web browsing & API requests |
| π¦ 20/21 | FTP (File Transfer Protocol) | TCP | Transferring files between servers |
| π³ 2375/2376 | Docker API | TCP | Managing Docker containers remotely |
| π₯οΈ 3389 | RDP (Remote Desktop Protocol) | TCP | Accessing Windows servers remotely |
| ποΈ 27017 | MongoDB | TCP | Conn to MongoDB on a remote server |
| π 3306 | MySQL | TCP | Connecting to MySQL databases |
| π¦Ύ 5432 | PostgreSQL | TCP | Connecting to PostgreSQL databases |
| π 9090 | Prometheus | TCP | Monitoring and metrics collection |
| π 3000 | Grafana | TCP | Visualizing monitoring data |
| π΅οΈ 53 | DNS (Domain Name System) | UDP/TCP | Resolving domain names to IPs |
| β° 123 | NTP (Network Time Protocol) | UDP | Synchronizing system time |
Note
If youβre running MongoDB on a remote server, ensure port 27017 is open in your firewall or security groups.
How Ports Work?
1οΈβ£ A client sends a request to a serverβs IP address & port. 2οΈβ£ The server listens on that port for incoming connections. 3οΈβ£ The connection is established, and data transfer begins.
TCP vs. UDP Ports
β TCP (Transmission Control Protocol) β Reliable, connection-oriented (e.g., HTTPS, SSH). β UDP (User Datagram Protocol) β Fast, connectionless (e.g., DNS, Streaming).
AWS Security Groups & Ports
- Security Groups allow or deny inbound & outbound traffic based on port numbers.
- Example:
- Allow SSH (Port 22) β Access Linux EC2 instances.
- Allow HTTP (Port 80) β Host a website on EC2.
π Summary
- Ports identify services on a system (e.g., 80 β HTTP, 443 β HTTPS).
- Some ports are well-known, while others are dynamic.
- TCP is reliable, while UDP is faster but less reliable.
- AWS Security Groups control access using ports.