01 / 20

Ports & Common
Protocols

Understand how ports and protocols like TCP, UDP, DNS, DHCP, HTTP/S, and SSH form the backbone of network communication: and why they matter for cyber security.

Cyber Security

What Is a Port?

Think of an IP address as a building's street address. A port is a specific door number inside that building. Each door leads to a different service: web traffic, email, file transfer, or remote login.

Server 192.168.1.10 Port 80 (HTTP) Port 443 (HTTPS) Port 22 (SSH) Client 10.0.0.5 Ephemeral Port 49152+ IP address = building | Port = door number

What Is a Protocol?

A protocol is a set of rules that governs how data is formatted, transmitted, and received over a network. Without protocols, devices would have no common language to communicate.

TCP
Transmission Control Protocol: reliable, ordered delivery with error checking. Used by HTTP, SSH, FTP.
UDP
User Datagram Protocol: fast, connectionless. No guaranteed delivery. Used by DNS, DHCP, streaming.

Why Ports & Protocols Matter for Security

Every open port is a potential entry point for attackers. Understanding which ports should be open: and which should not: is fundamental to defending a network.

1
Attack surface reduction: Close unnecessary ports to shrink the number of ways an attacker can reach your systems.
2
Firewall configuration: Firewalls allow or deny traffic based on port numbers and protocols. Misconfigurations leave gaps.
3
Threat detection: Unusual traffic on unexpected ports (e.g., outbound traffic on port 4444) can signal malware or a breach.

TCP vs UDP: The Two Transport Protocols

TCP Client Server SYN SYN-ACK ACK 3-Way Handshake Reliable, ordered, error-checked UDP Client Server Data Data Data Fire & Forget Fast, no handshake, no guarantee vs

TCP vs UDP: Key Differences

Feature TCP UDP
ConnectionConnection-orientedConnectionless
ReliabilityGuaranteed deliveryNo guarantee
OrderingOrdered packetsUnordered
SpeedSlower (overhead)Faster
Error CheckingYes + retransmissionChecksum only
Use CasesHTTP/S, SSH, FTPDNS, DHCP, VoIP

DNS: The Internet's Phone Book

The Domain Name System (DNS) translates human-readable domain names (like example.com) into IP addresses (like 93.184.216.34). It primarily uses UDP port 53.

Your Browser DNS Server UDP Port 53 Web Server 93.184.216.34 1. "example.com?" 2. "93.184.216.34" 3. Connect to IP DNS = Domain Name → IP Address translation Without DNS, you'd need to memorize every IP address

DHCP: Automatic IP Assignment

Dynamic Host Configuration Protocol (DHCP) automatically assigns IP addresses to devices when they join a network. It uses UDP ports 67 (server) and 68 (client).

1
Discover: Client broadcasts "I need an IP address!" to the entire network.
2
Offer: DHCP server responds with an available IP address and configuration.
3
Request: Client formally requests the offered address.
4
Acknowledge: Server confirms the assignment. The client now has an IP, subnet mask, gateway, and DNS server.

HTTP vs HTTPS: Encryption Matters

HTTP : Port 80 Client Server "password123" Plaintext: anyone can read ✕ Vulnerable to sniffing HTTPS : Port 443 Client Server "a3f$9kQ..." TLS encrypted: unreadable ✓ Secure communication HTTPS = HTTP + TLS/SSL Encryption The "S" stands for Secure: encrypts data in transit Always check for the lock icon in your browser

SSH: Secure Remote Access

Secure Shell (SSH) provides encrypted remote login and command execution on TCP port 22. It replaced the insecure Telnet protocol (port 23), which transmitted everything in plaintext.

Authentication
SSH supports password-based and key-based authentication. Key-based is far more secure.
Encryption
All traffic (commands, output, file transfers) is encrypted end-to-end using symmetric ciphers.
# Connect to a remote server via SSH
ssh admin@192.168.1.10 -p 22

# Using key-based authentication (more secure)
ssh -i ~/.ssh/id_rsa admin@192.168.1.10

The Well-Known Ports Map

Network Services HTTP TCP 80 HTTPS TCP 443 SSH TCP 22 DNS UDP 53 DHCP UDP 67/68 FTP TCP 20/21 Telnet TCP 23 (insecure) SMTP TCP 25

How to Analyze Network Traffic

Security analysts use port and protocol knowledge to investigate traffic. Here is a step-by-step approach:

1
Identify the port: Check which port the traffic uses. Is it a well-known port (0 to 1,023) or an unusual one?
2
Check the protocol: Is it TCP or UDP? Does the application-layer protocol match what's expected on that port?
3
Verify the direction: Is the traffic inbound (to your server) or outbound (from your network)? Unexpected outbound traffic is a red flag.
4
Look for anomalies: HTTP traffic on port 443? SSH on port 8080? Protocol mismatches often indicate tunneling or evasion.
5
Correlate with context: Cross-reference with firewall logs, IDS alerts, and known threat intelligence.

Example: Reading Firewall Rules

A security admin reviews these firewall rules. Which traffic is allowed?

# Firewall Rule Set
ALLOW TCP ANY → 443 # HTTPS inbound
ALLOW TCP ANY → 22 # SSH inbound
ALLOW UDP ANY → 53 # DNS queries
DENY TCP ANY → 23 # Block Telnet
DENY TCP ANY → 80 # Block plain HTTP
DENY ALL ANY → ANY # Default deny

Example: Spotting Suspicious Traffic

An analyst notices these connections in a network log. Which ones are suspicious?

# Network Log Entries
10.0.0.5 → 93.184.216.34 TCP 443 # Normal HTTPS
10.0.0.12 → 8.8.8.8 UDP 53 # Normal DNS
10.0.0.8 → 45.33.32.156 TCP 4444 # ??? Unusual port
10.0.0.3 → 198.51.100.1 TCP 23 # Telnet? Insecure!

Example: Understanding a Port Scan

An Nmap scan reveals open ports on a web server. What do the results tell us?

# Nmap Scan Results
PORT STATE SERVICE
22/tcp open ssh
80/tcp open http
443/tcp open https
3306/tcp open mysql
8080/tcp open http-proxy
✓ Expected
Ports 22 (SSH), 80 (HTTP), 443 (HTTPS) are standard for a web server.
✕ Risky
Port 3306 (MySQL) exposed to the internet is a serious vulnerability. Database ports should be internal only.
? Investigate
Port 8080 (HTTP proxy) may be intentional or may indicate a misconfigured service.

Common Mistakes

✕ Leaving Unnecessary Ports Open
Every open port is an attack surface. Close ports for services you don't need. Don't leave SSH open to the entire internet.
✕ Using HTTP Instead of HTTPS
HTTP transmits data in plaintext. Passwords, cookies, and personal data can be intercepted. Always use HTTPS (port 443).
✕ Confusing TCP and UDP Ports
Port 53 is DNS (usually UDP), not TCP. Configuring firewalls with the wrong protocol will block legitimate traffic or leave gaps.

Protocols & Ports: Quick Reference

Protocol Port(s) Transport Secure?
HTTP 80 TCP No
HTTPS 443 TCP Yes (TLS)
SSH 22 TCP Yes
DNS 53 UDP (TCP) No*
DHCP 67/68 UDP No
FTP 20/21 TCP No
Telnet 23 TCP No
SMTP 25 TCP No*

Question 1 of 5

Which port and protocol combination is used by HTTPS for secure web traffic?

Question 2 of 5

A security analyst sees outbound traffic from an internal machine to an external IP on TCP port 4444. What is the most likely concern?

Question 3 of 5

What is the primary difference between TCP and UDP?

Question 4 of 5

The DHCP process follows four steps: Discover, Offer, Request, Acknowledge. Which transport protocol does DHCP use?

Question 5 of 5

An Nmap scan shows that port 3306 (MySQL) is open and accessible from the public internet on a web server. What is the recommended action?