PHASE 3 · MODULE 3

Essential Network Protocols

The protocols that make networking possible — how they work, what ports they use, and what to watch for.

Learning Objectives

DH
DHCP — Dynamic Host Configuration Protocol
Ports: UDP 67 (server) UDP 68 (client)

Purpose: Automatically assign IP configuration (IP address, subnet mask, default gateway, DNS servers) to devices on a network, eliminating manual configuration.

How it works — DORA Process:

  • Discover: Client broadcasts DHCPDISCOVER (source 0.0.0.0, dest 255.255.255.255)
  • Offer: Servers respond with DHCPOFFER containing an available IP lease
  • Request: Client broadcasts DHCPREQUEST requesting the chosen offer
  • ACK: Server sends DHCPACK confirming the lease with full configuration

Scopes: A scope is the pool of IP addresses a DHCP server can assign. It includes the range, exclusion list (addresses not to hand out), lease duration, and options (gateway, DNS, etc.).

Reservations: Binding a specific MAC address to a permanent IP within a scope. Useful for printers, servers, and infrastructure devices that need stable addresses without static configuration.

Security Considerations

Rogue DHCP servers (evil twin attack) can distribute malicious DNS/gateway settings. Mitigate with DHCP snooping on switches, which trusts only designated uplink ports. Also watch for DHCP starvation attacks that exhaust the address pool.

Common Issues

APIPA address (169.254.x.x) indicates DHCP failure — client couldn't reach any server. Causes: DHCP server down, network isolation, scope exhaustion, or corrupted lease. Fix: check server status, verify scope availability, try ipconfig /release && ipconfig /renew.

DN
DNS — Domain Name System
Port: UDP/TCP 53

Purpose: Translates human-readable domain names (google.com) into machine-readable IP addresses (142.250.80.46). Without DNS, we'd need to memorize IP addresses for every website.

Resolution process (recursive query):

  • Client queries its configured recursive resolver (usually the ISP's or a public resolver like 8.8.8.8)
  • Resolver checks its cache; if miss, queries a root nameserver (.)
  • Root directs to the TLD nameserver (.com)
  • TLD directs to the authoritative nameserver (google.com's NS)
  • Authoritative returns the A record (IP address)
  • Resolver caches the result and returns it to the client

Key Record Types:

  • A — IPv4 address record
  • AAAA — IPv6 address record
  • CNAME — Canonical name (alias for another domain)
  • MX — Mail exchange (points to mail server)
  • NS — Name server (delegates a zone)
  • TXT — Text record (SPF, DKIM, domain verification)
  • PTR — Pointer (reverse DNS lookup: IP to name)
  • SOA — Start of authority (zone metadata)
  • SRV — Service locator (ports for specific services)
Security Considerations

DNS cache poisoning injects false records. Mitigate with DNSSEC (digital signatures on records), randomize source ports, and use encrypted DNS (DoH on port 443 or DoT on port 853). DNS tunneling can exfiltrate data via encoded subdomain queries.

Common Issues

nslookup or dig timeouts suggest DNS server unreachable. Stale cache causes old IP resolution. DNS hijacking redirects queries to malicious servers. Fix: flush cache (ipconfig /flushdns), verify resolver IP, check DNSSEC validation.

HT
HTTP / HTTPS — Hypertext Transfer Protocol (Secure)
Ports: TCP 80 (HTTP) TCP 443 (HTTPS)

Purpose: HTTP is the foundation of web communication — requesting and delivering resources (HTML, images, APIs). HTTPS adds encryption via TLS/SSL.

How it works: Client sends an HTTP request (method + URI + headers). Server responds with a status code + headers + optional body. Methods: GET (retrieve), POST (submit data), PUT (update), DELETE (remove), PATCH (partial update).

Key Status Codes:

  • 2xx Success: 200 OK, 201 Created, 204 No Content
  • 3xx Redirection: 301 Moved Permanently, 302 Found, 304 Not Modified
  • 4xx Client Error: 400 Bad Request, 401 Unauthorized, 403 Forbidden, 404 Not Found, 429 Too Many Requests
  • 5xx Server Error: 500 Internal Server Error, 502 Bad Gateway, 503 Service Unavailable, 504 Gateway Timeout

TLS Basics: HTTPS uses TLS to establish an encrypted channel. The handshake involves: (1) Client Hello with supported cipher suites, (2) Server Hello with chosen suite + certificate, (3) Key exchange to establish a shared symmetric key, (4) Encrypted communication begins.

Security Considerations

Always prefer HTTPS. Watch for expired certificates, weak cipher suites, and misconfigured HSTS headers. HTTP Strict Transport Security (HSTS) forces browsers to use HTTPS. Certificate pinning and OCSP stapling improve security further.

Common Issues

Browser certificate warnings (expired cert, hostname mismatch, self-signed). Connection refused on port 443 means the web service isn't running or a firewall blocks it. Use curl -v https://example.com to see the handshake details.

FT
FTP / SFTP — File Transfer Protocol (Secure)
FTP: TCP 20 (data) TCP 21 (control) | SFTP: TCP 22

FTP Purpose: Transferring files between client and server over a network. Uses separate control (commands) and data (file contents) channels — hence two ports.

FTP Modes: Active mode — server initiates data connection back to client (port 20 → client ephemeral). — client initiates data connection to server (safer through firewalls).

SFTP (SSH File Transfer Protocol): Runs over SSH (port 22). Encrypts both commands and data in a single secure tunnel. Replaces insecure FTP entirely in modern environments.

Security Considerations

Classic FTP transmits credentials in cleartext — easily captured. Use SFTP or FTPS (FTP over SSL/TLS on port 990) instead. FTP active mode can expose the server to inbound attacks. Disable anonymous FTP unless explicitly required.

Common Issues

Passive mode failing behind firewalls — the server advertises an IP/port the client can't reach. FTP data connection timeout — check NAT/firewall stateful inspection for established data channels. SFTP failures usually relate to SSH key auth or permissions.

SS
SSH — Secure Shell
Port: TCP 22

Purpose: Encrypted remote login and command execution. Replaces insecure telnet. Also used for secure file transfer (scp, sftp), port forwarding/tunneling, and key-based authentication.

How it works: Client connects to server on port 22. They negotiate a symmetric session key using Diffie-Hellman key exchange. Server authenticates using password or public key. All subsequent traffic is encrypted.

Common flags: ssh -i key.pem user@host (specify key), ssh -L 8080:localhost:80 (local port forward), scp file.txt user@host:/path/ (secure copy).

Security Considerations

Disable password authentication — use key-based auth exclusively. Change default port (22) to reduce automated scanning (does not provide real security, only obscurity). Use fail2ban to block brute-force attempts. Restrict access with AllowUsers or Match directives in sshd_config. Keep OpenSSH updated.

Common Issues

"Connection refused" — SSH service not running or firewall blocking port 22. "Permission denied (publickey)" — wrong key or disabled key auth. "Host key verification failed" — server was reinstalled; remove old key from ~/.ssh/known_hosts.

RD
RDP — Remote Desktop Protocol
Port: TCP 3389

Purpose: Graphical remote desktop access to Windows machines. Sends screen updates and receives keyboard/mouse input over an encrypted channel.

How it works: RDP uses the Remote Desktop Protocol (RDP) over TCP. It negotiates security (TLS or RDP), authenticates the user, then streams a compressed graphical session. NLA (Network Level Authentication) authenticates before the full session is established, reducing attack surface.

Security Considerations

RDP is a prime target for attackers (BlueKeep, Farflame). Never expose RDP directly to the internet. Use VPN access, enforce NLA, apply all security patches, use strong passwords, enable MFA where supported, and limit RDP access via firewall rules to specific source IPs.

Common Issues

"Cannot connect to remote computer" — RDP service not running (check TermService), firewall blocking 3389, or Network Level Authentication mismatch. "Authentication error" — often caused by credential caching or group policy restrictions on RDP access.

SN
SNMP — Simple Network Management Protocol
Ports: UDP 161 (agent) UDP 162 (manager)

Purpose: Monitoring and managing network devices (routers, switches, servers, printers). Collects performance data and triggers alerts on thresholds.

How it works: The manager (monitoring server) polls agents (devices) using GET and GETNEXT requests. Agents respond with values from the MIB (Management Information Base) — a hierarchical database of managed objects. Devices can also send unsolicited TRAP or INFORM messages to the manager.

Versions: SNMPv1 (community strings, no encryption — insecure), SNMPv2c (improved performance, still community-based), SNMPv3 (adds authentication and encryption — use this).

Security Considerations

Never use SNMPv1/v2c in production — community strings traverse the network in cleartext. SNMPv3 provides auth (SHA/MD5) and privacy (AES/DES). Restrict SNMP access with ACLs — only allow specific monitoring servers to query devices.

Common Issues

Monitoring tool shows no data — SNMP service not enabled on device, wrong community string/version, or firewall blocking UDP 161. OID mismatches cause "no such object" errors.

AR
ARP — Address Resolution Protocol
Layer: Link Layer (Layer 2/3 boundary)

Purpose: Resolves an IP address to a MAC (physical) address on the local network segment. Every IP packet needs a destination MAC to be delivered on the local link.

How it works:

  • Host A wants to send to IP X.X.X.Y but doesn't know the MAC
  • Host A broadcasts ARP REQUEST: "Who has X.X.X.Y? Tell X.X.X.A"
  • Host Y recognizes its IP and replies with ARP REPLY (unicast): "X.X.X.Y is at MAC-AA:BB:CC:DD:EE:FF"
  • Host A caches the mapping in its ARP table

Commands: arp -a (Windows) or ip neigh show (Linux) to view the ARP cache.

Security Considerations

ARP spoofing/poisoning lets an attacker intercept traffic by sending fake ARP replies. Defend with static ARP entries for critical servers, DHCP snooping + DAI (Dynamic ARP Inspection) on switches, and ARPwatch for anomaly detection.

Common Issues

"Incomplete" ARP entries indicate the target didn't respond (device offline or wrong VLAN). Stale entries persist until timeout — clear with arp -d if needed. MAC address flapping suggests a loop or ARP poisoning attempt.

IC
ICMP — Internet Control Message Protocol
Protocol: IP Protocol 1

Purpose: Error reporting and diagnostic messaging between IP devices. ICMP messages are embedded inside IP packets (protocol number 1) and carry type/code information.

Key Message Types:

  • Type 0 — Echo Reply: Response to a ping request
  • Type 3 — Destination Unreachable: Can't reach target (net/unreachable, host unreachable, port unreachable, fragmentation needed)
  • Type 11 — Time Exceeded: TTL reached zero (used by traceroute)
  • Type 8 — Echo Request: Ping request
  • Type 5 — Redirect: Advise a better route exists

Important: ICMP is often mistakenly called "the ping protocol." Ping is just one ICMP message type. Traceroute relies heavily on ICMP Type 11 (Time Exceeded) messages.

Security Considerations

Unrestricted ICMP can leak information (path MTU discovery, topology mapping). Some organizations block all ICMP, but this breaks PMTU discovery and causes blackhole framing. Best practice: allow ICMP Type 3/11/12 (unreachable/time exceeded/path MTU) inbound and outbound; restrict echo request/reply.

Protocol Quick Reference Table

ProtocolPort(s)TransportPurpose
DHCP67/68 UDPUDPAuto IP assignment
DNS53 TCP/UDPUDP (queries), TCP (zone xfer)Name resolution
HTTP80 TCPTCPWeb traffic (unencrypted)
HTTPS443 TCPTCPEncrypted web traffic
FTP20, 21 TCPTCPFile transfer (unencrypted)
SFTP22 TCPTCPFile transfer over SSH
SSH22 TCPTCPEncrypted remote shell
RDP3389 TCPTCPRemote desktop (Windows)
SNMP161/162 UDPUDPNetwork device management
ARP— (Layer 2)—IP-to-MAC resolution
ICMPProtocol 1—Error reporting & diagnostics
Telnet23 TCPTCPUnencrypted remote terminal (deprecated)
SMTP25 TCP / 587 TCPTCPEmail submission
POP3110 TCP / 995 TCP (POP3S)TCPEmail retrieval
IMAP143 TCP / 993 TCP (IMAPS)TCPEmail retrieval with server-side sync
NTP123 UDPUDPTime synchronization

Hands-On Labs

Laboratory 1: DHCP & DNS Investigation

  1. On a Windows machine, run ipconfig /all and identify your DHCP server, lease obtained/expired times, and DNS servers.
  2. Run ipconfig /flushdns, then nslookup google.com — observe the resolution process.
  3. Use nslookup -type=mx gmail.com to find mail exchange records.
  4. Check the ARP cache with arp -a — note the interface IP, physical address, and type (dynamic/static).
  5. Ping a remote host and watch the ICMP echo request/reply timing with ping -t google.com.

Laboratory 2: Protocol Capture & Analysis

  1. Install Wireshark and start capturing on your primary interface.
  2. Open a web browser and visit http://example.com (insecure HTTP — notice cleartext!).
  3. Filter with http in Wireshark — examine request/response headers.
  4. Visit https://example.com — filter with tls — observe the TLS handshake (ClientHello, ServerHello, Certificate, KeyExchange).
  5. Stop capture and analyze: how many packets for TLS handshake vs plain HTTP?

Laboratory 3: DNS Diagnostics Deep Dive

  1. Run dig example.com ANY to see all record types.
  2. Trace the DNS resolution chain: dig @8.8.8.8 example.com NS, then query the authoritative nameserver directly.
  3. Test reverse DNS: dig -x 8.8.8.8 (PTR record lookup).
  4. Check your local DNS cache: on Windows ipconfig /displaydns, on Linux sudo resolvectl statistics.

Resources