Port
An IP address identifies a device.
A port identifies a specific application or service running on that device.
- One server = One IP
- Many applications = Many ports
It's like:
- IP address = Apartment building address
- Port = Specific room number
Without ports, the server would not know which application should receive the traffic.
Common Default Ports
| Service | Port | Protocol |
|---|---|---|
| SSH | 22 | TCP |
| HTTP | 80 | TCP |
| HTTPS | 443 | TCP |
| MySQL | 3306 | TCP |
| DNS | 53 | UDP (mostly) |
TCP
TCP stands for Transmission Control Protocol.
Characteristics:
- Connection-oriented
- Reliable
- Guarantees packet delivery
- Ensures correct order
- Performs error checking
Real World Example:
When opening a website or connecting via SSH, you need reliability. Missing packets are not acceptable.
Used for:
- Web traffic (HTTP/HTTPS)
- SSH
- Database connections
- APIs
TCP = Reliability first.
UDP
UDP stands for User Diagram Protocol
Characteristics:
- Connectionless
- Faster than TCP
- No guarantee of delivery
- No ordering of packets
Real World Example:
Streaming video or DNS queries — speed matters more than perfection.
Used for:
- DNS
- DHCP
- Video Streaming
- Online gaming
UDP = Speed first.
How Application Use Ports
When a client connects to a server:
- Client sends traffic to:
- Server IP
- Specific Port
Example:
http://10.0.1.10
10.0.1.10 - Server
80 - Web server application
If the port is:
- Open = connection succeeds
- Closed = connection refused
- Blocked by firewall = Timeout
Checking Open Ports in Linux
Using ss (Modern Tool)
ss -tuln
Options:
- t - TCP
- u - UDP
- l - Listening
- n - numbers
Example output:
LISTEN 0 127 0.0.0.0:22 0.0.0.0:*
LISTEN 0 127 0.0.0.0:80 0.0.0.0:*
Meaning:
- SSH is listening on port 22
- Web server is listening on port 80
Show Process Using Port
ss -tulnp
This shows which application owns the port. Very useful for debugging.
Testing Port Connectivity
Using Netcat
nc -vz 10.0.1.10 80
Results:
- succeeded = Port open
- connection refused = Service not running
- timed out = Firewall blocking
Using curl (for HTTP services)
curl http://10.0.1.10
If you received a response = Web server works.
Example of Basic Troubleshooting Flow
If an application is not reachable.
Step 1 - Check network connectivity
ping <server-ip>
If ping fails = Network issue.
Step 2 - Check if port is listening
ss -tuln
If port not listed = Service not running.
Step 3 - Test port connectivity
nc vz <server-ip> <port>
If timeout → Firewall or routing issue.
Step 4 - Test application response
curl http://<server-ip>:<port>
If no response = Application issue.
Today, I learned that ports allow multiple applications to communicate using the same IP address by acting as specific “doors” for each service. I understood the difference between TCP, which is reliable and connection-oriented, and UDP, which is faster but does not guarantee delivery. I practiced using Linux commands like ss, nc, and curl to check open ports and test service connectivity. This lesson helped me understand how to troubleshoot application-level network issues as an Entry-Level Platform Engineer.
Top comments (0)