#Why this matters
State-inspecting firewalls verify IP addresses, ports, and connection state, yet most modern attacks travel inside permitted ports such as 80, 443, and 53. A firewall cannot tell whether an HTTP POST carries a normal form submission or a command-and-control (C2) check-in.
Intrusion Detection Systems (IDS) and Intrusion Prevention Systems (IPS) close that gap by inspecting packet headers, reassembled streams, and application-layer fields against signatures and protocol anomalies. Placing sensors poorly or writing sloppy rules, however, creates silent blind spots or overwhelms analysts with false positives.
#IDS vs. IPS and sensor placement
The core architectural choice is whether the sensor sits out-of-band (IDS) or inline (IPS).
| Mode | Traffic path | Active blocking | Failure impact | Best fit |
|---|---|---|---|---|
| Passive NIDS | Receives copies via TAP or switch SPAN | Alerts only (or injects TCP RST) | Zero forwarding outage if sensor crashes | Core visibility, threat hunting, initial rule tuning |
| Inline NIPS | Bump-in-the-wire between interfaces | Drops or rejects malicious packets | Network outage unless hardware bypass fails open | Mature, high-confidence signatures at choke points |
| Host IDS/IPS | Agent on endpoint OS | Blocks processes or local sockets | Local host impact only | Encrypted workloads and host-level context |
Passive sensors fed by a network TAP capture every frame reliably, whereas switch SPAN (port mirroring) can silently drop mirrored packets during traffic bursts. For inline IPS deployments, engineers must also choose between fail-open (traffic passes uninspected during a crash, preserving availability) and fail-closed (traffic halts, preserving strict policy).
Placement relative to Network Address Translation (NAT) and internal segments determines what you can actually attribute:
- InternetExternal traffic
- Perimeter Firewall & NATDrops unsolicited inbound ports
- DMZ Sensor (TAP)Sees public-facing services before internal routing
- Internal Core TAPSees real internal client IPs (pre-NAT) and east-west traffic
If a sensor sits only outside a NAT gateway, every outbound alert reports the single public NAT IP instead of the compromised workstation inside 10.10.10.0/24. Placing sensors inside the NAT boundary and on internal distribution switches exposes both real source addresses and lateral movement across VLANs.
#How signature engines process packets
Modern engines such as Suricata and Snort 3 do not run regular expressions blindly against every raw packet. They use a multi-stage pipeline so line-rate traffic stays fast:
- Packet acquisition and decoding: The engine reads frames (for example via
AF_PACKETin passive mode orNFQUEUEin inline mode) and validates L2-L4 headers. - Stream reassembly: TCP segments are reordered and reassembled into a continuous stream, defeating naive packet-splitting evasion.
- Application-layer parsing: Protocol parsers identify HTTP, DNS, TLS, and SMB regardless of port, extracting normalized fields such as URIs, host headers, and TLS Server Name Indication (SNI).
- Multi-pattern pre-filtering: An algorithm such as Hyperscan or Aho-Corasick scans traffic against one fast pattern chosen from each active rule.
- Full rule evaluation: Only rules whose fast pattern matched run expensive checks such as regular expressions (
pcre), byte tests, or thresholds.
Because of step 4, a rule with a short or common fast pattern (such as GET or .php) forces step 5 to evaluate thousands of times per second, driving up CPU usage and kernel packet drops.
#Writing and testing Suricata rules
A Suricata rule has three parts: the action (alert, drop, pass, reject), the header (protocol, source/destination IP variables and ports, direction), and the options in parentheses.
alert http $HOME_NET any -> $EXTERNAL_NET any (msg:"Lab C2 Beacon Check-in"; flow:established,to_server; http.method; content:"POST"; http.uri; content:"/api/v1/checkin"; bsize:15; http.header; content:"X-Session-Tag:"; fast_pattern; classtype:trojan-activity; sid:1000101; rev:1;)Key options make this rule accurate and cheap to run:
flow:established,to_server;restricts matching to completed TCP handshakes moving from client to server, eliminating spoofed one-packet noise.- Sticky buffers (
http.method;,http.uri;,http.header;) apply all followingcontentmodifiers to that parsed field until another sticky buffer appears. Usinghttp.uri;ensures Suricata inspects the normalized URI rather than raw packet bytes. bsize:15;checks that the entire URI buffer is exactly 15 bytes long, blocking partial-path false positives.fast_pattern;forces the pre-filter to indexX-Session-Tag:(14 uncommon bytes) instead ofPOST.sidandrevgive every rule a unique local ID (above1000000for custom rules) and revision number.
You can validate custom rules against a captured PCAP offline before touching a live sensor:
$ suricata -T -S local.rules -c /etc/suricata/suricata.yaml
Notice: suricata: Configuration provided was successfully validated.
$ suricata -r lab-beacon.pcap -S local.rules -l ./logs/
Notice: suricata: This is Suricata version 7.0.x RELEASE running in USER mode
$ cat ./logs/fast.log
11/18/2026-14:22:09.114021 [**] [1:1000101:1] Lab C2 Beacon Check-in [**] [Classification: A Network Trojan was detected] [Priority: 1] {TCP} 10.10.10.24:51422 -> 198.51.100.42:8080Suricata also writes structured JSON records to ./logs/eve.json, capturing the HTTP URI, hostname, and alert metadata together for SIEM ingestion.
#Defending against evasion and common mistakes
Attackers try to slip past naive signatures, and defenders often weaken their own sensors through configuration mistakes:
- Encrypted payload blindness: TLS hides
http.uriandhttp.headerfrom passive sensors. Instead of writing broken payload rules on port 443, match metadata fields (tls.sni, certificate subject/issuer, or JA3/JA4 fingerprints) or inspect decrypted traffic at an authorised TLS proxy. - Unanchored raw matches: Matching
contentwithoutflowor protocol sticky buffers lets attackers bypass rules using URL encoding (%2f), extra whitespace, or TCP segmentation. Always inspect normalized buffers (http.uri, nothttp.uri.raw, unless deliberately hunting raw obfuscation). - Enabling IPS blocking prematurely: Switching thousands of community rules to
dropwithout a baseline monitoring window breaks legitimate business traffic. Run new rules inalertmode first, measure hit rates, and promote only high-confidence signatures todrop. - Ignoring packet drops: Check
stats.logoreve.jsonstats events forcapture.kernel_drops. Dropped packets mean blind spots; fix them by tuningfast_patternchoices, pinning worker threads, or upgrading from SPAN to a hardware TAP.
#Summary
Passive NIDS provides risk-free visibility via TAPs or SPAN ports, while inline NIPS enforces blocking at the cost of latency and failure-mode risk. Placing sensors inside NAT boundaries and across internal segments ensures accurate host attribution and east-west coverage. Effective Suricata signatures rely on flow state, normalized sticky buffers, and selective fast_pattern strings, always tested offline against PCAPs and tuned in alert mode before blocking.