Tutorial 4.7: Firewall Fundamentals and Architectures

πŸ“‘ Table of Contents

🎯 Learning Objectives

After completing this tutorial, you should be able to:


πŸ“– Overview

In the previous tutorials, we explored intrusion detection and prevention systems, which provide visibility and active blocking of attacks. However, before an attack even reaches an IDS/IPS, it must first traverse the network perimeter. The firewall is the first line of defense in most network architectures, acting as a gatekeeper that controls traffic based on a set of security rules. Firewalls are fundamental to any security strategy, providing network segmentation, access control, and a barrier between trusted and untrusted networks.

This tutorial introduces the fundamentals of firewalls, their objectives, and the architectural patterns used to deploy them. We begin by defining firewalls and their core functions, then explore the concept of security zonesβ€”how networks are divided into trust levels, with the perimeter as the boundary between internal and external realms. We examine the Demilitarized Zone (DMZ), a critical architectural component that hosts public-facing services while protecting internal networks.

We will discuss the different types of firewalls (packet filtering, stateful, application-layer, and next-generation) and their evolution. We then delve into deployment architectures: the screened host, screened subnet (DMZ), and dual-homed gateway, each offering a different balance of security and complexity. We also cover security policy development and rule set management, including best practices for writing effective firewall rules.

Finally, we assess the strengths and limitations of firewalls in modern environmentsβ€”especially with cloud, mobile, and encrypted trafficβ€”and how they complement other security controls. Real-world case studies illustrate firewall successes and failures. By the end of this tutorial, you will have a strong foundation in firewall fundamentals, preparing you for Tutorial 4.8, where we dive into specific firewall technologies and advanced deployment strategies.

This content aligns with Stallings & Brown (2024), Chapter 9 and incorporates NIST SP 800-41 and industry best practices.

1. Firewall Concepts and Objectives

1.1 What is a Firewall?

A firewall is a network security device (hardware or software) that monitors incoming and outgoing network traffic and decides whether to allow or block specific traffic based on a defined set of security rules. Firewalls are a critical component of network security, establishing a barrier between a trusted internal network and untrusted external networks (such as the Internet).

1.2 Primary Objectives

1.3 The Firewall in the Defense-in-Depth Model

Firewalls are often the first layer of defense at the network perimeter. In a defense-in-depth strategy, they are complemented by IDS/IPS, antivirus, endpoint protection, and security awareness training. The firewall enforces the initial access policy, while deeper layers handle threats that bypass the perimeter.

Key Takeaway: A firewall is a policy-based traffic control device that serves as the primary gatekeeper between trusted and untrusted networks.

2. Security Zones and Perimeter Security

2.1 The Concept of Security Zones

A security zone is a logical grouping of network resources that share the same security policy and trust level. Typical zones include:

2.2 Perimeter Security

The perimeter is the boundary between the internal network and the outside world. Firewalls are the primary enforcement point at the perimeter, but perimeter security also includes intrusion detection, VPN gateways, and web filtering. The goal is to prevent unauthorized access while allowing legitimate business traffic.

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ SECURITY ZONES EXAMPLE β”‚ β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€ β”‚ β”‚ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ β”‚ β”‚ Internet β”‚ (Untrusted) β”‚ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ β”‚ β”‚ β”‚ β”‚ β–Ό β”‚ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ β”‚ β”‚ Firewall β”‚ β”‚ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ β”‚ β”‚ β”‚ β”‚ β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ β”‚ β–Ό β–Ό β”‚ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ β”‚ β”‚ DMZ β”‚ β”‚ Internal β”‚ β”‚ β”‚ β”‚ (Web, Mail) β”‚ β”‚ (Trusted) β”‚ β”‚ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ β”‚ β–Ό β”‚ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ β”‚ β”‚ Database β”‚ β”‚ β”‚ β”‚ (Internal) β”‚ β”‚ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ β”‚ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Figure 1: Security Zones and Firewall Segmentation

Key Takeaway: Security zones enable granular control by assigning different trust levels to different parts of the network, and firewalls enforce the policies between these zones.

3. DMZ Architectures

3.1 What is a DMZ?

A Demilitarized Zone (DMZ) is a physical or logical subnetwork that contains and exposes an organization's external-facing services to an untrusted network, usually the Internet. The DMZ sits between the internal network and the external network, providing an additional layer of security. If an attacker compromises a server in the DMZ, they still cannot directly access the internal network because the firewall restricts traffic between the DMZ and internal zones.

3.2 Common DMZ Architectures

3.3 DMZ Best Practices

Key Takeaway: The DMZ is a critical architectural pattern that isolates public-facing services from internal assets, reducing the risk of internal compromise from external attacks.

4. Security Policies and Rule Sets

4.1 Security Policy Definition

A security policy is a high-level document that defines the organization's security objectives and acceptable use. For firewalls, the security policy translates into a set of rules that determine which traffic is allowed or denied. The policy should specify:

4.2 Rule Set Components

A typical firewall rule includes:

4.3 Rule Order and First-Match Principle

Firewalls typically evaluate rules in order (first-match). The first rule that matches the traffic determines the action. Therefore, the most specific rules should be placed first, followed by more general rules, and a default deny at the end. This is the default-deny policy.

4.4 Example Rule Set (Simplified)

Key Takeaway: A well-defined security policy and carefully ordered rule set are essential for effective firewall operation. The principle of least privilege should guide rule creation.

5. Types of Firewalls (Overview)

Firewalls have evolved over time, from simple packet filters to sophisticated next-generation firewalls. We will cover these in detail in Tutorial 4.8, but here we provide a brief overview.

Type Description Key Characteristics
Packet Filtering Examines headers (IP, TCP, UDP) only. Stateless; fast; simple; vulnerable to spoofing.
Stateful Firewall Tracks connection state (e.g., SYN/ACK). Stateful; more secure; remembers sessions.
Application/Proxy Firewall Inspects application-layer payload (e.g., HTTP). Deep inspection; can block specific content; slower.
Next-Generation Firewall (NGFW) Combines stateful, application awareness, IPS, and threat intelligence. Integrated; user identity; granular control.

Table 1: Firewall Types Overview

6. Firewall Deployment Architectures

The placement of firewalls in a network defines the security architecture. Below are common deployment models.

6.1 Screened Host Architecture

A single host (bastion host) is placed on the perimeter, acting as a gateway that provides controlled access to internal services. The firewall filters traffic to and from this host. Internal hosts are protected but may be less segmented.

6.2 Screened Subnet Architecture (DMZ)

As described in Section 3, this uses a firewall (or two) to create a DMZ where public-facing servers reside. This is the most common enterprise architecture.

6.3 Dual-Homed Gateway

A host with two network interfaces: one connected to the external network, one to the internal network. It has no routing enabled; traffic must pass through proxy services (application-level firewall). This is an older model, less common now.

6.4 Multiple Firewalls (Layered)

Some organizations deploy multiple firewalls in series, each with different policies, to provide defense-in-depth. For example, an outer firewall handles broad Internet threats, while an inner firewall enforces stricter internal segmentation.

6.5 Cloud and Virtual Firewalls

In cloud environments (AWS, Azure), firewalls are often virtualized (e.g., AWS Security Groups, Azure NSGs) or implemented as virtual appliances (e.g., Palo Alto VM-Series). These provide similar functionality but are adapted to dynamic, elastic environments.

Key Takeaway: Firewall deployment architecture varies from simple single-firewall setups to complex multi-tiered designs, depending on the organization's security requirements and network complexity.

7. Policy Design and Rule Management

7.1 Principles of Rule Design

7.2 Rule Lifecycle Management

7.3 Example: Rule Set for a Web Server in DMZ

# Allow inbound HTTPS from external to web server allow source any dest web-server-ip proto tcp port 443 # Allow inbound HTTP (redirect to HTTPS if needed) allow source any dest web-server-ip proto tcp port 80 # Allow web server to outbound to database (internal) allow source web-server-ip dest db-server-ip proto tcp port 3306 # Allow web server to update (outbound to Internet) allow source web-server-ip dest any proto tcp port 80,443 # Deny everything else deny any any any

8. Strengths and Limitations

8.1 Strengths

8.2 Limitations

Key Takeaway: Firewalls are essential but not sufficient; they must be complemented with other controls (IDS/IPS, DLP, endpoint security) to provide comprehensive protection.

9. Real-World Case Studies

9.1 Case Study: Misconfigured Firewall Exposes Data

A healthcare organization had a firewall rule that inadvertently allowed inbound RDP (port 3389) from any external IP to an internal server. Attackers discovered this and brute-forced the credentials, gaining access to patient records. The breach was discovered when the hospital's IDS alerted on unusual outbound data transfers. The lesson: regularly audit firewall rules, restrict RDP to specific IPs, and use VPNs for remote access.

9.2 Case Study: DMZ Design Prevents Lateral Movement

A financial institution suffered an attack on its public web server in the DMZ. The attacker exploited a vulnerability in the web application and gained shell access. However, because the firewall strictly limited traffic from the DMZ to the internal network (only allowing web server to database on port 3306), the attacker could not move laterally to the corporate network. The database was also isolated, limiting the damage. This demonstrates the value of a well-designed DMZ.

9.3 Case Study: Firewall Bypass via Encrypted Tunnel

An organization allowed outbound SSH traffic from internal hosts to the Internet. An attacker used a compromised internal host to establish an SSH tunnel to an external C2 server, effectively bypassing the firewall's inspection. The firewall could not see the tunneled payload. This highlights the need for advanced threat detection (e.g., anomaly detection, DPI) and stricter outbound policies.

πŸ“Œ Summary

This tutorial provided a comprehensive introduction to firewalls, their fundamentals, and architectural patterns. We defined a firewall as a network security device that controls traffic based on policies, serving as the primary gatekeeper between trusted and untrusted networks. We explored the concept of security zonesβ€”untrusted, trusted, DMZβ€”and how firewalls enforce policies between these zones.

We examined the DMZ as a critical architectural component that isolates public-facing servers, reducing the risk of internal compromise. We discussed the importance of a well-defined security policy and rule sets, emphasizing the default-deny principle and rule ordering. We also reviewed the major types of firewalls (packet filtering, stateful, application, NGFW) and common deployment architectures (screened host, screened subnet, dual-homed gateway, multi-tiered).

We addressed the strengths (access control, segmentation) and limitations (encrypted traffic, insider threats, complexity) of firewalls, stressing that they must be part of a layered defense. Real-world case studies illustrated both successful firewall deployments and failures due to misconfiguration or limitations.

The overarching message is that firewalls are foundational to network security, but they are not a silver bullet. They must be properly configured, regularly audited, and complemented with detection, prevention, and response technologies. In the next tutorial (4.8), we will dive deeper into specific firewall technologies, including packet filtering, stateful inspection, application firewalls, and next-generation firewalls, along with advanced deployment strategies.

Next: Tutorial 4.8: Firewall Technologies and Deployment Strategies.

πŸ“ Quiz

1. What is the primary function of a firewall?

Answer
B. Control network traffic based on security rules.

2. Which security zone typically hosts public-facing web servers?

Answer
B. DMZ.

3. In a firewall rule set, which rule should be placed at the end?

Answer
B. A default deny rule.

4. Which firewall type inspects application-layer data such as HTTP commands?

Answer
C. Application-layer firewall / proxy.

5. What is the main benefit of a screened subnet (DMZ) architecture?

Answer
B. It isolates external-facing services from the internal network.

6. Which of the following is a limitation of traditional firewalls?

Answer
B. They cannot inspect encrypted traffic without decryption.

7. In the dual-homed gateway architecture, the gateway has:

Answer
B. Two network interfaces.

8. What is the principle of least privilege in firewall rule design?

Answer
B. Allow only what is necessary, block the rest.

9. Which firewall architecture uses two firewalls to separate the DMZ from both the Internet and the internal network?

Answer
B. Screened subnet (dual firewall).

10. Why is rule order important in a firewall?

Answer
B. Because the first matching rule determines the action.

11. Which of the following is NOT a typical component of a firewall rule?

Answer
C. Packet payload content (this is typically not part of a rule; it's part of deep inspection).

12. In a defense-in-depth strategy, firewalls are considered which type of control?

Answer
B. Preventive.

πŸ› οΈ Exercises

Exercise 1: Rule Set Design Intermediate

Design a firewall rule set for a small company with the following requirements:

Write the rules in order, specifying source, destination, service, and action.

Sample Solution
  • Rule 1: Allow external any to DMZ web (10.0.0.10) TCP 80,443 β†’ Allow
  • Rule 2: Allow external any to DMZ mail (10.0.0.20) TCP 25,143,993 β†’ Allow
  • Rule 3: Allow internal (192.168.1.0/24) to external any TCP 80,443,53 β†’ Allow
  • Rule 4: Allow internal to external DNS (UDP 53) β†’ Allow
  • Rule 5: Allow DMZ web (10.0.0.10) to internal DB (192.168.1.50) TCP 3306 β†’ Allow
  • Rule 6: Deny any any any β†’ Deny

Ensure specific rules are ordered before the default deny.

Exercise 2: Architectural Choice Intermediate

An organization is planning to host a public web application and an email server. They have a single firewall and want to maximize security. Compare the screened host and screened subnet architectures. Which would you recommend and why?

Sample Solution

Screened host: Places the public servers on the internal network (or directly connected to the firewall) with limited access. This is less secure because any compromise of the public servers could provide access to internal resources.

Screened subnet (DMZ): Places the servers in a separate DMZ with its own security policies, isolating them from internal network. This is more secure because even if a DMZ server is compromised, the attacker cannot directly access internal systems (only specific allowed ports).

Recommendation: Screened subnet for better isolation and security, especially since they have multiple public servers.

Exercise 3: Firewall Rule Analysis Advanced

Analyze the following firewall rule set. Identify at least three security issues and propose improvements.

Rule 1: allow source any dest any proto tcp port 80,443 Rule 2: allow source 10.0.0.0/8 dest any proto tcp port 22 Rule 3: allow source any dest 192.168.1.0/24 proto tcp port 3389 Rule 4: deny any any
Sample Solution

Issues:

  • Rule 1 allows HTTP/HTTPS from anywhere to anywhere, which is too permissive (allows internal servers to be accessed from the Internet). Should be restricted to specific servers (e.g., DMZ).
  • Rule 2 allows SSH from 10.0.0.0/8 (probably internal) to any destination. This could allow internal hosts to SSH to any external server, which may be acceptable but could be abused for data exfiltration. Should restrict destinations.
  • Rule 3 allows RDP from any source to the entire internal network. This is a severe security riskβ€”should only allow from specific IPs (e.g., VPN subnet) and to specific hosts.
  • No logging rules; cannot audit.

Improvements: Restrict source/destination; implement a default-deny; add logging; use application-aware rules if possible.

Exercise 4: DMZ Security Policy Intermediate

Write a security policy for a DMZ that includes a web server, an application server, and a database server. The web server must communicate with the application server, which in turn connects to the database. All servers are in the DMZ. Define the traffic rules between these servers and the outside world, and between the DMZ and the internal network.

Sample Solution

External to DMZ:

  • Allow HTTP/HTTPS to web server (TCP 80,443).
  • Allow (optional) SSH to web server for administration from specific IPs.

Within DMZ:

  • Allow web server to application server on relevant port (e.g., TCP 8080).
  • Allow application server to database server on TCP 3306 (MySQL).

DMZ to Internal:

  • Only allow necessary outbound: e.g., web server to update packages (HTTP/HTTPS), application server to internal logging (if needed).
  • Block all other outbound traffic from DMZ to internal.

Internal to DMZ:

  • Allow administrators from internal to SSH/HTTPS to management interfaces of DMZ servers (limited IPs).

Default: Deny all other traffic.

Exercise 5: Evaluating Firewall Limitations Advanced

An organization relies solely on a perimeter firewall for security. They have no IDS/IPS and no internal segmentation. Discuss the risks of this approach, and propose a layered defense strategy that includes firewalls but also addresses their limitations.

Sample Solution

Risks:

  • Insider threats and lateral movement are not addressed (once an attacker is inside, they have free reign).
  • Encrypted traffic (TLS) cannot be inspected, allowing malware C2.
  • Application-layer attacks (e.g., SQL injection) may bypass the firewall if not using NGFW.
  • Single point of failure.

Proposed layered strategy:

  • Use a next-generation firewall with IPS and application awareness.
  • Deploy internal firewalls or ACLs to segment the network (e.g., separate finance, R&D).
  • Deploy IDS/IPS in critical segments.
  • Implement endpoint detection and response (EDR) on all hosts.
  • Enable logging and integrate with SIEM for correlation.
  • Regularly audit firewall rules and perform penetration testing.

πŸ“š Homework

Homework 1: Write a 1,500-word essay on the evolution of firewalls from simple packet filters to next-generation firewalls (NGFW). Discuss the technological advancements that led to each generation, the security benefits, and the challenges of managing modern firewalls. Include at least three references.

Sample Answer

Key points: Packet filters (stateless) β†’ stateful inspection β†’ application proxies β†’ NGFW (integrated IPS, user identity, threat intelligence). Each step added more context awareness. NGFW helps with encrypted traffic (via SSL decryption) and application identification. Management challenges: complexity, performance, cost.

Homework 2: Research and document the firewall configuration best practices as recommended by NIST (SP 800-41) and SANS. Create a checklist of at least 20 items that a security administrator should follow when deploying a firewall. Group them into categories (e.g., policy, rule set, management, logging).

Sample Answer

Sample checklist categories: Policy (default-deny, least privilege), Rule Set (specific order, use objects), Management (change control, regular reviews), Logging (enable logging for all rules, forward to SIEM), High Availability (redundant firewalls), Patching (keep firmware up to date), Testing (test rules in staging). Provide at least 20 items.

Homework 3: A medium-sized enterprise has a single firewall with a DMZ. They are expanding to a second office and a cloud presence. Design a firewall architecture that integrates on-premises firewalls, cloud security groups, and VPN connectivity. Write a 1,000-word design document that includes a diagram (ASCII or described) and a justification for each component.

Sample Answer

Design outline: Use a perimeter firewall at each office (NGFW). Use cloud-native firewalls (e.g., AWS Security Groups, Azure NSGs) for cloud VPC. Connect offices via site-to-site VPN (IPsec) and cloud via VPN. Ensure consistent policy across all environments using a centralized management platform. Justification: segmentation, redundancy, scalability.

Homework 4: Write a critical analysis of the effectiveness of firewalls in the era of Zero Trust networking. Discuss how the Zero Trust model challenges traditional perimeter-based firewall thinking, and propose how firewalls must evolve to support Zero Trust architectures. Include examples of micro-segmentation and software-defined perimeter concepts.

Sample Answer

Key arguments: Zero Trust assumes no implicit trust, even inside the network. Traditional firewalls rely on perimeter trust. In Zero Trust, firewalls are still used for micro-segmentation but must be policy-enforcement points with granular, identity-based rules. Software-defined perimeters (SDP) and Zero Trust Network Access (ZTNA) complement firewalls. Firewalls need to integrate with identity providers and continuous monitoring.

Homework 5: Investigate a recent firewall-related security incident (e.g., a firewall misconfiguration that led to a breach). Write a case study that includes the incident details, the root cause (e.g., rule misconfiguration, lack of auditing), the impact, and the lessons learned. Provide recommendations to prevent similar incidents.

Sample Answer

Example: The 2021 attack on Colonial Pipeline involved a compromised VPN password, but also a firewall misconfiguration that allowed inbound access to the VPN from the Internet. The lesson: restrict VPN access to specific IPs, enforce MFA, and regularly audit firewall rules.


COMP400 – Computer and Network Security (Revision 3) • Unit 4: Security Systems and Models