Network Security Basics
Threats on the network (sniffing, spoofing, MITM, DDoS), firewalls and security groups, VPNs, segmentation and zero trust, and how they fit together.
Networks were designed for cooperation, not defence: IP addresses can be spoofed, ARP and BGP trust whoever answers, and much traffic used to be plain text. Network security adds controls at every layer, but the modern view is that the network itself is hostile and every connection must be authenticated and encrypted.
Common attacks
| Attack | Layer | What happens | Main defences |
|---|---|---|---|
| Sniffing | 1–2 | Reading traffic on a shared or compromised network | Encryption everywhere (TLS, WPA3) |
| ARP spoofing | 2 | Posing as the gateway to intercept a LAN's traffic | Dynamic ARP inspection, TLS |
| IP spoofing | 3 | Forging source addresses (used in floods and reflection) | Ingress filtering (BCP 38) |
| Man-in-the-middle | Any | Intercepting and possibly altering a conversation | TLS with certificate validation, HSTS, mTLS |
| DNS spoofing / poisoning | 7 | Redirecting names to attacker IPs | DNSSEC, DoH/DoT, TLS (the attacker still lacks a valid certificate) |
| BGP hijacking | 3 | Announcing someone else's prefixes | RPKI, monitoring |
| Port scanning | 4 | Finding open services (nmap) | Minimal exposure, firewalls |
| DDoS | 3–7 | Overwhelming bandwidth, connections or app resources | Anycast, CDNs, scrubbing, rate limiting |
DDoS in more detail
| Type | Example | Mitigation |
|---|---|---|
| Volumetric | UDP floods; amplification via open DNS, NTP or memcached servers (a small spoofed request triggers a huge reply to the victim) | Upstream scrubbing, anycast CDNs with Tbps of capacity |
| Protocol | SYN floods exhausting connection tables | SYN cookies, stateless filtering |
| Application (L7) | Floods of expensive HTTP requests (search, login) | WAF rules, rate limiting, caching, CAPTCHAs, bot detection |
Firewalls
A firewall allows or denies traffic based on rules.
| Kind | Decides using | Examples |
|---|---|---|
| Packet filter (stateless) | IPs, ports, protocol of each packet | Router ACLs, cloud network ACLs |
| Stateful | Also connection state: replies to allowed outbound connections are allowed automatically | iptables/nftables, cloud security groups |
| Application / next-gen | Application protocols, users, content | Palo Alto, WAFs for HTTP |
| WAF | HTTP requests: blocks SQL injection, XSS patterns, bad bots | Cloudflare, AWS WAF, ModSecurity |
Principle: default deny. Allow only what's needed, from the narrowest sources.
# Linux (ufw front end to netfilter)
ufw default deny incoming
ufw allow from 10.0.0.0/16 to any port 5432 proto tcp # Postgres only from the VPC
ufw allow 443/tcpNetwork segmentation
Split the network into zones so a compromise in one doesn't expose everything:
Kubernetes NetworkPolicies apply the same idea between pods.
VPNs
A VPN creates an encrypted tunnel across an untrusted network.
| Use | Example |
|---|---|
| Remote access to a private network | Employees connecting to the office or VPC |
| Site-to-site | Linking two offices, or on-premises to the cloud |
| Privacy on untrusted Wi-Fi | Consumer VPNs |
Protocols: WireGuard (modern, small, fast), IPsec (standard for site-to-site), OpenVPN (TLS-based).
Zero trust
The old castle-and-moat model trusted anything inside the network perimeter. Once an attacker got in (phishing, a compromised laptop), they could move laterally freely. Zero trust says:
- Never trust the network location; authenticate and authorise every request.
- Verify user identity (SSO, MFA) and device health for every access.
- Grant least privilege, per application rather than per network.
- Encrypt everything, including internal traffic (mTLS between services).
Implementations: identity-aware proxies (Google BeyondCorp, Cloudflare Access, Tailscale), service meshes with mTLS, short-lived credentials.
Detection and monitoring
- IDS/IPS (intrusion detection/prevention, e.g. Suricata, Zeek) inspect traffic for attack signatures and anomalies.
- Flow logs (VPC flow logs, NetFlow) record who talked to whom, for investigations.
- SIEM systems correlate logs from many sources and alert.
Defence in depth
No single control is enough. Layer them: encryption (TLS everywhere) + identity (MFA, mTLS) + least-privilege firewalls and segmentation + patching + monitoring + DDoS protection + secure application code (Web security).
- Assume the network is hostile: encrypt and authenticate everything.
- Know the attacks: sniffing, spoofing, MITM, DNS/BGP hijacks, DDoS (volumetric, protocol, L7).
- Firewalls and security groups should default-deny and expose the minimum.
- Segment networks so breaches can't spread; VPNs tunnel across untrusted networks.
- Zero trust replaces perimeter trust with per-request identity and device checks.