Lab 01: OSI Model Deep Dive
π― Objective
Understand the 7 layers of the OSI model by using real network tools to observe each layer in action. By the end of this lab, you will be able to map network activities to specific OSI layers and explain why layering matters for security.
π Background
The OSI (Open Systems Interconnection) model is a conceptual framework that standardizes how different network systems communicate. Think of it like the postal system: you write a letter (application layer), put it in an envelope (presentation/session), hand it to a postal worker (transport), who routes it through the postal network (network), puts it on a truck (data link), and drives on a road (physical).
There are 7 layers:
Layer 7 β Application: What users interact with (HTTP, DNS, FTP)
Layer 6 β Presentation: Data format, encryption, compression (TLS/SSL)
Layer 5 β Session: Managing connections between applications
Layer 4 β Transport: End-to-end delivery, ports (TCP, UDP)
Layer 3 β Network: IP addressing and routing
Layer 2 β Data Link: MAC addresses, switches, frames
Layer 1 β Physical: Cables, Wi-Fi signals, bits
Security professionals use the OSI model to identify where an attack is happening. A DDoS might target Layer 3/4, while phishing targets Layer 7. Understanding layers helps you choose the right defense.
β±οΈ Estimated Time
45 minutes
π Prerequisites
Basic familiarity with Linux command line
Docker installed and
innozverse-cybersecimage available
π οΈ Tools Used
curlβ Application layer (HTTP requests)ipβ Network and Data Link layer inspectionss/netstatβ Transport layer socket infocat /proc/net/devβ Physical/Data Link interface stats
π¬ Lab Instructions
Step 1: Observe Layer 7 (Application) β HTTP with curl
The Application layer is what end-users see. HTTP is a Layer 7 protocol. curl lets us see the raw HTTP communication happening at this layer.
πΈ Verified Output:
π‘ What this means: These are HTTP response headers from the web server.
HTTP/1.1 200 OKmeans the server understood our request and responded successfully. TheContent-Type: text/htmltells the browser how to render the content. TheCF-RAYheader reveals this site uses Cloudflare (a CDN). This is purely Layer 7 information β the application-level conversation.
Step 2: Observe Layer 4 (Transport) β TCP Sockets with ss
The Transport layer handles end-to-end communication using ports. TCP provides reliable, ordered delivery. Let's see what transport-layer sockets are active.
πΈ Verified Output:
π‘ What this means:
ss -tulnshows TCP (-t) and UDP (-u) sockets that are listening (-l) with numeric ports (-n). In a fresh container there are no listening services, so the output is empty. On a real server you'd see ports like 22 (SSH), 80 (HTTP), 443 (HTTPS) listed here. The port number is the Layer 4 concept β it tells the OS which application should receive the data.
Step 3: Create a TCP Connection to See Layer 4 in Action
Let's demonstrate a TCP connection using netcat (nc):
πΈ Verified Output:
π‘ What this means: We created a TCP connection on port 9999. The server listened (
nc -l -p 9999), the client connected to127.0.0.1:9999. TCP performed a 3-way handshake (SYN β SYN-ACK β ACK) invisibly, then data was exchanged. This is Layer 4 (transport) using Layer 3 (IP address 127.0.0.1) to get there.
Step 4: Observe Layer 3 (Network) β IP Routing
The Network layer handles IP addressing and routing β deciding HOW data gets from point A to point B.
πΈ Verified Output:
π‘ What this means: This is the routing table β the Layer 3 map.
default via 172.17.0.1means "for any IP I don't know how to reach directly, send it to 172.17.0.1 (the gateway/router)." The172.17.0.0/16line means "for IPs in this subnet, I can reach them directly viaeth0." The/16is a subnet mask β it means the first 16 bits are the network address, leaving 16 bits for hosts (65,534 possible hosts).
Step 5: Observe Layer 2 (Data Link) β MAC Addresses
The Data Link layer uses MAC addresses to deliver frames within a local network. Every network interface has a unique MAC address.
πΈ Verified Output:
π‘ What this means:
lois the loopback interface (127.0.0.1) β it routes traffic back to itself.eth0is the actual network interface with MAC address62:ef:c5:e9:ab:9a. MAC addresses are 48-bit hardware addresses used at Layer 2. Unlike IP addresses (Layer 3), MAC addresses don't cross routers β they're only used within a single network segment.
Step 6: Observe Layer 1 (Physical) β Interface Statistics
Layer 1 is the physical medium β cables, Wi-Fi signals. We can observe Layer 1 effects by looking at bytes transmitted/received.
πΈ Verified Output:
π‘ What this means: This shows interface statistics.
eth0has received 1108 bytes across 10 packets and sent 706 bytes. Theerrsanddropcolumns show errors β these would be non-zero if there were physical layer problems (bad cable, signal interference).0 errorsmeans our Layer 1 connection is clean.
Step 7: Understand the Security Implications of Each Layer
Different attacks target different layers:
πΈ Verified Output:
π‘ What this means: Each layer has its own attack surface. A Web Application Firewall (WAF) defends Layer 7. A firewall defends Layer 3/4. Encryption (TLS) protects Layer 6. Physical security protects Layer 1. Defense-in-depth means protecting every layer.
Step 8: Trace a Complete Request Through All Layers
Let's make an HTTP request and think through each layer it passes through:
πΈ Verified Output:
π‘ What this means: Watch how the layers stack: DNS resolved
example.comto93.184.216.34(Layer 3 addressing). TCP connected to port 80 (Layer 4 transport). Then the HTTP GET request was made (Layer 7 application). All 7 layers worked together invisibly!
Step 9: Examine DNS β the Address Book of the Internet
DNS (Domain Name System) works at Layer 7 but interacts with Layer 3 to convert names to IP addresses:
πΈ Verified Output:
π‘ What this means: DNS returned
142.251.34.142as the IP forgoogle.com. TheArecord is IPv4,AAAAis IPv6,MXis the mail server. Without DNS, you'd have to memorize IP addresses instead of domain names. This is why DNS poisoning attacks are so dangerous β an attacker who can corrupt DNS can redirect you to fake websites.
Step 10: OSI Layer Summary Challenge
Let's verify your understanding:
πΈ Verified Output:
π‘ What this means: Each of these is a real-world security concern. HTTPS (Layer 6) protects data in transit. ARP poisoning (Layer 2) enables man-in-the-middle attacks. Port-based firewalls work at Layer 4. Understanding which layer an attack targets tells you which defense to deploy.
β
Verification
Run this final check to confirm you understand the OSI model:
πΈ Verified Output:
π¨ Common Mistakes
Confusing Layer 7 with "everything": People often think security is only about web apps (Layer 7). Physical security, network segmentation, and protocol security are equally important.
Forgetting that layers depend on each other: HTTPS (Layer 6/7) still travels over TCP (Layer 4) and IP (Layer 3). Breaking a lower layer breaks everything above it.
Assuming encryption makes you safe at all layers: TLS protects Layer 6 data, but an ARP poisoning attack (Layer 2) can still intercept traffic before it's encrypted.
π Summary
The OSI model has 7 layers, each responsible for a specific aspect of network communication
Each layer has its own security concerns and attack surface β defense-in-depth means protecting every layer
Tools like
curl,ip,ss, anddiglet us directly observe different OSI layers in actionWhen analyzing a security incident, identifying the OSI layer helps determine the correct response and defense
π Further Reading
Last updated
