How IDS and IPS Work: Intrusion Detection and Prevention Systems Explained

Intrusion Detection Systems (IDS) and Intrusion Prevention Systems (IPS) are network security technologies that monitor traffic for malicious activity, policy violations, and known attack patterns. An IDS passively observes traffic and generates alerts when it detects suspicious behavior. An IPS goes further: deployed inline in the traffic path, it actively blocks or drops malicious packets in real time. Together, they form a critical layer in network defense, sitting between the perimeter firewall and the applications it protects.

The distinction between IDS and IPS is operational, not technological. The same detection engine -- whether Snort, Suricata, or a commercial appliance -- can run in either mode. In IDS mode, it mirrors traffic from a SPAN port or network TAP and analyzes it out-of-band, alerting a security team when something suspicious appears. In IPS mode, it sits inline (between the router/switch and the protected network), inspecting every packet in real time and dropping those that match malicious signatures or anomalous patterns. The trade-off is clear: IDS has zero impact on network performance but cannot stop an attack in progress; IPS can block attacks instantly but introduces latency and becomes a potential point of failure.

This article covers the architecture, detection methods, rule syntax, deployment patterns, evasion techniques, and performance considerations of modern IDS/IPS systems.

Architecture: NIDS vs HIDS

Intrusion detection systems come in two fundamental architectures:

Network-based IDS/IPS (NIDS/NIPS)

A network-based IDS monitors traffic on a network segment by capturing packets at a strategic point -- typically at the network perimeter, at data center boundaries, or at segment choke points. The sensor receives a copy of all traffic (via SPAN/mirror port, network TAP, or inline placement) and applies its detection engine to every packet.

Key characteristics of NIDS:

Host-based IDS/IPS (HIDS/HIPS)

A host-based IDS runs on individual endpoints (servers, workstations) and monitors activity at the host level: file system changes, process execution, system calls, log entries, registry modifications (Windows), and local network connections. HIDS has access to decrypted traffic (since it operates after TLS termination) and can detect attacks that are invisible to network-based sensors, such as local privilege escalation, rootkits, and file integrity violations.

Well-known HIDS implementations include:

IDS/IPS Deployment Architecture Internet Firewall IPS (Inline) blocks malicious pkts Switch SPAN/TAP IDS (Passive) alerts only, no blocking SIEM / SOC Internal Network Web Server App Server DB Server HIDS Agent HIDS Agent HIDS Agent Inline (blocking) Passive (alerting) Host-based agent

Detection Methods

Signature-Based Detection

Signature-based detection is the oldest and most widely used IDS/IPS method. It works by comparing network traffic against a database of known attack patterns -- signatures (also called rules). Each signature describes the specific bytes, patterns, or protocol behaviors that characterize a known attack.

For example, a signature might match the specific byte sequence in a buffer overflow exploit for a particular CVE, the SQL injection string ' OR 1=1 -- in an HTTP request, or the DNS query pattern used by a specific malware family's command-and-control beacon.

Strengths of signature-based detection:

Weaknesses:

Anomaly-Based Detection

Anomaly-based detection establishes a baseline model of "normal" network behavior and flags traffic that deviates significantly from that baseline. Instead of looking for known attack patterns, it looks for unusual patterns that might indicate an attack.

Anomaly detection can flag behaviors such as:

Strengths: can detect novel attacks and zero-day exploits. Weaknesses: high false positive rate (legitimate behavioral changes trigger alerts), requires a training period to establish baselines, and can be slowly normalized by an attacker who gradually shifts baseline behavior over time ("slow and low" attacks).

Stateful Protocol Analysis

Stateful protocol analysis combines elements of both signature and anomaly detection. The IDS/IPS maintains full protocol state machines for the protocols it monitors (HTTP, DNS, SMTP, SMB, etc.) and validates that traffic conforms to the protocol specification. It detects attacks that violate protocol semantics, even if the specific byte pattern does not match a signature.

For example, a stateful HTTP analyzer would detect:

Snort and Suricata Rule Syntax

Snort and Suricata are the two dominant open-source IDS/IPS engines. They share a common rule format (Suricata extends it with additional keywords), making it easy to discuss rule writing in a unified way.

Rule Structure

A Snort/Suricata rule consists of a header and an options section:

action protocol src_ip src_port -> dst_ip dst_port (options;)

A concrete example -- detecting a SQL injection attempt in an HTTP request:

alert http $HOME_NET any -> $EXTERNAL_NET any (
  msg:"SQL Injection attempt - UNION SELECT";
  flow:established,to_server;
  http.uri;
  content:"UNION"; nocase;
  content:"SELECT"; nocase; distance:0; within:20;
  pcre:"/UNION\s+(ALL\s+)?SELECT/Ui";
  classtype:web-application-attack;
  sid:1000001; rev:3;
  metadata:created_at 2024-01-15, updated_at 2024-06-01;
)

Breaking down the rule components:

Advanced Rule Examples

Detecting DNS exfiltration by entropy analysis (Suricata with Lua scripting):

alert dns $HOME_NET any -> any any (
  msg:"Possible DNS exfiltration - high entropy query";
  dns.query;
  lua:dns_entropy.lua;
  classtype:trojan-activity;
  sid:1000010; rev:1;
)

Detecting TLS connections with suspicious JA3 fingerprints (known malware TLS clients):

alert tls $HOME_NET any -> $EXTERNAL_NET any (
  msg:"Known malware JA3 fingerprint - Cobalt Strike";
  ja3.hash;
  content:"72a589da586844d7f0818ce684948eea";
  classtype:trojan-activity;
  sid:1000020; rev:1;
)

Detecting a lateral movement technique (SMB remote service creation, used by PsExec):

alert smb $HOME_NET any -> $HOME_NET any (
  msg:"SMB - Remote Service Creation (PsExec-like)";
  flow:established,to_server;
  smb.named_pipe;
  content:"svcctl";
  classtype:attempted-admin;
  sid:1000030; rev:1;
)

Inline IPS vs Passive IDS Deployment

Passive (IDS) Mode

In passive mode, the sensor receives a copy of network traffic via:

Passive IDS can detect and alert on attacks but cannot block them. By the time the alert reaches a human analyst (or even an automated response system), the malicious packets have already been delivered to their target. Passive IDS is primarily used for:

Inline (IPS) Mode

In inline mode, the sensor sits directly in the traffic path. Every packet passes through the IPS engine, and packets matching drop rules are silently discarded (never forwarded to the destination). The IPS can also:

Inline IPS introduces operational risks: if the IPS fails (hardware failure, software crash, overload), it can black-hole all traffic. To mitigate this, inline IPS deployments use:

Evasion Techniques

Sophisticated attackers use a variety of techniques to evade IDS/IPS detection. Understanding these evasion methods is essential for tuning IDS rules and validating that the IDS deployment is effective.

Fragmentation and Reassembly Attacks

IP fragmentation splits a single IP packet into multiple fragments. If an attack payload is split across fragments, a signature that matches on the complete payload will not trigger unless the IDS reassembles the fragments before inspection. Attackers exploit this in several ways:

TCP Segmentation Attacks

Similar to IP fragmentation but at the TCP layer. The attacker sends the attack payload in very small TCP segments (e.g., 1 byte per segment). If the IDS does not perform full TCP stream reassembly, it will not see the complete attack string. More sophisticated variants include:

Application-Layer Evasion

Common IDS Evasion Techniques IP Fragmentation DROP TAB LE * Payload split across multiple IP fragments IDS must reassemble to match TTL Manipulation TTL=3 (benign) expires! TTL=64 (evil) reaches target IDS sees benign; target gets malicious Encoding Evasion Rule matches: ' OR 1=1 Attacker sends: %27%20OR%201%3D1 %2527 OR 1=1 IDS must decode before matching Countermeasures 1. Full TCP stream reassembly with OS-specific normalization policies 2. Multi-layer protocol decoding (URL decode, Base64, UTF-8 normalization) 3. Target-based reassembly (configure IDS to mimic target OS fragment handling) 4. TLS decryption (MITM proxy) or metadata-based detection (JA3, cert analysis)

Performance Considerations

IDS/IPS performance is a constant engineering challenge. The sensor must inspect every packet at line rate while maintaining complex state for thousands of concurrent connections and matching against tens of thousands of signatures.

Packet Capture and Processing

Standard kernel networking (the AF_PACKET socket interface) can handle up to approximately 1-3 Gbps of traffic on modern hardware before packet drops become unacceptable. For higher speeds, kernel bypass techniques are essential:

Multi-Pattern Matching

The core of IDS performance is the multi-pattern matching engine -- the algorithm that simultaneously checks a packet against thousands of content rules. The dominant algorithms include:

Suricata Threading Model

Suricata uses a multi-threaded architecture where each thread handles a subset of traffic flows independently. The threading model includes:

On a 16-core server, Suricata can scale to inspect 40+ Gbps when combined with DPDK capture and Hyperscan matching. However, the threading model means that a single flow (TCP connection) is always handled by one worker thread -- a single very-high-bandwidth flow can saturate one thread even if other threads are idle.

Tuning and False Positive Management

A production IDS deployment generates a staggering volume of alerts. An untuned Suricata sensor on a busy corporate network might produce millions of alerts per day. The vast majority are false positives -- legitimate traffic that happens to match a signature intended for a different context.

Effective IDS management requires systematic tuning:

Integration with SIEM and SOAR

IDS/IPS alerts are most valuable when correlated with other security data in a SIEM (Security Information and Event Management) platform. A single IDS alert might be noise, but the same alert combined with a failed login attempt, a firewall deny log, and a DNS query to a known-malicious domain becomes a high-confidence indicator of compromise.

Suricata outputs alerts in EVE JSON format, which is easily ingested by SIEM platforms (Splunk, Elastic Security, QRadar, Sentinel). The EVE log includes not just the alert metadata but also protocol-level details (HTTP headers, DNS queries, TLS certificates, file hashes) that enrich the SIEM's correlation capabilities.

SOAR (Security Orchestration, Automation and Response) platforms can automatically respond to IDS alerts: blocking the attacking IP on the firewall, isolating the targeted host, enriching the alert with threat intelligence, and creating tickets for analyst review.

Relevant RFCs and Standards

See It in Action

IDS/IPS systems protect networks at the border where BGP-routed traffic enters an organization's infrastructure. The DDoS attacks and intrusion attempts they detect arrive via the same routing infrastructure visible in the global BGP table. Use the god.ad BGP Looking Glass to explore the networks behind major IDS/IPS vendors and security organizations:

Every packet reaching this page was inspected by multiple IDS/IPS sensors along the path -- at your ISP's border, at Cloudflare's edge, and possibly at intermediate transit networks. Look up any IP address to see its route origin and the networks it traverses, each of which deploys its own intrusion detection infrastructure.

See BGP routing data in real time

Open Looking Glass
More Articles
How TLS/HTTPS Works: Securing the Internet's Traffic
Certificate Transparency: How CT Logs Secure the Web's PKI
How Firewalls Work: Packet Filtering, Stateful Inspection, and Beyond
What is Cross-Site Scripting (XSS)?
What is Cross-Site Request Forgery (CSRF)?
What is Server-Side Request Forgery (SSRF)?