hack3rs.ca network-security
/learning/tcp-ip-dns-http-tls-routing-switching :: module-1

student@hack3rs:~/learning$ open tcp-ip-dns-http-tls-routing-switching

TCP/IP, DNS, HTTP, TLS, Routing and Switching Fundamentals

Build the protocol literacy needed for defensive work. This module explains how traffic moves, how names resolve, how web sessions are built, and where defenders can observe or control each step.

Most network security mistakes come from weak protocol understanding. If you cannot explain a normal TCP handshake, DNS lookup, or TLS negotiation, detection engineering and troubleshooting become guesswork.

learning-objectives

  • $Explain packet vs frame vs segment terminology and where each appears in the stack.
  • $Describe all seven OSI layers and map common protocols/telemetry to the correct layer.
  • $Trace a typical web request from DNS resolution through TLS and HTTP response.
  • $Identify key control points: switches, routers, firewalls, reverse proxies, and DNS resolvers.
  • $Recognize what telemetry can be observed before and after encryption.

example-dataflow-and-observation-paths

Use these example dataflows to trace how activity moves through systems and where a defender can observe evidence. This is how learners move from memorizing terms to thinking like investigators.

  • $Client resolves a domain via DNS -> resolver returns IP -> client initiates TCP handshake -> TLS negotiation starts -> HTTP request/response exchange begins.
  • $Switch forwards local frames by MAC -> router forwards packets by IP -> firewall enforces policy -> reverse proxy/load balancer forwards to application server.
  • $Defender evidence path: DNS logs -> firewall flow logs -> packet capture metadata -> web server access logs -> application logs.

baseline-normal-before-debugging

  • $Normal DNS requests resolve quickly and are followed by connections to the returned IPs.
  • $A normal TCP handshake shows SYN -> SYN/ACK -> ACK before application data.
  • $Expected TLS negotiation completes before HTTP requests over HTTPS are visible as metadata only.
Expert tip: Baseline normal behavior before writing detections or escalating anomalies. Most tuning and triage errors come from skipping this step.

concept-breakdown-and-mastery

1. Protocol Stack and Data Flow

$ core idea: Start by understanding encapsulation: application data is wrapped by transport headers (TCP/UDP), then by IP, then by a layer-2 frame. Defensive tooling may show different layers depending on where you collect traffic.

$ defender angle: TCP provides ordered delivery, retransmission, and flow control. UDP is simpler and lower overhead, so it is common in DNS, streaming, and some telemetry. Security implications differ because TCP sessions expose state and retries while UDP traffic is more stateless and bursty.

$ prove understanding: Explain packet vs frame vs segment terminology and where each appears in the stack.

2. OSI Model for Defenders (All 7 Layers, in Practice)

$ core idea: The OSI Model is a teaching model that helps defenders troubleshoot and reason about network behavior layer by layer. In real environments, the TCP/IP model is used more often operationally, but OSI remains extremely useful because it gives you a clean mental checklist: physical path, local delivery, routing, transport behavior, session state, data representation, and application behavior.

$ defender angle: Layer 1 (Physical) is the medium: cables, fiber, radio, signal quality, interfaces, and link state. Defenders often ignore Layer 1 until there is packet loss, duplex mismatch, or wireless interference. A security team should still understand Layer 1 symptoms because intermittent connectivity, drops, and retransmissions can look like attack traffic or can hide real attacks in noisy telemetry.

$ prove understanding: Describe all seven OSI layers and map common protocols/telemetry to the correct layer.

3. DNS, HTTP, and TLS in a Real Request

$ core idea: A user requests a website. The endpoint first resolves a name via DNS (often through a local resolver, enterprise DNS, or encrypted DNS). Then it opens a TCP session (or QUIC/UDP for HTTP/3), negotiates TLS, and finally exchanges HTTP requests and responses.

$ defender angle: Defenders should learn what is visible at each stage. DNS query names, resolver behavior, SNI (in many TLS cases), certificate metadata, timing, and destination IPs can all support detection even when payloads are encrypted.

$ prove understanding: Trace a typical web request from DNS resolution through TLS and HTTP response.

4. Routing, Switching, and Security Visibility

$ core idea: Switches forward frames inside a LAN using MAC addresses, while routers move packets between networks using routing tables. This matters because SPAN/mirror ports, taps, and sensor placement determine what traffic your IDS can actually see.

$ defender angle: Network defenders should know where NAT, load balancers, and proxies alter source/destination context. Misreading translated addresses is a common root cause for false assumptions during incident triage.

$ prove understanding: Identify key control points: switches, routers, firewalls, reverse proxies, and DNS resolvers.

deep-dive-notes-expanded

Work through the sections in order. For each section, learn the theory, identify normal behavior, identify failure patterns, then validate with packet/log/CLI evidence.

1. Protocol Stack and Data Flow

Start by understanding encapsulation: application data is wrapped by transport headers (TCP/UDP), then by IP, then by a layer-2 frame. Defensive tooling may show different layers depending on where you collect traffic.

TCP provides ordered delivery, retransmission, and flow control. UDP is simpler and lower overhead, so it is common in DNS, streaming, and some telemetry. Security implications differ because TCP sessions expose state and retries while UDP traffic is more stateless and bursty.

ICMP is not just for ping. It supports diagnostics and error reporting, which makes it useful for troubleshooting and also useful for reconnaissance and covert signaling if not monitored.

Normal Behavior

Normal DNS requests resolve quickly and are followed by connections to the returned IPs.

Failure / Abuse Pattern

DNS lookup succeeds but no TCP handshake follows (routing/firewall or application issue).

Evidence To Collect

Explain packet vs frame vs segment terminology and where each appears in the stack.

2. OSI Model for Defenders (All 7 Layers, in Practice)

The OSI Model is a teaching model that helps defenders troubleshoot and reason about network behavior layer by layer. In real environments, the TCP/IP model is used more often operationally, but OSI remains extremely useful because it gives you a clean mental checklist: physical path, local delivery, routing, transport behavior, session state, data representation, and application behavior.

Layer 1 (Physical) is the medium: cables, fiber, radio, signal quality, interfaces, and link state. Defenders often ignore Layer 1 until there is packet loss, duplex mismatch, or wireless interference. A security team should still understand Layer 1 symptoms because intermittent connectivity, drops, and retransmissions can look like attack traffic or can hide real attacks in noisy telemetry.

Layer 2 (Data Link) handles local network delivery with frames and MAC addresses. Ethernet, ARP behavior, VLAN tagging, and switch forwarding all live here. Security relevance includes rogue devices, ARP spoofing, VLAN mistakes, and switch misconfiguration. When analyzing east-west traffic, Layer 2 context helps explain why a host can reach another host directly or why a sensor on one VLAN sees nothing from another.

Layer 3 (Network) is where IP addressing and routing happen. IPv4/IPv6, subnets, gateways, routing tables, and ICMP diagnostics are central here. This is where defenders reason about source/destination IPs, network zones, path selection, and segmentation boundaries. A large portion of network security monitoring starts at Layer 3 because IP metadata remains visible even when payloads are encrypted.

Layer 4 (Transport) is where TCP and UDP behavior becomes critical. TCP handshakes, resets, retransmissions, windows, and ports help defenders determine whether a service is reachable, blocked, failing, or being probed. UDP traffic requires a different mindset because there may be no connection state, which changes how you detect scanning, floods, DNS abuse, or malformed traffic patterns.

Layer 5 (Session) is often less visible as a separate implementation layer in modern stacks, but the concept matters: session setup, maintenance, and teardown. For defenders, session thinking explains why authentication tokens, keep-alives, protocol state, and session reuse matter. Attackers often abuse session handling through token theft, replay, or session fixation, so understanding “who owns this session and how long it stays valid” is operationally important.

Layer 6 (Presentation) is about how data is represented: encoding, serialization, compression, and encryption. TLS is commonly discussed at this layer conceptually because it transforms plaintext into encrypted application data and negotiates cryptographic parameters. Defenders must understand that encryption changes visibility, but does not remove all observability: certificates, metadata, timing, sizes, and destination patterns still support detection.

Layer 7 (Application) is what users and analysts usually recognize first: HTTP, DNS, SMTP, SSH, APIs, authentication flows, and app-specific behavior. Many attacks blend in here by looking “normal” at lower layers while abusing application logic, credentials, or protocol semantics. Expert defenders learn normal application behavior deeply enough to spot odd methods, header patterns, query names, authentication prompts, and automation artifacts.

A practical way to teach yourself the stack is to trace one event through all layers. Example: a browser visits a website. Layer 1/2 provide link and local switching, Layer 3 routes to the destination, Layer 4 establishes TCP, Layer 5 maintains session state, Layer 6 negotiates TLS, and Layer 7 carries DNS/HTTP behavior. If the page fails to load, the OSI model helps you ask smarter questions in order instead of guessing randomly.

Use the OSI Model as a troubleshooting and detection framework, not as trivia. When you see an alert or outage, ask: Is this a link problem (L1), local reachability/ARP/VLAN issue (L2), routing/subnet issue (L3), port or handshake problem (L4), session/auth problem (L5), encoding/TLS issue (L6), or application logic problem (L7)? This layered approach makes investigations faster and more accurate.

Normal Behavior

A normal TCP handshake shows SYN -> SYN/ACK -> ACK before application data.

Failure / Abuse Pattern

TCP handshakes fail or retransmit heavily (path, filtering, or service health problem).

Evidence To Collect

Describe all seven OSI layers and map common protocols/telemetry to the correct layer.

3. DNS, HTTP, and TLS in a Real Request

A user requests a website. The endpoint first resolves a name via DNS (often through a local resolver, enterprise DNS, or encrypted DNS). Then it opens a TCP session (or QUIC/UDP for HTTP/3), negotiates TLS, and finally exchanges HTTP requests and responses.

Defenders should learn what is visible at each stage. DNS query names, resolver behavior, SNI (in many TLS cases), certificate metadata, timing, and destination IPs can all support detection even when payloads are encrypted.

HTTP semantics matter because attackers often abuse ordinary methods and headers. Understanding status codes, redirects, user agents, cookies, and APIs helps separate malicious automation from normal browser behavior.

Normal Behavior

Expected TLS negotiation completes before HTTP requests over HTTPS are visible as metadata only.

Failure / Abuse Pattern

TLS negotiation fails due to version/cipher/certificate mismatch.

Evidence To Collect

Trace a typical web request from DNS resolution through TLS and HTTP response.

4. Routing, Switching, and Security Visibility

Switches forward frames inside a LAN using MAC addresses, while routers move packets between networks using routing tables. This matters because SPAN/mirror ports, taps, and sensor placement determine what traffic your IDS can actually see.

Network defenders should know where NAT, load balancers, and proxies alter source/destination context. Misreading translated addresses is a common root cause for false assumptions during incident triage.

Routing asymmetry, VLAN boundaries, and cloud overlays can make traffic visibility incomplete. A good defender asks, “Where was this traffic captured, and what could be missing?” before making conclusions.

Normal Behavior

Normal DNS requests resolve quickly and are followed by connections to the returned IPs.

Failure / Abuse Pattern

DNS lookup succeeds but no TCP handshake follows (routing/firewall or application issue).

Evidence To Collect

Identify key control points: switches, routers, firewalls, reverse proxies, and DNS resolvers.

terminal-walkthroughs-with-example-output

These walkthroughs show representative commands plus example output so learners know what success and useful evidence look like. Treat the output as a pattern guide, not a fixed transcript.

Host And Resolver Checks

Beginner
Command
ip addr
Example Output
2: eth0    inet 10.10.20.15/24
3: eth1    inet 10.10.30.5/24

$ why this matters: Use this step to validate host and resolver checks before moving on to more advanced commands in the same block. Focus on interpreting the output, not just running the command.

HTTP / TLS Inspection Basics

Intermediate
Command
curl -I http://example.com
Example Output
HTTP/1.1 301 Moved Permanently
Location: https://example.com/

$ why this matters: Use this step to validate http / tls inspection basics before moving on to more advanced commands in the same block. Focus on interpreting the output, not just running the command.

Packet Capture Starter

Advanced
Command
sudo tcpdump -ni any host example.com -c 50
Example Output
IP 10.10.20.15.53422 > 93.184.216.34.443: Flags [S]
IP 93.184.216.34.443 > 10.10.20.15.53422: Flags [S.]

$ why this matters: Use this step to validate packet capture starter before moving on to more advanced commands in the same block. Focus on interpreting the output, not just running the command.

cli-labs-and-workflow

Run these commands only in environments you own or are explicitly authorized to test. Use a lab VM, sandbox network, or approved internal test segment for practice.

Host And Resolver Checks

Beginner
ip addr
ip route
resolvectl status || cat /etc/resolv.conf
dig example.com +short
dig example.com A +trace

Run in a lab or authorized environment. Record what fields change when you alter the test conditions.

HTTP / TLS Inspection Basics

Intermediate
curl -I http://example.com
curl -I https://example.com
curl -vk https://example.com/ 2>&1 | less
openssl s_client -connect example.com:443 -servername example.com </dev/null
ss -tupan | head

Run in a lab or authorized environment. Record what fields change when you alter the test conditions.

Packet Capture Starter

Advanced
sudo tcpdump -ni any host example.com -c 50
sudo tshark -i any -f 'host example.com' -a duration:20

Run in a lab or authorized environment. Record what fields change when you alter the test conditions.

expert-mode-study-loop

  • $Explain the concept in plain language without reading notes.
  • $Show how to validate the concept with logs, packets, or commands.
  • $Name at least one common failure mode and how to detect it.
  • $Document what 'normal' looks like before testing edge cases.
Progress marker: You are ready to move on when you can explain the topic, run the commands, and interpret the output without guessing.

knowledge-check-and-answer-key

Try answering these from memory before looking at the hints. These questions are designed to test understanding of concepts, dataflow, and evidence collection.

1. Protocol Stack and Data Flow

Questions
  • ?How would you explain "Protocol Stack and Data Flow" to a new defender in plain language?
  • ?What does normal behavior look like for protocol stack and data flow in your lab or environment?
  • ?Which logs, packets, or commands would you use to validate protocol stack and data flow?
  • ?What failure mode or attacker abuse pattern matters most for protocol stack and data flow?
Show answer key / hints
Answer Key / Hints
  • #Explain packet vs frame vs segment terminology and where each appears in the stack.
  • #Normal DNS requests resolve quickly and are followed by connections to the returned IPs.
  • #ip addr
  • #DNS lookup succeeds but no TCP handshake follows (routing/firewall or application issue).

2. OSI Model for Defenders (All 7 Layers, in Practice)

Questions
  • ?How would you explain "OSI Model for Defenders (All 7 Layers, in Practice)" to a new defender in plain language?
  • ?What does normal behavior look like for osi model for defenders (all 7 layers, in practice) in your lab or environment?
  • ?Which logs, packets, or commands would you use to validate osi model for defenders (all 7 layers, in practice)?
  • ?What failure mode or attacker abuse pattern matters most for osi model for defenders (all 7 layers, in practice)?
Show answer key / hints
Answer Key / Hints
  • #Describe all seven OSI layers and map common protocols/telemetry to the correct layer.
  • #A normal TCP handshake shows SYN -> SYN/ACK -> ACK before application data.
  • #curl -I http://example.com
  • #TCP handshakes fail or retransmit heavily (path, filtering, or service health problem).

3. DNS, HTTP, and TLS in a Real Request

Questions
  • ?How would you explain "DNS, HTTP, and TLS in a Real Request" to a new defender in plain language?
  • ?What does normal behavior look like for dns, http, and tls in a real request in your lab or environment?
  • ?Which logs, packets, or commands would you use to validate dns, http, and tls in a real request?
  • ?What failure mode or attacker abuse pattern matters most for dns, http, and tls in a real request?
Show answer key / hints
Answer Key / Hints
  • #Trace a typical web request from DNS resolution through TLS and HTTP response.
  • #Expected TLS negotiation completes before HTTP requests over HTTPS are visible as metadata only.
  • #sudo tcpdump -ni any host example.com -c 50
  • #TLS negotiation fails due to version/cipher/certificate mismatch.

4. Routing, Switching, and Security Visibility

Questions
  • ?How would you explain "Routing, Switching, and Security Visibility" to a new defender in plain language?
  • ?What does normal behavior look like for routing, switching, and security visibility in your lab or environment?
  • ?Which logs, packets, or commands would you use to validate routing, switching, and security visibility?
  • ?What failure mode or attacker abuse pattern matters most for routing, switching, and security visibility?
Show answer key / hints
Answer Key / Hints
  • #Identify key control points: switches, routers, firewalls, reverse proxies, and DNS resolvers.
  • #Normal DNS requests resolve quickly and are followed by connections to the returned IPs.
  • #Choose one CLI command and explain what fields you would inspect.
  • #DNS lookup succeeds but no TCP handshake follows (routing/firewall or application issue).

lab-answer-key-expected-findings

Use this as a baseline answer key for labs and walkthroughs. Replace these with environment-specific observations as you practice in real or simulated networks.

Expected Normal Findings
  • +Normal DNS requests resolve quickly and are followed by connections to the returned IPs.
  • +A normal TCP handshake shows SYN -> SYN/ACK -> ACK before application data.
  • +Expected TLS negotiation completes before HTTP requests over HTTPS are visible as metadata only.
Expected Failure / Anomaly Clues
  • !DNS lookup succeeds but no TCP handshake follows (routing/firewall or application issue).
  • !TCP handshakes fail or retransmit heavily (path, filtering, or service health problem).
  • !TLS negotiation fails due to version/cipher/certificate mismatch.

hands-on-labs

  • $Take one browser request and map each observed artifact (link status, ARP, IP, TCP/UDP, TLS, HTTP/DNS) to the OSI layer where it is most useful for troubleshooting.
  • $Capture a browser visit to a test site and annotate the DNS query, TCP handshake, TLS handshake, and first HTTP request/response.
  • $Compare the same site over HTTP and HTTPS in a lab to identify what telemetry remains visible when encryption is enabled.
  • $Document where a packet would traverse switch, router, NAT, and firewall in your home or lab network.

common-pitfalls

  • $Treating the OSI Model as memorization only instead of using it to structure troubleshooting and detection.
  • $Confusing ports with protocols (for example assuming port 443 always means safe web traffic).
  • $Treating “encrypted” as “invisible” and ignoring metadata-based detections.
  • $Ignoring capture location and making claims about traffic that a sensor could never observe.

completion-outputs

# A protocol flow diagram for one normal web transaction
# An OSI layer cheat sheet that maps common protocols, logs, and tools to each layer
# A glossary of core network terms used in your later learning modules
# A visibility map of where you can inspect traffic in your environment
<- learning index Back to the course map -> next page Subnetting, NAT, Firewall Policy Logic, and Segmentation Basics
learning-path-position

Foundations / Weeks 1-2 · Module 1 of 12