01Enforce versus observe
A firewall enforces a policy at a boundary: traffic matching an allow rule passes, everything else is dropped. An IDS sits off to the side, copies traffic, and raises alerts. An IPS sits inline like a firewall but decides based on attack content rather than addresses and ports, so it can drop a malicious packet that a firewall rule would have allowed.
02How deep does it look?
Firewall technology evolved by inspecting progressively more of each flow. Every step adds context and catches more, at the cost of throughput, memory, and configuration complexity.
03Packet filtering and rule order
A packet filter compares each packet's 5-tuple (source IP, destination IP, source port, destination port, protocol) against an ordered rule list. Most firewalls are first match wins: evaluation stops at the first rule that fits, so ordering is part of the policy, not a formatting detail.
Default deny
End every policy with an explicit deny-all and allow only what is needed. Default allow means every forgotten service is exposed.
Egress filtering
Filter outbound traffic too. It stops infected hosts from beaconing out and data from leaving on arbitrary ports.
Rule hygiene
Large rulesets accumulate shadowed, redundant, and stale rules. More rules usually means more errors, not more security.
- nftables wiki — the modern Linux packet filter · pfSense firewall rule docs · OPNsense
- Nmap — detecting and subverting firewalls
- Wool, A. (2004). A quantitative study of firewall configuration errors. IEEE Computer, 37(6).
- Al-Shaer, E. & Hamed, H. (2004). Discovery of policy anomalies in distributed firewalls. IEEE INFOCOM.
04Stateful inspection
A stateless filter judges each packet in isolation, so to let replies in you must open broad inbound port ranges. A stateful firewall remembers connections it has seen leave and admits only packets that belong to one of them.
State tracking also lets the firewall enforce protocol sanity (a TCP packet with the ACK flag set but no prior SYN is suspicious) and handle protocols like FTP that open secondary connections on negotiated ports.
05Proxies and next-generation firewalls
Port numbers no longer identify applications: almost everything rides on 443. Application-aware firewalls parse the protocol itself to answer questions a packet filter cannot, such as "is this really HTTP?", "which SaaS app is this?", or "is this file a known malware sample?"
Proxy (application gateway)
Terminates the client's connection and opens a new one to the server, so no packet passes directly. Strong isolation and full content visibility; heavy per-connection cost.
Web application firewall
A reverse proxy specialized for HTTP that blocks attacks such as SQL injection and cross-site scripting in otherwise permitted requests.
NGFW
Combines stateful filtering, application identification, user identity, an IPS engine, threat-intelligence feeds, and optional TLS inspection in one platform.
The TLS inspection dilemma
Payload inspection is blind to encrypted traffic unless the firewall decrypts it, which means acting as a trusted man-in-the-middle with its own CA certificate on every client. That restores visibility but concentrates risk: a poorly implemented interception box can quietly weaken the encryption it replaces, and it breaks certificate pinning and privacy expectations.
- OWASP ModSecurity Core Rule Set — open-source WAF rules
- Durumeric, Z. et al. (2017). The security impact of HTTPS interception. NDSS.
06Architecture: DMZ and segmentation
Where firewalls sit matters as much as their rules. A DMZ (screened subnet) holds anything the internet must reach, so that a compromised public server still sits behind a second boundary before it can touch internal data.
The same idea scales inward. Segmentation splits the internal network into zones (users, servers, OT, guests) so lateral movement must cross a policy point. Microsegmentation applies per-workload rules in hypervisors, cloud security groups, or host firewalls, which is the network half of zero-trust architecture.
- NIST SP 800-207 — Zero Trust Architecture
- AWS security groups — stateful, per-instance cloud firewalls
07IDS and IPS
The difference is action. An IDS observes and reports; an IPS observes and intervenes. Think of a camera versus a guard at the door.
| IDS | IPS | |
|---|---|---|
| Position | Out of band (SPAN port, network tap) | Inline, traffic passes through it |
| Response | Alert, log, hand off to analysts or SOAR | Drop, reset, rate-limit, quarantine automatically |
| Cost of a false positive | Wasted analyst time | Blocked legitimate business traffic |
| Failure mode | Fails open; network unaffected | Must choose fail-open (risk) or fail-closed (outage) |
| Latency added | None | Some, per packet |
Network-based (NIDS)
Watches traffic on a segment. Sees many hosts at once; blind to encrypted payloads and host-internal activity.
Host-based (HIDS)
Runs on the endpoint: logs, file integrity, process behavior. Sees decrypted data; must be deployed and trusted on every host. EDR is its modern descendant.
- Snort 3 documentation · Suricata documentation · Zeek documentation
- Security Onion — free distribution bundling Suricata, Zeek, and analysis tools
- Wazuh — open-source host-based detection
- Denning, D. (1987). An intrusion-detection model. IEEE Transactions on Software Engineering, SE-13(2).
08Detection methods
Signature
Matches known byte patterns or behaviors. The basis of Snort and Suricata rule sets. Defeated by zero-days and simple obfuscation.
Anomaly
Models normal (statistically or with machine learning) and flags deviations. Finds the unknown, but "unusual" is not the same as "malicious."
Specification / protocol
Flags violations of what a protocol or application should do: malformed headers, impossible state transitions, policy breaches.
- Emerging Threats open rule set
- CIC-IDS2017 dataset — labeled traffic for detection experiments
- Paxson, V. (1999). Bro: a system for detecting network intruders in real-time. Computer Networks, 31(23–24).
- Roesch, M. (1999). Snort: lightweight intrusion detection for networks. USENIX LISA.
- García-Teodoro, P. et al. (2009). Anomaly-based network intrusion detection: techniques, systems and challenges. Computers & Security, 28(1–2).
- Sommer, R. & Paxson, V. (2010). Outside the closed world: on using machine learning for network intrusion detection. IEEE S&P.
09Accuracy and the base-rate problem
Every alert is one of four outcomes. Tuning trades false positives against false negatives; you cannot drive both to zero.
- Axelsson, S. (2000). The base-rate fallacy and the difficulty of intrusion detection. ACM TISSEC, 3(3).
- Arp, D. et al. (2022). Dos and don'ts of machine learning in computer security. USENIX Security.
10Reading a rule and an alert
A signature rule has a header that scopes which traffic it applies to and options that describe what to look for. This illustrative rule flags an SSH login attempt burst from outside:
alert tcp $EXTERNAL_NET any -> $HOME_NET 22 ( msg:"possible SSH brute force"; flow:to_server; flags:S; detection_filter:track by_src, count 20, seconds 60; classtype:attempted-admin; sid:1000001; rev:1;)
- Snort 3 rule writing guide · Suricata rule format
- malware-traffic-analysis.net — packet captures and practice exercises
11Limits, evasion, and failures
Attackers aim at the gap between what the sensor reconstructs and what the target actually receives: fragmented or overlapping packets reassembled differently, low TTLs that reach the sensor but not the host, payload encoding, and above all encryption.
Allowed-path attacks
SQL injection over 443, malware in permitted email, or a stolen VPN credential all pass a correctly configured firewall.
Air gaps and insiders
Stuxnet reached isolated industrial networks on removable media, never crossing a perimeter firewall. Host and behavior monitoring were the only chance.
Alerts nobody acts on
In the 2013 Target breach, detection tools reportedly flagged the malware, but the alerts were not escalated. Detection without response is just logging.
Common misconceptions
- Handley, M., Paxson, V. & Kreibich, C. (2001). Network intrusion detection: evasion, traffic normalization, and end-to-end protocol semantics. USENIX Security.
- MITRE ATT&CK — Defense Evasion tactic
—References
Peer-reviewed
- Al-Shaer, E. & Hamed, H. (2004). Discovery of policy anomalies in distributed firewalls. IEEE INFOCOM. doi:10.1109/INFCOM.2004.1354680
- Arp, D. et al. (2022). Dos and don'ts of machine learning in computer security. USENIX Security. usenix.org
- Axelsson, S. (2000). The base-rate fallacy and the difficulty of intrusion detection. ACM TISSEC, 3(3). doi:10.1145/357830.357849
- Denning, D. (1987). An intrusion-detection model. IEEE TSE, SE-13(2). doi:10.1109/TSE.1987.232894
- Durumeric, Z. et al. (2017). The security impact of HTTPS interception. NDSS. doi:10.14722/ndss.2017.23456
- García-Teodoro, P. et al. (2009). Anomaly-based network intrusion detection. Computers & Security, 28(1–2). doi:10.1016/j.cose.2008.08.003
- Handley, M., Paxson, V. & Kreibich, C. (2001). Network intrusion detection: evasion, traffic normalization, and end-to-end protocol semantics. USENIX Security. usenix.org
- Paxson, V. (1999). Bro: a system for detecting network intruders in real-time. Computer Networks, 31(23–24). doi:10.1016/S1389-1286(99)00112-7
- Roesch, M. (1999). Snort: lightweight intrusion detection for networks. USENIX LISA. usenix.org
- Sommer, R. & Paxson, V. (2010). Outside the closed world. IEEE S&P. doi:10.1109/SP.2010.25
- Wool, A. (2004). A quantitative study of firewall configuration errors. IEEE Computer, 37(6). doi:10.1109/MC.2004.2