IT & Networking Foundations
Beginner 13 min read IT & Networking Foundations

Ports and Common Network Services

The service inventory every defender should have memorized

Well-known ports identify common services (22 SSH, 80/443 web, 3389 RDP). Knowing the default service map tells an analyst what SHOULD be listening — and what's suspicious when it isn't.

portsservicesSSHRDPSMBSSLwell-known ports
Before we start

What you will learn

  • Map well-known ports to their services and risk profiles
  • Enumerate what is listening on your own hosts
  • Judge new or unexpected listeners as suspicious signals
Introduction

What is this?

TCP and UDP wrap payloads in segments addressed by ports. Well-known ports (0-1023) are reserved for common services: 22 SSH, 25 SMTP, 53 DNS, 80 HTTP, 443 HTTPS, 3389 RDP. Services are also a threat map: every open port is an attack surface, and every service has a default behavior an attacker can probe.

Motivation

Why do you need it?

  • Reconnaissance (authorized scans of your own lab) enumerates open ports first — knowing the defaults is how you read a scan.
  • An unexplained listener is an intrusion signal; the known-service map is your baseline.
  • Port-triggered alerts (e.g., new 3389 or 445 listener) fire all day in SOCs; you must reason about them.
  • Hardening = reducing exposed services to the minimum — a decision expressed in ports.
Think about it

Mental model

Imagine

Apartments with directory labels

Think of

Ports on a host

Each apartment (process) has a number (port) on the directory (well-known list). Security is like checking the building directory: you want to know who is home, who answers strangers, and which apartments shouldn't exist.

Mechanics

How it works

  • A server binds a socket (IP:port), e.g., nginx listens on 0.0.0.0:443.
  • A client connects to that address/port; the client side picks a random ephemeral source port.
  • IANA defines the well-known range 0-1023 and registered range up to 49151; the rest are ephemeral.
  • Security scanners probe ports to inventory services; each open port is then fingerprinted by banner or behavior.
  • UDP services (53, 123) differ: they're stateless, so they're fingerprinted via requests or responses rather than connection.

A host's open ports and their services.

eth0 (host)
22 SSH
80/443 web
3306 MySQL
3389 RDP
Reference

Key commands

ss -tulnp

List all listening TCP/UDP sockets with the owning process — your host's service inventory.

nc -zv 127.0.0.1 22

Test whether a specific local port accepts connections.

lsof -i :443

Show which process owns the listener on port 443.

Real world

In production

  • An asset scan benchmark expects 'SSH only on port 22 from the admin subnet'; anything else escalates.
  • A SOC alert fires when a database node shows a new 3389 listener — mercilessly explained as 'DB shouldn't serve RDP'.
  • A fire drill: closing 23 (telnet) and 21 (FTP) fleet-wide is the fastest way to stop cleartext admin traffic.
Guidelines

Best practices

  • Keep the open-port set minimal, documented and scheduled for review.
  • Bind only what's needed: a DB bound to 127.0.0.1 beats the same port bound to 0.0.0.0.
  • Change obvious defaults (SSH on 22 is discoverable; standing exotic passwords is worse than any port choice).
  • Baseline listeners before an incident so 'what's new' is a 10-second query.
Watch out

Common mistakes

  • Assuming 'port closed from outside' means the service is safe — internal-network attackers may still reach it.
  • Treating port numbers as security in themselves; a service on 443 still speaks its own dangerous protocol.
  • Forgetting ephemeral ports in firewall rules, breaking legitimate return traffic.
When things break

Debugging tips

  • ss -tulnp on the host answers 'is the service actually listening, and as which user?'
  • For a 'nothing listens' claim that's still reachable, check proxies/NAT rewrites — the listener may be elsewhere.
  • Cross-check listeners against the config that was supposed to be applied; drift is usually intentional and wrong.
Security

Security considerations

  • Every listener is a vector for the fingerprint-to-exploit loop; reduce and gate them.
  • Port scanning your own lab, Docker hosts and home router (authorized equipment you own) is how you build the inventory muscle before ever touching production.
Interviews

Interview checkpoint

Practice

Hands-on lab

Inventory Your Own Host's Services
25 min · beginner
In progress
Objectives
  • List every listener on your lab host and map it to a service
  • Identify which process and user owns each socket
  • Judge which listeners are expected vs suspicious

Inventory Your Own Host's Services

25 min · beginner

0/5 steps
0%
sandbox · Linux sandbox
$
Try these commands
Test yourself

Quick quiz

0/2
1

Which port designates SSH by convention?

2

Closing a port to the internet guarantees the service behind it is safe.

Go deeper

Official documentation