Skip to content
beginner Phase 2 · Networking for Security

Common Ports and Protocols

Map default ports to services and flag traffic that deviates from norms.

45m
0 problems
Topic Progress 0%

The Ports You Must Know and Why They Matter

More Than a Memorization Exercise

Ports are the addressing mechanism that allows a single IP address to host multiple services. Each port is a 16-bit number (0-65535), and certain ports are assigned to specific protocols by convention (IANA). Knowing these assignments is not trivia — it is the foundation for firewall configuration, intrusion detection, and incident response.

When you see traffic on port 443, you know it is likely HTTPS. When you see traffic on port 23, you know it is Telnet — and you should be alarmed because Telnet transmits credentials in plaintext. When you see traffic on a high port (e.g., 4444) that you did not expect, you should investigate because attackers often use high ports for command-and-control.

The Well-Known Ports (0-1023)

These ports require root/administrator privileges to bind to on most operating systems. They are the standard ports for common services:

Web and Proxy:

  • 80/tcp — HTTP (plaintext web traffic). Should be redirected to 443 in any secure environment.
  • 443/tcp — HTTPS (TLS-encrypted web traffic). The standard for secure web communication.
  • 8080/tcp — HTTP alternate (often used for proxy servers or web management interfaces).
  • 8443/tcp — HTTPS alternate (often used for web management interfaces).

Remote Access:

  • 22/tcp — SSH (Secure Shell). Encrypted remote administration. The replacement for Telnet and rlogin.
  • 23/tcp — Telnet. Plaintext remote administration. Credentials and all data are transmitted unencrypted. Should never be used.
  • 3389/tcp — RDP (Remote Desktop Protocol). Windows remote desktop. Frequently targeted by brute-force attacks.
  • 5900/tcp — VNC (Virtual Network Computing). Remote desktop for Linux/Unix. Often configured without encryption.

File Transfer:

  • 20/tcp, 21/tcp — FTP (File Transfer Protocol). Port 20 is data, port 21 is control. Plaintext — credentials are transmitted unencrypted. Replaced by SFTP and FTPS.
  • 22/tcp — SFTP (SSH File Transfer Protocol). Runs over SSH, so it is encrypted. Note: SFTP is not FTP over SSH — it is a completely different protocol.
  • 989/tcp, 990/tcp — FTPS (FTP over TLS). Encrypted FTP.
  • 445/tcp — SMB (Server Message Block). Windows file sharing. Also used by WannaCry and other ransomware for lateral movement.

Email:

  • 25/tcp — SMTP (Simple Mail Transfer Protocol). Used for server-to-server mail relay. Often blocked on residential IPs to prevent spam.
  • 587/tcp — SMTP submission. Used for client-to-server mail submission with authentication.
  • 110/tcp — POP3 (Post Office Protocol v3). Plaintext email retrieval.
  • 143/tcp — IMAP (Internet Message Access Protocol). Plaintext email retrieval.
  • 993/tcp — IMAPS (IMAP over TLS). Encrypted IMAP.
  • 995/tcp — POP3S (POP3 over TLS). Encrypted POP3.

Directory and Authentication:

  • 389/tcp — LDAP (Lightweight Directory Access Protocol). Plaintext directory queries. Used by Active Directory.
  • 636/tcp — LDAPS (LDAP over TLS). Encrypted LDAP.
  • 88/tcp — Kerberos. Windows authentication protocol.
  • 464/tcp — Kerberos password change.

Database:

  • 1433/tcp — Microsoft SQL Server.
  • 1521/tcp — Oracle Database.
  • 3306/tcp — MySQL.
  • 5432/tcp — PostgreSQL.
  • 27017/tcp — MongoDB.
  • 6379/tcp — Redis. No authentication by default — frequently exposed to the internet.

DNS and Network Services:

  • 53/tcp, 53/udp — DNS (Domain Name System). Both TCP and UDP are used; UDP for queries, TCP for zone transfers and large responses.
  • 67/udp, 68/udp — DHCP (Dynamic Host Configuration Protocol).
  • 69/udp — TFTP (Trivial File Transfer Protocol). No authentication — used for network boot.
  • 123/udp — NTP (Network Time Protocol). Can be abused for amplification attacks.
  • 161/udp, 162/udp — SNMP (Simple Network Management Protocol). Community strings are plaintext — SNMPv1 and v2c should not be used.

Remote Management and Infrastructure:

  • 161/udp — SNMP. Community strings act as plaintext passwords.
  • 514/udp — Syslog. Plaintext log transmission.
  • 514/tcp — Syslog over TCP (more reliable, still plaintext).
  • 2375/tcp, 2376/tcp — Docker API. 2375 is unencrypted, 2376 is TLS.
  • 6443/tcp — Kubernetes API server.
  • 10250/tcp — Kubernetes kubelet API.

Encrypted vs. Plaintext: The Security Distinction

The most important security distinction between protocols is whether they transmit data in plaintext or encrypted:

Protocol Port Encrypted? Risk
HTTP 80 No Credentials and data interceptable
HTTPS 443 Yes (TLS) Safe in transit
SSH 22 Yes Safe in transit
Telnet 23 No Credentials interceptable
FTP 21 No Credentials interceptable
SFTP 22 Yes (over SSH) Safe in transit
SMTP 25 No (STARTTLS optional) Data interceptable
IMAP 143 No (STARTTLS optional) Credentials interceptable
IMAPS 993 Yes Safe in transit
LDAP 389 No Credentials interceptable
LDAPS 636 Yes Safe in transit
SMB 445 Depends on version SMBv1 is vulnerable
RDP 3389 Yes (TLS) Safe if configured correctly
VNC 5900 Often no Credentials often interceptable
Redis 6379 No No auth by default
MySQL 3306 Optional Often misconfigured

The rule: any protocol that transmits credentials or sensitive data in plaintext is a security risk. Replace Telnet with SSH, FTP with SFTP, HTTP with HTTPS, LDAP with LDAPS, and SNMPv2c with SNMPv3.

Firewall Design and Anomaly Detection

Using Port Knowledge Defensively

Knowing ports is not just about memorization — it is about using that knowledge to design defenses and detect anomalies.

Default-Deny Firewall Design

The fundamental principle of firewall configuration is default deny: block all traffic by default, then allow only what is explicitly required. This is the opposite of the legacy approach (allow all, block known bad) which is ineffective because you cannot enumerate all bad traffic.

A well-designed firewall rule set for a web server:

# iptables example: default-deny inbound, allow only required ports
iptables -P INPUT DROP
iptables -P FORWARD DROP
iptables -P OUTPUT ACCEPT

# Allow established connections
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT

# Allow loopback
iptables -A INPUT -i lo -j ACCEPT

# Allow SSH from management network only
iptables -A INPUT -p tcp --dport 22 -s 10.0.0.0/24 -j ACCEPT

# Allow HTTP and HTTPS from anywhere
iptables -A INPUT -p tcp --dport 80 -j ACCEPT
iptables -A INPUT -p tcp --dport 443 -j ACCEPT

# Log and drop everything else
iptables -A INPUT -j LOG --log-prefix "DROP: "
iptables -A INPUT -j DROP

Notice what is NOT allowed: Telnet (23), FTP (21), MySQL (3306), Redis (6379). The web server does not need these services, so they are blocked. If an attacker compromises the web server and tries to pivot to the database on port 3306, the firewall blocks the connection.

Non-Standard Ports as an Indicator of Compromise

Attackers often run services on non-standard ports to evade detection. If you see SSH running on port 2222 instead of 22, or a web server on port 8080 instead of 80, it may be:

  1. Legitimate: A system administrator moved the service to a non-standard port for security through obscurity (weak but sometimes used).
  2. Malicious: An attacker installed a backdoor on a non-standard port to avoid detection by security tools that only monitor standard ports.
# Find all listening ports and the processes that own them
netstat -tlnp
# On Linux, look for services on unexpected ports
ss -tlnp | grep -v -E ':(22|80|443|53) '

The key is to know what SHOULD be running on each port and investigate deviations. A service on port 4444 (default for Metasploit's Meterpreter) or port 1337 (common backdoor port) is almost certainly malicious.

Port Scanning: How Attackers Use Port Knowledge

Attackers use port scanning to discover what services are running on a target. The most common scan types:

# SYN scan (half-open, stealthy — does not complete the TCP handshake)
nmap -sS target.example.com

# Connect scan (completes the handshake, more detectable but more reliable)
nmap -sT target.example.com

# Service version detection (probes each open port for version info)
nmap -sV target.example.com

# Scan all 65535 ports (attackers do this — you should too)
nmap -p- target.example.com

The output tells the attacker exactly which services are running and often which versions. If the attacker sees Apache 2.4.49, they know to try CVE-2021-41773 (path traversal). This is why patching and version detection are critical — the attacker will find and exploit known vulnerabilities.

Detecting Unauthorized Services

To detect services that should not be running:

  1. Baseline: Document which ports should be open on each host. This is your known-good state.

  2. Scan regularly: Use nmap or a vulnerability scanner to compare actual open ports against the baseline.

  3. Monitor network flow: Use NetFlow, sFlow, or a network detection and response (NDR) tool to detect traffic on unexpected ports.

  4. Alert on deviations: If a port that was closed last week is now open, investigate immediately.

# Quick check: what is listening on this host?
netstat -tlnp

# Check for services on high ports (potential backdoors)
netstat -tlnp | awk '$4 ~ /:([0-9]{4,5})$/'

Common Port-Based Attack Patterns

  • Port 23 (Telnet): Brute-force attacks against IoT devices and routers with default credentials.
  • Port 445 (SMB): EternalBlue exploit (WannaCry, NotPetya), pass-the-hash attacks.
  • Port 3389 (RDP): Brute-force attacks, BlueKeep exploit (CVE-2019-0708).
  • Port 6379 (Redis): Unauthenticated access, write SSH keys to gain remote access.
  • Port 27017 (MongoDB): Unauthenticated access, ransomware that deletes databases and demands payment.
  • Port 9200 (Elasticsearch): Unauthenticated access, data exfiltration.
  • Port 2375 (Docker API): Unauthenticated container escape, cryptomining.

The pattern: services that are exposed to the internet without authentication or with default credentials. The fix is never to expose management interfaces to the internet — use a VPN or bastion host for remote access.

Practice Problems

0 / 2 solved

Solution
The risks: (1) Port 3306 (MySQL) is open to the internet — attackers can attempt to brute-force database credentials or exploit known MySQL vulnerabilities. (2) Port 6379 (Redis) is open to the internet — Redis has no authentication by default, so attackers can read/write data, write SSH keys, or execute commands. (3) Port 22 (SSH) is open to the internet — while necessary for administration, it should be restricted to specific management IPs. Corrected rule set: allow 22 only from the management network (e.g., 10.0.0.0/24), allow 80 and 443 from anywhere (public web traffic), block 3306 and 6379 from all external sources (the web application connects to them locally on the same server, so no inbound access is needed). If the database and cache are on separate servers, allow 3306 and 6379 only from the web server's IP address.

Solution
Possible explanations: (1) A backdoor or reverse shell — port 1337 is commonly used by attackers for command-and-control because it is non-standard and may evade basic monitoring. (2) A legitimate but unauthorized service — a developer may have installed a tool for testing without informing the security team. (3) A misconfigured service — a legitimate service may have been configured to use the wrong port. Investigation steps: (1) Identify the process: netstat -tlnp | grep 1337 to find the PID and executable path. (2) Examine the process: check the executable's hash, digital signature, and file creation date. (3) Check network connections: netstat -anp | grep 1337 to see if the process has established connections to external IPs. (4) Review process history: check if the process was started by a user or by a service, and correlate with authentication logs. (5) If the process is unauthorized, isolate the server from the network, capture memory and disk images for forensic analysis, and begin incident response procedures.

Quiz

1. A company's web server is accessible on port 80 (HTTP) and port 443 (HTTPS). An attacker intercepts traffic between a user and the web server and reads the user's login credentials. Which protocol was the user likely using, and what is the specific security failure?

Question 1 options

2. Why is finding a service running on port 4444 during an investigation considered a strong indicator of compromise?

Question 2 options

3. A firewall is configured to allow all outbound traffic and block all inbound traffic except ports 22, 80, and 443. An attacker compromises the web server and wants to exfiltrate data. Why is this firewall configuration insufficient to prevent data exfiltration?

Question 3 options

Flashcards

Question

What ports do HTTP and HTTPS use?

Answer

HTTP uses port 80 (plaintext). HTTPS uses port 443 (TLS-encrypted). HTTP should redirect to HTTPS in any secure environment.

Question

What is the encrypted replacement for Telnet (port 23)?

Answer

SSH (Secure Shell) on port 22. Telnet transmits credentials and all data in plaintext. SSH encrypts the entire session.

Question

What is the encrypted replacement for FTP (ports 20/21)?

Answer

SFTP (SSH File Transfer Protocol) on port 22, or FTPS (FTP over TLS) on ports 989/990. FTP transmits credentials in plaintext.

Question

Why is finding Redis (port 6379) exposed to the internet a critical risk?

Answer

Redis has no authentication by default. An attacker can read and write data, write SSH keys to the server's authorized_keys file for remote access, and even execute operating system commands through Redis configuration directives.

Question

What is the principle of default-deny firewall configuration?

Answer

Block all traffic by default, then allow only what is explicitly required. This is the opposite of allow-all-with-exceptions, which is ineffective because you cannot enumerate all malicious traffic patterns.

Question

Why is a service on a non-standard port (e.g., SSH on port 2222) a potential indicator of compromise?

Answer

Attackers run services on non-standard ports to evade detection by security tools that only monitor standard ports. While it could be a legitimate configuration change, it warrants investigation because it is a common attacker technique.

Revision Notes

Key Takeaways

  • 1. Know the well-known ports: 22 (SSH), 80 (HTTP), 443 (HTTPS), 53 (DNS), 445 (SMB), 3389 (RDP)
  • 2. Any protocol transmitting credentials in plaintext (Telnet, FTP, HTTP, LDAP) is a security risk — replace with encrypted alternatives
  • 3. Default-deny firewall configuration is the only effective approach — block all, allow only required
  • 4. Services on non-standard ports are potential indicators of compromise — investigate deviations from baseline
  • 5. Database ports (3306, 5432, 6379, 27017) should never be exposed to the internet
  • 6. Egress filtering is as important as ingress filtering — attackers exfiltrate data through outbound connections

Interview Tips

  • • Be ready to list the ports for common protocols and identify which are encrypted vs. plaintext
  • • Discuss how you would design firewall rules for a specific server role (web, database, management)
  • • Explain how you would detect unauthorized services using port scanning and network monitoring
  • • Describe a time when a non-standard port or unexpected service led to discovering a security issue
  • • Connect port knowledge to incident response — knowing which ports are expected helps you identify anomalies quickly

Cheat Sheet

Common Ports and Protocols Cheat Sheet

Phase: Networking for Security | Level: beginner

Essential Ports:

  • 22/tcp — SSH (encrypted remote access)
  • 23/tcp — Telnet (PLAINTEXT — do not use)
  • 80/tcp — HTTP (PLAINTEXT — redirect to 443)
  • 443/tcp — HTTPS (TLS-encrypted)
  • 53/tcp+udp — DNS
  • 445/tcp — SMB (Windows file sharing)
  • 3389/tcp — RDP (Windows remote desktop)
  • 3306/tcp — MySQL
  • 5432/tcp — PostgreSQL
  • 6379/tcp — Redis (no auth by default)
  • 27017/tcp — MongoDB
  • 389/tcp — LDAP (PLAINTEXT)
  • 636/tcp — LDAPS (encrypted)

Encrypted vs. Plaintext:

Plaintext Encrypted Replacement
Telnet (23) SSH (22)
FTP (21) SFTP (22) or FTPS (990)
HTTP (80) HTTPS (443)
LDAP (389) LDAPS (636)
SNMPv2c (161) SNMPv3 (161)

Firewall Design:

  • Default deny: block all, allow only required
  • Restrict management ports (22, 3389) to specific IPs
  • Never expose database ports (3306, 5432, 6379) to the internet
  • Implement egress filtering (block unauthorized outbound)

Indicator of Compromise:

  • Services on non-standard ports (e.g., SSH on 2222)
  • Port 4444 (Meterpreter default)
  • Port 1337 (common backdoor)
  • Unexpected high-port listeners

Continue Learning

Before You Start

  • No prerequisites listed.