Firewall
What is a Firewall?
A firewall is a network security system that monitors and controls incoming and outgoing network traffic based on predefined security rules. It acts as a barrier between trusted internal networks and untrusted external networks (such as the internet), blocking unauthorised access while allowing legitimate traffic.
Types of firewalls
Packet filter firewall
The simplest type of firewall inspects individual packets based on header information: source IP address, destination IP address, port numbers, and protocol (TCP/UDP). Packet filters operate at Layers 3 and 4 of the OSI model and are fast but lack context awareness.
Stateful inspection firewall
A stateful firewall tracks the state of active connections (TCP handshake states, UDP pseudo-states). It can distinguish between new connection attempts and packets belonging to established sessions. This prevents attacks that exploit the stateless nature of packet filters.
Application layer firewall (proxy firewall)
Application layer firewalls (Layers 5–7) understand specific application protocols (HTTP, FTP, DNS, SMTP). They can inspect content, not just headers, and detect application-level attacks such as SQL injection or cross-site scripting in HTTP traffic.
Next-Generation Firewall (NGFW)
NGFWs combine stateful inspection with deep packet inspection (DPI), application awareness (regardless of port), user identification, SSL/TLS inspection, intrusion prevention (IPS), and threat intelligence integration. They provide comprehensive visibility and control over network traffic.
Web Application Firewall (WAF)
A WAF specifically protects web applications from attacks targeting the HTTP layer: SQL injection, cross-site scripting (XSS), CSRF, and OWASP Top 10 vulnerabilities. WAFs can be deployed as hardware appliances, software, or cloud services.
Firewall architectures
Perimeter firewall
A traditional perimeter firewall protects the boundary between the internal network and the internet. This model assumes that everything inside is trusted, which is insufficient in modern environments with remote work and cloud services.
DMZ (Demilitarised Zone)
A DMZ is a network segment sitting between the internal network and the internet. Publicly accessible services (web servers, mail servers) are placed in the DMZ, isolated from the internal corporate network by a second firewall.
Zero Trust network architecture
The Zero Trust model abandons the concept of a trusted internal network entirely. Every connection, regardless of source, is verified and authorised. Micro-segmentation with firewalls between all network segments enforces least-privilege access.
Firewall rule best practices
- Default deny: Block all traffic by default; only explicitly allow what is necessary
- Least privilege: Allow only the minimum required ports and protocols
- Egress filtering: Monitor and control outbound traffic, not just inbound
- Regular review: Remove outdated rules; unused rules increase the attack surface
- Logging: Log all allowed and denied connections for security monitoring and forensics
Firewalls in cloud environments
Cloud providers offer native firewall capabilities: Security Groups (AWS, GCP) and Network Security Groups (Azure) control traffic at the VM level. Additional virtual firewall appliances or cloud-native NGFW services (AWS Network Firewall, Azure Firewall) provide advanced inspection capabilities for cloud workloads.
