Home›Knowledge Bank›Cybersecurity›What Is a Firewall? Types and How They Protect Networks
Cybersecurity

What Is a Firewall? Types and How They Protect Networks

A plain-English guide to firewalls, how they filter traffic, and why they're the foundation of network security.

Share
Quick answer

A firewall is a network security device or software that monitors incoming and outgoing traffic and blocks or allows it based on a defined set of security rules. It acts as a checkpoint between trusted internal networks and untrusted external ones, such as the internet. Firewalls are the baseline control that most other network defenses are built around.

Every enterprise network, from a five-person startup to a global bank, relies on some form of traffic control to decide what gets in and what stays out. That control point is almost always a firewall. This guide breaks down what a firewall actually does, the different types you'll encounter in real environments, where they sit in a network architecture, and how to configure rules without creating gaps or chaos.

What Is a Firewall?

A firewall is a security device or piece of software that monitors and controls network traffic based on a defined set of rules. It sits between networks of different trust levels and decides what traffic is allowed to pass.

The core concept is the trusted-vs-untrusted network boundary. Your internal corporate network is trusted; the public internet is not. The firewall is the checkpoint between them, inspecting everything that tries to cross.

Think of it as a gatekeeper standing at the entrance of a building. It checks IDs, consults a guest list, and either waves people through or turns them away. A firewall does the same thing with data packets instead of people.

How Firewalls Work

Firewalls make decisions using rules, often called Access Control Lists (ACLs). Each rule describes a pattern of traffic and an action: allow or deny.

To match traffic against these rules, a firewall examines packet headers rather than the full content of the data. These headers contain:

  • Source and destination IP addresses — identifying where traffic originates and where it's headed.
  • Ports — numbers that indicate which service or application the traffic is meant for.
  • Protocols — such as TCP, UDP, or ICMP, defining how the communication is structured.

Based on these details, the firewall makes an allow or deny decision for every packet or connection attempt. The order and specificity of rules matters enormously, since most firewalls process rules top-down and stop at the first match.

A key distinction is stateful vs stateless inspection. A stateless firewall evaluates each packet in isolation, with no memory of previous traffic. A stateful firewall tracks the state of active connections, so it can recognize that an inbound packet is a legitimate reply to an outbound request rather than a new, unsolicited connection.

Master the right skills for your goal

Not sure which path fits? Get a free 1:1 consultation with our team.

Related courses

Types of Firewalls

Firewalls have evolved considerably, and most networks today use a mix of types layered together.

  • Packet-filtering firewalls are the simplest form, checking headers against static rules without tracking connection state.
  • Stateful inspection firewalls add connection awareness, making them far better at distinguishing legitimate return traffic from new, potentially malicious attempts.
  • Proxy or application-layer firewalls act as intermediaries, fully terminating a connection and inspecting the actual application data before forwarding it, which allows deeper scrutiny at the cost of some performance.
  • Next-generation firewalls (NGFW) combine traditional filtering with intrusion prevention, application awareness, and deep packet inspection, letting them identify traffic by the application generating it rather than just the port it uses.
  • Cloud and web application firewalls protect specific workloads or web applications, filtering HTTP/HTTPS traffic for threats like injection attacks, and are commonly deployed alongside major cloud provider platforms.

Where Firewalls Sit in a Network

Firewall placement is as important as the firewall itself. A single device at the edge of the network is no longer considered sufficient protection.

  • Perimeter firewalls sit at the boundary between the internal network and the internet, filtering traffic entering and leaving the organization as a whole.
  • Internal segmentation firewalls divide the internal network into smaller zones, so a compromise in one area doesn't automatically grant access to everything else.
  • DMZs (demilitarized zones) are isolated network segments that host public-facing services, such as web servers, separating them from sensitive internal systems.
  • Host-based firewalls run directly on individual servers or endpoints, providing a last line of defense even if perimeter controls are bypassed.
  • Cloud security groups function as the modern, software-defined equivalent of firewalls, controlling traffic to and from individual cloud resources or Kubernetes environments at a much more granular level.

A firewall doesn't make your network safe — it makes your network's exposure deliberate. Everything it allows through is a choice someone made, which means every misconfigured rule is also a choice, just an invisible one.

Why Firewalls Matter

Firewalls mitigate a wide range of threats by simply reducing the attack surface available to outsiders. Unused ports, unnecessary services, and unsolicited connection attempts are blocked before they ever reach a vulnerable system.

They also play a direct role in compliance. Many regulatory frameworks and security standards explicitly require documented network segmentation and traffic filtering controls as a baseline expectation.

Most importantly, a firewall is typically the first line of defense against unauthorized access. It won't stop every attacker, but it forces anyone probing your network to work harder and leaves a trail of logged attempts that defenders can act on.

Setting Up and Managing Firewall Rules

A well-configured firewall is only as good as the rule set behind it. Poorly ordered or overly permissive rules can undo most of the protection the device is meant to provide.

  • Default-deny posture: start by blocking everything, then explicitly allow only the traffic that's required. This is far safer than starting open and trying to block threats as they appear.
  • Least privilege: grant only the access a system or user genuinely needs, nothing more. Broad "allow all" rules are a common source of breaches.
  • Rule ordering: place more specific rules above general ones, since most firewalls stop evaluating at the first match. A broad allow rule placed too early can silently override the deny rules below it.
  • Logging: enable logging on deny rules at minimum, and review logs regularly. Unexplained spikes in blocked traffic often indicate reconnaissance or an active attack.
  • Regular audits: remove rules that are no longer needed. Firewall rule sets tend to accumulate cruft over the years as projects end and systems get decommissioned.

Common pitfalls include forgetting to remove temporary "test" rules, duplicating rules across devices inconsistently, and failing to document why a rule exists in the first place. When a rule's purpose isn't documented, nobody feels safe removing it, and the rule set only ever grows.

These principles overlap heavily with the mindset behind zero trust security, where access is never assumed and must be continually verified rather than granted by default once a connection is established.

A Worked Example: Rules for a Small Web Server

Abstract principles are easier to apply once you've walked through a concrete scenario. Imagine a small company running a single public-facing web server that also needs to be managed remotely by an administrator. The server hosts HTTPS traffic for customers and needs occasional SSH access for maintenance, and nothing else should be reachable from the outside.

Following a default-deny posture, the rule set might look like this, evaluated top-down:

  • Allow inbound TCP 443 from any source to the web server's IP address, since customers worldwide need to reach the HTTPS service.
  • Allow inbound TCP 22 only from the administrator's known static IP address, rather than from any source, since SSH is a far more sensitive entry point than a web port.
  • Deny all other inbound traffic, including ICMP ping requests if there's no operational need to expose them, closing off every port and protocol not explicitly required.
  • Allow outbound traffic needed for the server to function, such as DNS lookups and software update checks, while still denying unsolicited outbound connections that might indicate malware trying to call home.

Notice what's absent as much as what's present. There's no rule for TCP 3389 (RDP), no broad "allow all internal" rule, and no SSH access from arbitrary addresses. If the administrator's IP address changes, that one rule gets updated rather than loosened into a wildcard "just to be safe." This is the practical shape that least privilege and default-deny take once they leave the abstract and meet a real box sitting on the internet.

Now contrast that with a mistake seen constantly in audits: a rule allowing inbound TCP 22 from 0.0.0.0/0 "temporarily" during initial setup, which is never revisited. Within days, automated scanners across the internet will find that open port and begin brute-forcing credentials against it. The difference between a secure server and a compromised one, in this example, is a single overly broad source address that nobody circled back to fix.

Troubleshooting Firewall Issues

Even a carefully designed rule set will eventually produce a support ticket from someone whose application "suddenly stopped working," and firewalls are frequently the first suspect. A structured approach saves hours compared to guessing.

  • Check the logs first. Most firewalls will log a denied connection attempt, including the source, destination, port, and the rule that triggered the block. This single step resolves the majority of "is it the firewall?" questions immediately.
  • Confirm rule order, not just rule existence. It's common to find that the correct allow rule exists, but a broader deny rule placed above it is intercepting the traffic first. Reordering, not rewriting, is often the actual fix.
  • Verify both directions. A stateful firewall usually handles return traffic automatically, but in segmented environments with multiple firewalls in a path, it's easy for one hop to allow outbound traffic while another silently blocks the response.
  • Isolate the firewall from other possible causes. DNS failures, expired certificates, and application-level errors all produce symptoms that look identical to a blocked connection. A quick packet capture on both sides of the firewall will usually show whether traffic is arriving at all.
  • Test from the same vantage point the real traffic uses. A connectivity test run from the administrator's own machine, which may sit on an already-trusted segment, can pass even when the actual client population is being blocked. Testing from a representative location avoids false reassurance.

A useful habit is keeping a simple change log alongside the firewall configuration itself, noting who changed which rule, when, and why. When an issue appears right after a deployment, that log turns a long investigation into a two-minute diff review. Firewalls rarely fail silently without a traceable cause; the challenge is almost always visibility into what changed and when, which is exactly what good logging and documentation are meant to solve.

Common Misconceptions About Firewalls

Firewalls are essential, but they're frequently misunderstood, and that misunderstanding leads to false confidence.

  • "A firewall stops all attacks": it doesn't. Firewalls filter traffic based on rules, but they can't inspect encrypted payloads in depth without additional tools, and they do nothing against threats that arrive through legitimate, allowed channels like email attachments or compromised credentials.
  • "Firewalls are outdated": this misreads what modern firewalls have become. NGFWs, cloud security groups, and web application firewalls are firewalls in function even if they don't look like the boxy appliances of decades past.
  • "One firewall is enough": a single perimeter device offers minimal protection against threats that originate inside the network, which is why internal segmentation and host-based firewalls matter.
  • "Firewalls replace other security practices": they don't substitute for patching, strong authentication, or user awareness. Many successful intrusions rely on social engineering or exploiting vulnerabilities that a firewall was never designed to catch, which is part of why organizations also invest in ethical hacking techniques to find those gaps before attackers do.

Understanding both what a firewall does and what it leaves uncovered is the real skill here. It's a foundational control, not a complete security strategy on its own, and treating it as the latter is how breaches happen despite a seemingly well-defended perimeter.

For a structured, hands-on path in this area, explore the the Network Security Course programme.

Key takeaways
  • A firewall filters traffic based on rules; it decides what network traffic is allowed in or out, not what happens after traffic is permitted.
  • Stateful firewalls track active connections and are now the default standard, replacing simple stateless packet filtering.
  • Next-generation firewalls (NGFWs) add application awareness and intrusion prevention on top of basic traffic filtering.
  • A firewall is a necessary foundation, not a complete security strategy; it should be layered with endpoint, identity, and monitoring controls.
  • In cloud environments, security groups and network ACLs serve the same role as traditional firewalls and require the same rule discipline.

Glossary

  • Firewall: A device or software that filters network traffic based on a defined set of security rules.
  • Packet filtering: Inspecting the header of each data packet (source, destination, port) to decide whether to allow or block it.
  • Stateful inspection: A filtering method that tracks the state of active connections rather than evaluating each packet in isolation.
  • Next-generation firewall (NGFW): A firewall that adds deep packet inspection, application identification, and intrusion prevention to standard filtering.
  • DMZ (demilitarized zone): A network segment isolated between the internet and the internal network, used to host public-facing servers safely.
  • Access control list (ACL): The ordered set of rules a firewall uses to determine which traffic to permit or deny.
The Skill Path

Learning Network Security Course: from concept to capability

Understanding the concept is the start. Being able to apply it is a separate skill, and it follows a fairly consistent path — this is the arc a structured programme takes you through.

The typical learning arc

  1. *{position:relative;z-index:1} .ci-header{display:flex;align-items:flex-start;justify-cont
  2. Network Security Foundations
  3. Protocols and Network Attacks
  4. Firewalls and Network Segmentation
  5. Intrusion Detection and Prevention
  6. VPNs and Secure Remote Access
  7. Wireless and Endpoint Security
  8. Monitoring and Incident Response

The concrete skills it builds

*{position:relative;z-index:1} .ci-header{display:flex;align-items:flex-start;justify-cont · Network Security Foundations · Protocols and Network Attacks · Firewalls and Network Segmentation · Intrusion Detection and Prevention · VPNs and Secure Remote Access · Wireless and Endpoint Security · Monitoring and Incident Response

Want a structured, instructor-led path through all of this — with hands-on projects and real feedback? → Network Security Course

Frequently asked questions

Is a firewall enough to protect a network?

No. A firewall blocks unauthorized traffic based on rules, but it doesn't detect malware on an endpoint, stop phishing, or catch insider misuse. Most organizations pair firewalls with antivirus, intrusion detection, and endpoint protection for layered defense.

What's the difference between a hardware and software firewall?

A hardware firewall is a dedicated physical appliance that filters traffic for an entire network, typically placed at the perimeter. A software firewall runs on an individual device and only protects that machine, which is why most enterprises use both.

Do I need a firewall if I use cloud services?

Yes, though it may look different. Cloud providers offer security groups, network ACLs, and web application firewalls (WAFs) that perform the same filtering function as traditional firewalls, just configured through a console or API instead of physical hardware.

Can a firewall stop ransomware?

A firewall can block the network connections ransomware uses to spread or communicate with command-and-control servers, but it can't stop ransomware delivered through a trusted channel like an email attachment someone opens. It's one layer, not a complete solution.

What is a next-generation firewall (NGFW)?

An NGFW adds deep packet inspection, application awareness, and intrusion prevention to traditional port-and-protocol filtering. It can identify what application is generating traffic, not just which port it's using, which catches threats basic firewalls miss.

How often should firewall rules be reviewed?

Most security teams review firewall rule sets quarterly at minimum, and after any major infrastructure change. Stale or overly permissive rules are one of the most common audit findings and a frequent cause of preventable breaches.


← Back to Knowledge Bank

Ready to build this capability?

Browse our upcoming batches — live, instructor-led, delivered on Orbit.