Part 3 of the "Hacking from Zero" series
Networking Fundamentals Every Hacker Must Know
"To hack a network, you must first understand it."
Understanding networks is foundational โ you can memorize tools but lack effectiveness without grasping why ports exist, how data moves, or what DNS does. This guide covers networking concepts repeatedly encountered in TryHackMe and real penetration testing work.
๐ The OSI Model โ The 7 Layers Explained
The OSI framework describes how data travels between machines. You'll encounter this constantly in cybersecurity contexts.
| Layer | Name | What It Does | Hacker Relevance |
|---|---|---|---|
| 7 | Application | User-facing protocols (HTTP, FTP, DNS) | SQL injection, XSS, web attacks |
| 6 | Presentation | Encryption, encoding, compression | SSL/TLS stripping, encoding attacks |
| 5 | Session | Manages sessions between devices | Session hijacking |
| 4 | Transport | TCP/UDP โ reliable delivery | Port scanning, DoS |
| 3 | Network | IP addressing, routing | IP spoofing, MITM |
| 2 | Data Link | MAC addresses, switches | ARP poisoning, MAC spoofing |
| 1 | Physical | Cables, signals, hardware | Physical access attacks |
Memory trick: "Please Do Not Throw Sausage Pizza Away" (Physical, Data Link, Network, Transport, Session, Presentation, Application)
As a hacker, you'll primarily work at Layers 3โ7. Understanding all 7 helps you know where in the stack an attack occurs.
๐ฆ TCP vs UDP โ The Two Transport Protocols
Everything on the internet travels via either TCP or UDP at the Transport layer (Layer 4).
TCP โ Transmission Control Protocol
TCP is reliable. It guarantees that data arrives, in order, without errors. It does this via a three-way handshake:
Client โ SYN โ Server (I want to connect)
Client โ SYN-ACK โ Server (OK, I'm ready)
Client โ ACK โ Server (Great, let's go)
Why hackers care:
- Nmap's SYN scan (-sS) exploits this handshake โ it sends a SYN but never completes the connection, making it stealthier
- TCP sequence numbers can be predicted in some attacks (session hijacking)
- SYN flood attacks overwhelm servers by sending thousands of SYN packets without completing handshakes
Used by: HTTP, HTTPS, SSH, FTP, SMTP โ most services you'll target
UDP โ User Datagram Protocol
UDP is fast but unreliable. It fires packets and doesn't check if they arrived. No handshake.
Why hackers care:
- UDP services are often overlooked โ always scan with -sU
- DNS (port 53) runs on UDP โ DNS poisoning attacks live here
- SNMP (port 161) runs on UDP โ often misconfigured and leaks system info
Used by: DNS, DHCP, SNMP, VoIP, online gaming
๐ข IP Addresses & Subnetting
IPv4
An IP address is a 32-bit number written as four octets:
192.168.1.100
Each octet is 0โ255. There are roughly 4.3 billion possible IPv4 addresses โ almost all assigned.
Private IP ranges (not routable on the internet):
| Range | Common Use |
|---|---|
| 10.0.0.0โ10.255.255.255 | Large corporate networks |
| 172.16.0.0โ172.31.255.255 | Medium networks |
| 192.168.0.0โ192.168.255.255 | Home networks |
On TryHackMe, target machines are typically in the 10.10.x.x range.
Subnetting & CIDR Notation
A subnet divides a network into smaller segments. CIDR notation tells you how many bits are used for the network vs host:
192.168.1.0/24 โ 256 addresses (192.168.1.0 โ 192.168.1.255)
10.0.0.0/8 โ 16,777,216 addresses
192.168.1.0/30 โ 4 addresses (useful for point-to-point links)
Why hackers care: Knowing the subnet tells you how many hosts to scan. If you're on 10.10.10.0/24, there are up to 254 live hosts to discover.
Scan a whole subnet with Nmap:
nmap -sn 10.10.10.0/24 # Ping sweep โ find live hosts
IPv6
128-bit addresses written in hex:
2001:0db8:85a3:0000:0000:8a2e:0370:7334
IPv6 is increasingly relevant. Many tools and firewalls are configured for IPv4 only โ IPv6 is sometimes a blind spot worth probing.
๐ How the Internet Works: A Packet's Journey
When you type https://tryhackme.com in your browser, here's what actually happens:
- DNS lookup โ Your computer asks, "What's the IP address for tryhackme.com?"
- TCP handshake โ Your browser connects to that IP on port 443
- TLS handshake โ Encryption is negotiated
- HTTP request โ Your browser asks for the webpage
- HTTP response โ The server sends the HTML back
- Rendering โ Your browser displays it
Each step is an attack surface. DNS can be poisoned. TLS can be stripped. HTTP can be intercepted. This is why understanding the full journey matters.
๐ DNS โ The Internet's Phone Book
DNS (Domain Name System) translates human-readable domain names into IP addresses.
tryhackme.com โ DNS lookup โ 104.22.55.228
DNS Record Types
| Record | Purpose | Hacker Relevance |
|---|---|---|
| A | Domain โ IPv4 address | Basic lookup |
| AAAA | Domain โ IPv6 address | IPv6 recon |
| MX | Mail server for domain | Email spoofing recon |
| CNAME | Alias for another domain | Subdomain takeover |
| TXT | Arbitrary text (SPF, DKIM) | Recon, email security checks |
| NS | Nameservers for domain | DNS zone transfers |
| PTR | IP โ domain (reverse DNS) | Reverse lookups |
DNS Enumeration (Hacker's Perspective)
# Basic lookup
nslookup tryhackme.com
# Dig โ more powerful
dig tryhackme.com
dig tryhackme.com MX # Mail servers
dig tryhackme.com TXT # TXT records
dig tryhackme.com ANY # All records
# Zone transfer attempt (finds ALL subdomains if misconfigured)
dig axfr @ns1.tryhackme.com tryhackme.com
# Subdomain brute-force (with gobuster)
gobuster dns -d tryhackme.com -w /usr/share/wordlists/subdomains.txt
Zone transfers are a classic misconfiguration โ a DNS server that allows zone transfers will dump every single subdomain and IP address for the domain. Always try it.
๐ ARP โ Connecting IPs to MAC Addresses
ARP (Address Resolution Protocol) works at Layer 2. When a device wants to send data to 192.168.1.5, it broadcasts, "Who has 192.168.1.5?" and the device with that IP replies with its MAC address.
ARP Poisoning / ARP Spoofing: An attacker sends fake ARP replies, claiming their MAC address belongs to the gateway's IP. All traffic meant for the gateway now flows through the attacker โ a classic Man-in-the-Middle (MITM) attack.
# View your ARP table
arp -a
# ARP poisoning with arpspoof (for labs only)
arpspoof -i eth0 -t 192.168.1.5 192.168.1.1
๐ช Common Ports โ The Hacker's Cheat Sheet
Knowing common ports cold will save you time on every CTF:
| Port | Protocol | Service | Notes |
|---|---|---|---|
| 21 | TCP | FTP | Check anonymous login |
| 22 | TCP | SSH | Brute-force with Hydra |
| 23 | TCP | Telnet | Unencrypted โ sniff traffic |
| 25 | TCP | SMTP | Email relay attacks |
| 53 | TCP/UDP | DNS | Zone transfer, poisoning |
| 80 | TCP | HTTP | Full web attack surface |
| 110 | TCP | POP3 | Email retrieval |
| 139/445 | TCP | SMB | EternalBlue, pass-the-hash |
| 443 | TCP | HTTPS | HTTPS web attacks |
| 3306 | TCP | MySQL | DB dumping if exposed |
| 3389 | TCP | RDP | Brute-force, BlueKeep |
| 5985 | TCP | WinRM | Windows remote management |
| 8080 | TCP | HTTP-alt | Dev servers, Jenkins |
๐ NAT, DHCP, and Firewalls (Quick Overview)
NAT (Network Address Translation)
Allows many private IP devices to share one public IP. Your home router does this. In pentests, NAT is why you can't directly reach internal machines from outside โ you need to pivot.
DHCP
Automatically assigns IP addresses to devices on a network. On TryHackMe's VPN, your machine gets a 10.x.x.x address via DHCP.
Firewalls
Filter traffic based on rules (IP, port, protocol). Two types:
- Stateless โ checks each packet in isolation
- Stateful โ tracks connection state, smarter
Hacker implication: Firewalls block certain ports. When Nmap shows a port as filtered, a firewall is likely dropping your packets. Techniques like firewall evasion (-f for fragmentation, -D for decoys) can help.
๐ ๏ธ Essential Networking Commands
# Your IP address
ip a
ifconfig # older systems
# Routing table
ip route
route -n
# Active connections
ss -tulpn
netstat -tulpn # older systems
# DNS lookup
nslookup google.com
dig google.com
# Trace the route to a host
traceroute google.com
tracert google.com # Windows
# Check if host is alive
ping 10.10.10.10
# ARP table
arp -a
# Download a file
wget http://10.10.10.10/file.txt
curl http://10.10.10.10/file.txt
๐ฏ Practice These on TryHackMe
| Room | What You'll Learn |
|---|---|
| Intro to Networking | OSI model, TCP/IP in depth |
| How The Web Works | DNS, HTTP, cookies, and end-to-end |
| DNS in Detail | Every record type, zone transfers |
| HTTP in Detail | Requests, responses, methods, status codes |
| Packet Analysis (Wireshark) | See real packets flowing |
| Introductory Networking | Subnetting, routing, ARP |
๐งฉ Putting It All Together
Here's how networking knowledge directly translates to attack techniques:
| Concept | Attack-Enabled |
|---|---|
| DNS records | Subdomain enumeration, zone transfer |
| ARP | MITM via ARP poisoning |
| TCP handshake | SYN flood, session hijacking |
| Open ports | Vulnerability targeting |
| Subnets | Host discovery, lateral movement |
| SMB (445) | EternalBlue, pass-the-hash |
| Firewalls | Evasion, port knocking |
Every concept in networking has an offensive equivalent. That's why understanding the fundamentals isn't just academic โ it directly makes you a better attacker (and defender).
๐ What's Next
Now that you can scan with Nmap and understand the network you're scanning, it's time to put it all together in a real room. Next, a full walkthrough of the RootMe room on TryHackMe โ one of the most popular beginner rooms that covers web exploitation and privilege escalation from start to finish.
- โ Getting Started with TryHackMe โ Learning Path Overview
- โ Nmap Deep Dive: The Hacker's Swiss Army Knife
- โ (You are here) Networking Fundamentals Every Hacker Must Know
- โ TryHackMe Walkthrough: RootMe Room
- โ OSINT: How Hackers Find Information About You