Firewall

On this page 7

A firewall is a security control that enforces an access policy on network traffic, allowing or blocking each connection between network zones or hosts according to an ordered rule set. It can be a dedicated appliance, software on a host, a virtual instance or a cloud service, and its purpose is to ensure that only explicitly permitted communication crosses a boundary.

In infrastructure defense, the firewall is the oldest and still the most fundamental layer of network segmentation. It decides who may talk to whom and over which protocol, while neighboring controls such as IDS, IPS, WAF and EDR inspect what happens inside the permitted traffic or on the endpoints themselves.

How a firewall evaluates traffic

A firewall compares each packet or connection against its rules, normally top to bottom with first match wins, and applies the action of the first matching rule. A classic rule matches the 5-tuple: source address, destination address, source port, destination port and protocol. If no rule matches, a final implicit default deny drops the traffic.

Modern firewalls are stateful. When a permitted connection opens, the firewall records it in a connection table with addresses, ports, protocol state and an idle timeout, and it then admits return packets that belong to that entry without a separate rule. Packets that claim to belong to a nonexistent session, such as an unsolicited TCP ACK, are dropped, which defeats many scanning and spoofing techniques that fool stateless filters.

Beyond allow and deny, firewalls commonly perform network address translation (NAT), log decisions for later analysis and terminate VPN tunnels. Logging every denied and permitted connection at the boundary is one of the most valuable data sources for a SIEM.

Types of firewalls

Firewall technology has evolved from simple packet filters to devices that understand applications and users. The generations still coexist, because each fits a different placement and performance budget.

TypeInspection depthStrengthMain limitation
Stateless packet filterLayer 3 and 4 headers per packetVery fast, simple router ACLsNo session awareness; easy to bypass
Stateful firewallHeaders plus connection stateBlocks out-of-state packetsCannot tell applications on the same port apart
Application proxyFull protocol at layer 7Breaks the direct connection; deep controlPer-protocol support and higher latency
Next-generation firewall (NGFW)Application, user identity and threat signaturesPolicy by application and userThroughput drops with full inspection enabled
Host-based firewallTraffic of one operating systemControls lateral movement per hostDisabled if the host is compromised
Cloud firewallVirtual network trafficScales with cloud workloadsRules spread across many accounts and services
Firewall types and what they inspect

Cloud platforms often provide two layers at once: stateful security groups attached to instances and stateless network ACLs on subnets. Confusing the two is a frequent cause of broken return traffic, because a stateless ACL needs explicit rules for ephemeral response ports.

A firewall controls whether a connection is allowed, while most neighboring controls examine the content or behavior of traffic and systems. The table shows how the responsibilities divide.

ControlPrimary questionPositionTypical action
FirewallIs this connection permitted?Between zones or on a hostAllow, deny, log, translate
WAFIs this HTTP request malicious?In front of web applicationsBlock injection and abuse patterns
IDSDoes this traffic match an attack?Passive copy of trafficAlert only
IPSDoes this traffic match an attack?Inline in the traffic pathDrop or reset the session
EDRIs this process behaving maliciously?On endpointsKill, isolate, collect telemetry
SIEMWhat do all logs reveal together?Central log platformCorrelate and raise incidents
DDoS mitigationIs this traffic volume an attack?Upstream or at the edgeAbsorb and scrub floods
Firewall and neighboring infrastructure defenses

An NGFW often bundles IPS and URL filtering, which blurs the lines in product terms, but the functions remain distinct. A firewall in particular is not a DDoS defense: a volumetric attack can saturate the uplink, or exhaust the connection table, before the firewall makes any decision.

Designing a firewall rule set

Good rule design follows least privilege: begin from default deny, permit only documented business flows, and make every rule as specific as possible in source, destination and service. Each rule should carry an owner, a justification and a review date.

The example policy below protects a small DMZ web tier and shows the typical order from specific permits to a logged final deny.

RuleSourceDestinationServiceAction
1Any internet addressWeb servers in DMZTCP 443Allow
2Web servers in DMZDatabase serverTCP 5432Allow
3Admin jump hostDMZ serversTCP 22Allow and log
4DMZ serversInternal networkAnyDeny and log
5AnyAnyAnyDeny and log
Example rule set for a DMZ web tier

Egress filtering is as important as inbound control. A server that may only reach its update repository and its database cannot easily download attack tools or send stolen data to an attacker’s server, which turns many intrusions into contained incidents.

Common firewall mistakes and their fixes

Firewall failures are rarely caused by the product itself. They come from policy drift, overly broad rules and unmonitored exceptions that accumulate over years of change requests.

MistakeConsequenceFix
Any-any rulesSegmentation exists only on paperReplace with specific source, destination and port
Shadowed rulesA broad earlier rule hides later onesRun rule analysis and reorder or remove
No egress controlFree outbound access for malwareRestrict outbound traffic to required destinations
Exposed management interfaceFirewall itself becomes the targetLimit administration to a management network
Unpatched firmwareEdge device exploited directlyPatch edge devices as critical systems
Rules without ownersNobody dares to delete stale accessRequire owner and expiry on every rule
Typical firewall weaknesses

Internet-facing firewalls and VPN gateways have become high-value targets in their own right, so their vulnerabilities deserve the shortest patch deadlines in the organization.

Put simply

A firewall is a guarded gate between networks. Every connection that tries to pass is compared with a list of who is allowed to go where, and anything not on the list is turned away.

A modern firewall also remembers who left through the gate, so replies to those visitors are let back in automatically. It does not check what visitors carry in their bags, which is the job of other security tools, but without the gate everything else is wide open.

In practice

A mid-sized manufacturer runs its office computers and its production machines on separate network zones. An internal firewall between them permits only one flow: a data historian server in the office zone may collect machine data from the production zone over OPC UA on TCP port 4840. Everything else, including Windows file sharing on port 445 and remote desktop on port 3389, is denied and logged.

When a phishing email infects an office laptop with ransomware, the malware spreads through file shares across the office zone and encrypts dozens of workstations. Its attempts to reach production systems hit the deny rule, and the firewall logs give the response team an exact timeline of the scanning.

Office work stops for two days while the IT team restores systems from backup, but production lines keep running throughout, because the firewall rule set had made the factory floor unreachable from the infected zone.