Firewalls, VPNs and OS security
Clear, exam-focused notes on firewalls, VPNs and operating-system security: definitions, principles, rule logic, VPN modes and encryption basics, OS hardening and permissions, with worked examples and exam tips.
Drafted with Aria, reviewed by the AiCanCode.org team · Updated . How we write and check our notes. Spotted an error? Use Give Feedback at the bottom of the page.
Why it matters
A network engineer or security engineer uses firewalls to enforce access rules between networks, and uses VPNs to create secure, private links over untrusted networks. An operating-system (OS) engineer or sysadmin uses OS security controls (permissions, services, patching, auditing) to reduce attack surface and preserve confidentiality, integrity and availability of systems.
Key ideas
Firewall (defined): A firewall is a device or software that enforces an access-control policy on network traffic flowing between two or more networks. Assumption: traffic is observable and can be classified by headers or content.
- Types (define each when first used): Packet-filtering firewall — inspects packet headers (IP addresses, ports, protocol) and makes allow/deny decisions per packet. Stateful firewall — keeps track of connection state (e.g., TCP handshake) and allows packets related to established connections. Proxy / Application-layer firewall — understands application protocols (HTTP, FTP) and can inspect or modify payloads; acts as an intermediary. Next-Generation Firewall (NGFW) — combines stateful inspection, application awareness, intrusion prevention, and often TLS inspection.
- Policy principles: Implicit deny (default deny) — if no rule matches, deny the traffic. Principle of least privilege — allow only minimal traffic required. Rules are evaluated in order; earlier matching rule applies unless the firewall supports rule priorities.
- Rule elements: source IP, destination IP, source port, destination port, protocol, interface, time, action (allow/deny), logging. For stateful firewalls also connection state (NEW, ESTABLISHED, RELATED).
VPN (defined): A Virtual Private Network (VPN) is a secure tunnel that carries packets between endpoints across an untrusted network, providing confidentiality and integrity. Two main tunnel types: tunnel mode (encapsulates entire original IP packet inside a new IP header) and transport mode (protects payload only, original IP header remains). Assumption: endpoints share keys/certificates.
- Common VPN technologies: IPsec (used at the network layer; can operate in transport or tunnel mode; uses AH for authentication and ESP for encryption and/or integrity; note AH is not NAT-friendly and is rarely used on the public Internet; ESP with IKEv2 and NAT-T is common), TLS-based VPNs (e.g., OpenVPN; tunnels using TLS over TCP or DTLS over UDP—above the transport layer), IKE (Internet Key Exchange) for key management, L2TP over IPsec, WireGuard (modern, simpler crypto protocol).
- Security properties: encryption (confidentiality), message authentication codes or signatures (integrity & authentication), replay protection (sequence numbers) and anti-replay windows.
OS security (defined): Operating-system security are mechanisms inside the OS and its configuration that control access to files, processes, network services, and hardware. Components: user accounts and authentication, file permissions and access control lists (ACLs), process isolation, kernel hardening, secure boot, auditing/logging, patch management, service minimisation.
- Unix/Linux permission basics: owner/group/other read-write-execute bits; special bits SUID/SGID/sticky. SUID (set-user-ID) — when set on an executable, the process runs with the file owner's privileges; dangerous if used on internet-facing programs. SGID (set-group-ID) — on an executable, the process runs with the file's group; on a directory, new files inherit the directory's group. Sticky bit — on a directory, only the file's owner (or root) can delete/rename files within it. Capabilities — fine-grained kernel privileges to avoid full root where possible.
- Windows basics: user accounts, UAC (User Account Control), NTFS permissions, Local Security Policy, Windows Firewall, patching via WSUS/Windows Update.
Connection between topics: Firewalls control what traffic reaches hosts; VPNs protect traffic across untrusted segments; OS security protects the hosts when traffic reaches them. These complement but do not replace each other.
Diagrams to draw (describe exactly):
- Firewall placement: draw three boxes left-to-right labelled 'Internet', 'Firewall', 'LAN'. Draw arrows for traffic; label a DMZ as a subnet between two firewalls or as a zone on the external side with a server icon. Label bastion hosts in DMZ. Show rule table beside firewall: Rule 1: allow TCP 80 to DMZ webserver; Rule 2: deny all inbound.
- VPN tunnel: draw two LANs separated by the Internet. Between the two gateways draw a pipe labelled 'IPsec tunnel (ESP)'. Inside the pipe draw an example original packet with source/dest private IPs; outside the pipe show new outer IP headers with public IPs.
Formulas
Effective_throughput = link_rate × (payload_size / (payload_size + overhead_per_packet)) — link_rate in bits per second (bps), sizes in bits. Use to estimate impact of added headers on VPN throughput.
C = E_k(P) — ciphertext C is the encryption of plaintext P with key k. Symbols: C (ciphertext, bits), E_k (encryption function under key k), P (plaintext, bits). Applies to symmetric encryption.
MAC = H_k(P) — message authentication code computed with key k on P. Symbols: MAC (authentication tag), H_k (MAC function), P (message). Applies when integrity is separate from encryption.
Note: cryptographic formulas are schematic; actual algorithms (AES, HMAC, SHA) have specified block and tag sizes.
Worked examples
Firewall rule evaluation (logical): Problem: Given the following ordered rules on a packet-filter firewall between Internet and LAN, and the packet info, decide action.
- Rule 1: allow tcp dst-port=22 to 203.0.113.10
- Rule 2: allow tcp dst-port=80 to 203.0.113.20 from any
- Rule 3: allow tcp dst-port=80 to 198.51.100.5 from 203.0.113.0/24
- Rule 4: deny all Packet: source IP 198.51.100.50, source port 52340, destination IP 203.0.113.20, destination port 80, protocol tcp. Steps:
- Check Rule 1: destination port 22? No (packet port 80) → no match.
- Check Rule 2: dst-port 80 to 203.0.113.20 from any → match. Action = allow. Answer: Allowed. (Explain: first matching rule wins; implicit deny would block if no match.)
VPN MTU and overhead estimation (protocol-tracing style): Problem: Link MTU = 1500 bytes. Using IPsec ESP in tunnel mode adds outer IP header + ESP header + possible padding and ESP trailer. For this exercise assume combined overhead = 60 bytes. What is the maximum inner IP packet size that will not fragment after encapsulation? Steps:
- Original outer MTU = 1500 bytes.
- Encapsulation adds 60 bytes, so maximum inner packet size = 1500 − 60 = 1440 bytes.
- If inner IP packet is larger than 1440 bytes, fragmentation will occur (or DF flag will cause ICMP need-to-fragment message). Answer: Maximum inner-packet size 1440 bytes. (Note: overhead value used is an example; exact ESP overhead depends on algorithms and options.)
OS-hardening model answer (theory question): Question: Describe five OS-hardening steps you would perform after installing a Linux server exposed to the Internet. Model answer (points expected in full-marks answer):
- Disable or remove unnecessary services and daemons (explain why).
- Apply latest security patches and enable unattended security updates where appropriate (mention kernel and userland packages).
- Configure iptables/nftables or host-based firewall to allow only required ports; enable logging for denied packets.
- Create least-privilege user accounts, disable root SSH login, use key-based authentication, and configure sudo for administrative tasks.
- Enable file-system protections: mount options (noexec, nodev, nosuid where applicable), set proper ownership and permissions, minimise SUID binaries; enable SELinux/AppArmor for mandatory access control.
- Plus: enable secure logging and centralise logs, configure auditd for important files, and perform regular backups and integrity checks (e.g., AIDE). State why each reduces risk.
Common mistakes
- Confusing packet-filter and stateful firewall behaviour — e.g., assuming return packets allowed without state tracking when using a pure stateless packet filter.
- Forgetting implicit deny: students sometimes list only allow rules and forget to state the default deny policy.
- Mixing VPN modes: saying 'tunnel mode preserves the original IP header' (wrong — transport mode preserves it; tunnel mode encapsulates entire packet).
- Overlooking MTU/fragmentation effects when adding VPN headers — leads to incorrect throughput estimates.
- In OS security questions, giving only a checklist without explaining how each step reduces risk.
For your exam
- Short notes: types of firewalls, IPsec components, VPN use-cases, OS-hardening checklist. Full marks: named types, short working principle, pros/cons and a short diagram or command example if asked.
- Derivations/logic: rule-evaluation trace for firewall tables; explain connection tracking state transitions (SYN→SYN-ACK→ACK). Full marks: step-by-step state changes and rule matching logic.
- Numericals: MTU and throughput impact, effective payload after encryption overhead. Full marks: write formula, substitute numbers with units, show intermediate steps, final answer with units and note on assumptions.
- Diagrams: place firewall(s), DMZ, VPN tunnel between gateways. Full marks: neat labelled boxes, arrows for traffic, labels for interfaces and policies.
Quick check
- What is the principle of 'implicit deny' in firewall policy?
- Name two differences between IPsec tunnel mode and transport mode.
- What does the SUID bit do on a Unix executable? Answers: 1) If no rule matches, deny the traffic (default deny). 2) Tunnel mode encapsulates entire IP packet and uses new outer IP header; transport mode protects payload only and preserves original IP header. 3) When SUID set, the executable runs with the file owner's privileges (often root) rather than the calling user's privileges.
Finished this topic? Mark it so your progress, study plan and readiness keep up.
Stuck on something here?