Skip to main content

Welcome to a Grasp lesson

Create a free account to keep studying and create your own study path.

Lesson 8

Firewalls and NAT in Network Architecture

Recommended resources

Hello! Welcome to the final lesson in our first module, "Networking Fundamentals for Security."

In our previous lessons, we've built a solid understanding of how data travels across networks. We've covered the OSI model, IP addressing, subnetting, ARP, and finally, how ports direct data to the correct application on a device. You now know how a packet finds its way from a specific application on one computer to a specific application on another.

Today, we will address the learning outcome: Describe how firewalls and NAT function in network architecture. We'll explore two critical technologies that don't just enable communication but actively control and manage it. Firewalls act as the network's security guards, while Network Address Translation (NAT) acts as its receptionist. For an aspiring penetration tester, understanding these controls is non-negotiable, as they are often the first line of defense you will encounter and need to analyze.

Firewalls: The Network's Security Guards

A firewall is a network security device—either hardware or software—that monitors and filters incoming and outgoing network traffic based on an organization's predefined security policies. At its core, a firewall establishes a barrier between a trusted internal network and an untrusted external network, such as the internet.

Its job is to decide whether to allow or block specific traffic. It makes these decisions by inspecting data packets and comparing their characteristics against a set of rules. These rules are typically based on:

  • Source IP Address: Where the packet is from.
  • Destination IP Address: Where the packet is going.
  • Source and Destination Ports: Which applications are communicating.
  • Protocol: The type of traffic (e.g., TCP, UDP, ICMP).

Let's watch a video that illustrates how these rules are applied in a typical network architecture.

Cybersecurity Architecture: Networks

The video 'Cybersecurity Architecture: Networks' by IBM Technology provides a great visual explanation of how a basic packet-filtering firewall uses rules to control traffic flow between the internet, a web server, and an internal database.

Watch the segment from 01:21 to 04:54. Pay close attention to how the firewall rules are configured to only allow specific traffic (e.g., web traffic on port 80/443) to reach the web server, while blocking direct access to the internal database.

Stateless vs. Stateful Firewalls

The firewall described in the first part of that video is a basic packet-filtering firewall. This type is also known as a stateless firewall. It's called stateless because it evaluates each packet in complete isolation, without any memory of packets that came before it. It simply checks the packet's header against its rule list and makes a decision. While fast, this approach has limitations. It wouldn't know if a response packet it receives is part of a legitimate conversation or a spoofed packet sent by an attacker.

To address this, the stateful firewall was developed. A stateful firewall, or stateful packet inspection (SPI) firewall, is more intelligent. It monitors the state of active connections and uses this contextual information to make decisions. It maintains a "state table" that tracks details of every active session. When a packet arrives, the firewall first checks if it's part of an existing, legitimate conversation in its state table. If so, it's allowed through without needing to be re-evaluated against the full rule set. If it's a new connection request, it's evaluated against the rules to see if a new session should be established.

This statefulness allows the firewall to block unsolicited traffic more effectively. For instance, if it receives a reply packet from the internet for which it has no record of an outgoing request from the internal network, it will drop the packet, assuming it to be malicious or invalid.

To solidify your understanding of this critical distinction, please read the following article.

Firewalls: Stateless vs. Stateful

The article 'Firewalls: Stateless vs. Stateful' from Baeldung offers a clear, theoretical breakdown of these two firewall types.

Please read sections 3 ('Stateless Firewalls') and 4 ('Stateful Firewalls'). Focus on why a stateful firewall is more robust against attacks like spoofing by keeping track of connection states.

This image provides a great visual summary of the difference. A stateless firewall just uses its rule list (ACL), while a stateful firewall consults its dynamic state table.

Stateless vs. Stateful Firewall Comparison
This diagram shows how a stateless firewall processes traffic based on a static Access Control List (ACL), whereas a stateful firewall uses a dynamic State Table to track active connections and make context-aware decisions.

Firewalls in Network Architecture: The DMZ

One of the most important architectural functions of a firewall is network segmentation—dividing a network into smaller, isolated zones to contain threats. A classic example of this is the Demilitarized Zone (DMZ).

A DMZ is a perimeter network that protects an organization's internal network from an untrusted external network. It's a semi-trusted buffer zone that holds servers that need to be accessible from the internet, such as web, email, or DNS servers. By placing these public-facing servers in a DMZ, you isolate them from your trusted internal network. An attacker who compromises a web server in the DMZ is still blocked by a second firewall from reaching the critical internal assets.

The following video segment explains this concept of defense-in-depth using firewalls to create a DMZ.

Cybersecurity Architecture: Networks

Let's return to the 'Cybersecurity Architecture: Networks' video to see how firewalls are used to create various segmented architectures, including a basic and multi-tiered DMZ.

Watch the segment from 10:36 to 15:47. Focus on understanding the logic behind a basic DMZ (using two firewalls) and how it provides 'defense in depth'.


Network Address Translation (NAT)

Now let's turn to our second topic: Network Address Translation (NAT). While often found on the same device as a firewall, NAT serves a completely different purpose.

The primary driver for NAT was the exhaustion of IPv4 addresses. With billions of devices needing to connect to the internet, there simply aren't enough unique public IPv4 addresses to go around. NAT solves this by allowing a whole private network of devices (using private IP addresses like 192.168.x.x or 10.x.x.x) to share a single public IP address when accessing the internet.

This video provides an excellent introduction using a simple analogy.

Every Networking Concept Explained In 20 Minutes

The video 'Every Networking Concept Explained In 20 Minutes' by TechWorld with Nana uses a great receptionist analogy to explain the core function of NAT.

Watch from 07:30 to 10:14. This will clarify why NAT is necessary for private networks and how it translates addresses for outbound and inbound traffic.

How NAT Works "Under the Hood"

As the video explained, the NAT device (usually your router) acts as an intermediary.

  1. Outbound Traffic: When a device on your private network sends a packet to the internet, the router receives it. It replaces the packet's private source IP with its own public source IP. It records this translation in a NAT table. To handle multiple devices at once, it also translates the source port, a process called Port Address Translation (PAT) or NAT Overload.
  2. Inbound Traffic: When a response comes back from the internet, it's addressed to the router's public IP and the specific port assigned to that session. The router looks up this combination in its NAT table, finds the original internal device that made the request, and rewrites the destination IP and port back to the private ones before forwarding the packet.
Network Address Translation (NAT) Process Illustration
This diagram illustrates the NAT process. For outbound traffic, the router changes the private source IP (10.0.0.1) to its public IP (150.150.0.1). For inbound traffic, it reverses the process, changing the public destination IP back to the private one.

For a more detailed explanation of the translation table and the different types of NAT, please review the following resource.

What Is NAT (Network Address Translation)?

This article, 'What Is NAT (Network Address Translation)?', provides a deeper technical dive into how NAT functions, which aligns with your preference for theoretical understanding.

Read the sections 'What is NAT?', 'How does NAT work under the hood?', and 'Types of IP Addresses in NAT'. Focus on understanding the NAT table and the distinction between Static NAT, Dynamic NAT, and PAT (NAT Overload).

NAT vs. a Firewall

This is a critical point of clarification for anyone in security: NAT is not a firewall.

While NAT does provide a security benefit by hiding the internal IP address structure from the outside world, this is a byproduct of its primary function. Because the NAT device will drop any unsolicited inbound packets for which it has no entry in its translation table, it can feel like a firewall.

However, a true firewall performs deep inspection, enforces complex policies, and protects against a wide array of threats. NAT simply translates addresses. A firewall locks the door; NAT just hides the apartment number from the public directory.

The article you just read has an excellent section that clarifies this. I highly recommend re-reading this specific part.

What Is NAT (Network Address Translation)?

Let's revisit the CloudMyLab article to focus on the crucial distinction between NAT and a firewall.

Please read the subsection titled 'NAT vs Firewall Security'. This explicitly breaks down what NAT does and does not do from a security perspective.


Conclusion

This lesson concludes our foundational module on networking. We have examined the mechanisms that control and manage traffic at the network edge.

Key Takeaways:

  • Firewalls act as security guards, filtering traffic based on a set of rules. They are used for network segmentation to create zones like the DMZ.
  • Stateless firewalls inspect packets individually, while stateful firewalls track connection states, offering more robust security.
  • NAT acts as a receptionist, primarily to conserve IPv4 addresses by allowing many private IPs to share one public IP.
  • PAT (NAT Overload) is the most common form of NAT, using port numbers to manage multiple simultaneous connections through a single public IP.
  • NAT is not a firewall, although it provides a basic level of security by obscuring the internal network and dropping unsolicited inbound traffic.

You now have a strong theoretical foundation in networking principles crucial for ethical hacking. We've built the network; in the next module, we'll start learning how to secure the information that flows through it.

Preview of the Next Module:
Our next module is "Core Network Services and Cryptography." We will begin by exploring the three fundamental pillars of information security: confidentiality, integrity, and availability (the CIA triad). This will set the stage for understanding encryption, which is the bedrock of modern data protection.