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.

Intermediate 4 min readLesson 14 of 15

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

AttackLayerWhat happensMain defences
Sniffing1–2Reading traffic on a shared or compromised networkEncryption everywhere (TLS, WPA3)
ARP spoofing2Posing as the gateway to intercept a LAN's trafficDynamic ARP inspection, TLS
IP spoofing3Forging source addresses (used in floods and reflection)Ingress filtering (BCP 38)
Man-in-the-middleAnyIntercepting and possibly altering a conversationTLS with certificate validation, HSTS, mTLS
DNS spoofing / poisoning7Redirecting names to attacker IPsDNSSEC, DoH/DoT, TLS (the attacker still lacks a valid certificate)
BGP hijacking3Announcing someone else's prefixesRPKI, monitoring
Port scanning4Finding open services (nmap)Minimal exposure, firewalls
DDoS3–7Overwhelming bandwidth, connections or app resourcesAnycast, CDNs, scrubbing, rate limiting

DDoS in more detail

TypeExampleMitigation
VolumetricUDP 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
ProtocolSYN floods exhausting connection tablesSYN 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.

KindDecides usingExamples
Packet filter (stateless)IPs, ports, protocol of each packetRouter ACLs, cloud network ACLs
StatefulAlso connection state: replies to allowed outbound connections are allowed automaticallyiptables/nftables, cloud security groups
Application / next-genApplication protocols, users, contentPalo Alto, WAFs for HTTP
WAFHTTP requests: blocks SQL injection, XSS patterns, bad botsCloudflare, AWS WAF, ModSecurity

Principle: default deny. Allow only what's needed, from the narrowest sources.

Shell
# 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/tcp

Network segmentation

Split the network into zones so a compromise in one doesn't expose everything:

443 only80805432InternetPublic subnetload balancers, WAFPrivate app subnetData subnetno internet route

Kubernetes NetworkPolicies apply the same idea between pods.

VPNs

A VPN creates an encrypted tunnel across an untrusted network.

UseExample
Remote access to a private networkEmployees connecting to the office or VPC
Site-to-siteLinking two offices, or on-premises to the cloud
Privacy on untrusted Wi-FiConsumer 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).

Key takeaways
  • 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.