Networking Fundamentals for Cybersecurity
Why Networking Matters
Understanding networks is crucial for cybersecurity because:
- Most attacks happen over networks
- Penetration testing requires network knowledge
- Security tools operate at network level
- Incident response involves network analysis
OSI Model
The Open Systems Interconnection model has 7 layers:
Layer 7: Application
- Purpose: User interface and application services
- Protocols: HTTP, HTTPS, FTP, SMTP, DNS, SSH
- Attacks: Phishing, SQL injection, XSS
- Tools: Burp Suite, Wireshark
Layer 6: Presentation
- Purpose: Data translation, encryption, compression
- Functions: SSL/TLS, data formatting
- Security: Encryption protocols
Layer 5: Session
- Purpose: Establish, manage, terminate connections
- Examples: NetBIOS, RPC
- Attacks: Session hijacking
Layer 4: Transport
- Purpose: End-to-end communication, reliability
- Protocols: TCP (reliable), UDP (fast)
- Attacks: SYN flood, port scanning
- Tools: Nmap, Hping3
Layer 3: Network
- Purpose: Routing, logical addressing
- Protocol: IP (IPv4, IPv6), ICMP
- Devices: Routers
- Attacks: IP spoofing, routing attacks
- Tools: Traceroute, ping
Layer 2: Data Link
- Purpose: Physical addressing, error detection
- Protocol: Ethernet, ARP
- Addressing: MAC addresses
- Devices: Switches, bridges
- Attacks: ARP spoofing, MAC flooding
Layer 1: Physical
- Purpose: Physical transmission of bits
- Media: Cables, wireless, fiber
- Devices: Hubs, repeaters
- Attacks: Physical tapping, jamming
TCP/IP Model
Simplified 4-layer model:
- Application: HTTP, DNS, FTP, SSH
- Transport: TCP, UDP
- Internet: IP, ICMP, ARP
- Network Access: Ethernet, WiFi
IP Addressing
IPv4
- Format: 32-bit (4 octets)
- Example: 192.168.1.1
- Classes:
- Class A: 1.0.0.0 - 126.255.255.255 (large networks)
- Class B: 128.0.0.0 - 191.255.255.255 (medium)
- Class C: 192.0.0.0 - 223.255.255.255 (small)
Private IP Ranges
- 10.0.0.0/8
- 172.16.0.0/12
- 192.168.0.0/16
Subnetting
Network: 192.168.1.0/24
Subnet Mask: 255.255.255.0
Usable IPs: 192.168.1.1 - 192.168.1.254
Broadcast: 192.168.1.255
Total Hosts: 254
IPv6
- Format: 128-bit (8 groups of 4 hex digits)
- Example: 2001:0db8:85a3:0000:0000:8a2e:0370:7334
- Advantages: Larger address space, better security
Common Protocols
HTTP/HTTPS (Ports 80/443)
- Purpose: Web traffic
- Security: HTTPS adds TLS encryption
- Attacks: Man-in-the-middle, session hijacking
- Testing: Burp Suite, OWASP ZAP
DNS (Port 53)
- Purpose: Domain name resolution
- Types: A, AAAA, MX, CNAME, TXT
- Attacks: DNS spoofing, cache poisoning, tunneling
- Tools: dig, nslookup, dnsrecon
dig example.com
nslookup example.com
host example.com
SSH (Port 22)
- Purpose: Secure remote access
- Security: Encrypted communication
- Attacks: Brute force, key theft
- Best practices: Key-based auth, disable root login
FTP (Ports 20/21)
- Purpose: File transfer
- Security: Unencrypted (use SFTP/FTPS)
- Attacks: Credential sniffing, anonymous access
SMTP (Port 25, 587, 465)
- Purpose: Email transmission
- Attacks: Email spoofing, spam relay
- Tools: Swaks, sendEmail
SMB (Ports 139/445)
- Purpose: File/printer sharing
- Attacks: EternalBlue, pass-the-hash
- Tools: smbclient, enum4linux
TCP Three-Way Handshake
Client Server
| |
|----SYN (SEQ=100)----->|
| |
|<---SYN-ACK (SEQ=300,--|
| ACK=101) |
| |
|----ACK (ACK=301)----->|
| |
| Connection Established
Port Scanning
Port States
- Open: Service accepting connections
- Closed: No service, but reachable
- Filtered: Firewall blocking
Scan Types
nmap -sS target.com
nmap -sT target.com
nmap -sU target.com
nmap -sV target.com
nmap -O target.com
nmap -A target.com
nmap -p 80,443,8080 target.com
nmap -p 1-1000 target.com
Network Devices
Router
- Connects different networks
- Routes traffic based on IP
- Layer 3 device
Switch
- Connects devices in same network
- Forwards based on MAC address
- Layer 2 device
Firewall
- Filters traffic based on rules
- Can operate at multiple layers
- Types: Packet filtering, stateful, application
Load Balancer
- Distributes traffic across servers
- Improves availability and performance
Network Security Concepts
Firewall Rules
sudo ufw enable
sudo ufw allow 22/tcp
sudo ufw allow 80/tcp
sudo ufw deny 23/tcp
sudo ufw status
sudo iptables -A INPUT -p tcp --dport 22 -j ACCEPT
sudo iptables -A INPUT -p tcp --dport 80 -j ACCEPT
sudo iptables -P INPUT DROP
VPN (Virtual Private Network)
- Purpose: Secure remote access
- Protocols: OpenVPN, IPSec, WireGuard
- Benefits: Encryption, privacy, bypass restrictions
IDS/IPS
- IDS: Intrusion Detection System (monitors)
- IPS: Intrusion Prevention System (blocks)
- Tools: Snort, Suricata, Zeek
NAT (Network Address Translation)
- Translates private IPs to public
- Provides basic security
- Conserves IPv4 addresses
Network Reconnaissance
Passive Reconnaissance
whois example.com
dig example.com ANY
fierce -dns example.com
site:example.com
intitle:"index of"
Active Reconnaissance
nmap -sn 192.168.1.0/24
nmap -p- target.com
nmap -sV -sC target.com
traceroute target.com
Packet Analysis with Wireshark
Capture Filters
host 192.168.1.1
port 80
tcp
udp
icmp
Display Filters
ip.addr == 192.168.1.1
tcp.port == 80
http
dns
arp
Common Tasks
- Capture HTTP traffic
- Analyze TCP handshakes
- Detect ARP spoofing
- Find cleartext passwords
- Identify suspicious traffic
Network Attacks
ARP Spoofing
echo 1 > /proc/sys/net/ipv4/ip_forward
arpspoof -i eth0 -t victim gateway
arpspoof -i eth0 -t gateway victim
DNS Spoofing
- Redirect DNS queries
- Phishing attacks
- Man-in-the-middle
Port Scanning Detection
- Monitor for scan patterns
- Use IDS/IPS
- Implement rate limiting
Best Practices
- Segment networks: VLANs, DMZ
- Monitor traffic: IDS/IPS, SIEM
- Encrypt communications: VPN, TLS
- Regular updates: Patch network devices
- Strong authentication: Multi-factor
- Least privilege: Minimal access
- Backup configurations: Regular backups
Practice Exercises
- Set up a home lab with multiple VMs
- Perform network reconnaissance on your lab
- Capture and analyze traffic with Wireshark
- Configure firewall rules
- Practice ARP spoofing (ethically, in your lab)
- Scan for vulnerabilities with Nmap
- Set up and test a VPN
Next Module
Ready for Introduction to Penetration Testing!