DEV Community

Kervie Sazon
Kervie Sazon

Posted on

Networking Fundamentals - Part 4: Ports & TCP/UDP

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:

  1. Client sends traffic to:
  2. Server IP
  3. Specific Port

Example:

http://10.0.1.10 
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

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:*
Enter fullscreen mode Exit fullscreen mode

Meaning:

  • SSH is listening on port 22
  • Web server is listening on port 80

Show Process Using Port

ss -tulnp
Enter fullscreen mode Exit fullscreen mode

This shows which application owns the port. Very useful for debugging.

Testing Port Connectivity

Using Netcat

nc -vz 10.0.1.10 80
Enter fullscreen mode Exit fullscreen mode

Results:

  • succeeded = Port open
  • connection refused = Service not running
  • timed out = Firewall blocking

Using curl (for HTTP services)

curl http://10.0.1.10
Enter fullscreen mode Exit fullscreen mode

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>
Enter fullscreen mode Exit fullscreen mode

If ping fails = Network issue.

Step 2 - Check if port is listening

ss -tuln
Enter fullscreen mode Exit fullscreen mode

If port not listed = Service not running.

Step 3 - Test port connectivity

nc vz <server-ip> <port>
Enter fullscreen mode Exit fullscreen mode

If timeout → Firewall or routing issue.

Step 4 - Test application response

curl http://<server-ip>:<port>
Enter fullscreen mode Exit fullscreen mode

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)