Skip to content
Tutorials Center
My learning

Topics

Lesson 20 of 37 ยท IDS/IPS and Monitoring

IDS vs IPS - Detection and Prevention

Learn how intrusion detection (IDS) and intrusion prevention (IPS) systems differ, where to place sensors, and how passive and inline modes trade safety for control.

A firewall decides who may talk to whom. It says little about what is inside the conversation. An attacker who sends a perfectly legal HTTPS request to your web server passes the firewall untouched, yet the request may carry an exploit. Intrusion detection and intrusion prevention systems exist to look at traffic and behavior and raise a hand when something looks wrong.

This lesson explains the difference between an IDS and an IPS, the places you can put them, and the trade-offs that decide which one you run. Later lessons in this chapter go deeper into signature detection, anomaly detection and log analysis.

Everything in this chapter is about defending networks you own or are authorized to monitor. Examples use made-up addresses from documentation ranges such as 203.0.113.0/24 and 198.51.100.0/24.

IDS and IPS in one table

IDS (detection) IPS (prevention)
Position Off to the side, sees a copy of traffic In the path, every packet passes through it
Action Alerts, logs Alerts, logs, drops, resets, rate-limits
Failure impact If it dies, you lose visibility If it dies, traffic may stop (or bypass protection)
Delay added None Small, on every packet
False positive cost A noisy dashboard Blocked legitimate users

An IDS is an alarm. An IPS is an alarm wired to a door lock. Many products do both and you switch the mode per rule: noisy new rules start in alert-only mode, proven rules graduate to blocking.

Two jobs, one engine

Detect Copy of traffic, raise alerts
Prevent Inline, drop bad packets

Same detection logic, different placement.

1 / 3

Network and host based

A NIDS/NIPS (network) watches packets crossing a link. A HIDS/HIPS (host) runs on a server or laptop and watches files, processes, logins and system calls. They see different things:

  • A network sensor sees every host on a segment, but cannot read traffic that is encrypted end to end, and it does not know what a process did after the packet arrived.
  • A host sensor sees decrypted data and local actions, but only for the machine it lives on, and an attacker who owns the machine may switch it off.

A solid design uses both and ties the alerts together in a SIEM.

Passive versus inline deployment

There are three common ways to feed a network sensor.

flowchart LR
    I["Internet"] --> FW["Firewall"]
    FW --> SW["Core switch"]
    SW --> S["Servers"]
    SW -. "mirror port (SPAN)" .-> IDS["IDS sensor"]
    FW --> IPS["Inline IPS"]
    IPS --> SW

A SPAN or mirror port feeds a passive IDS; an inline IPS sits in the traffic path.

  1. SPAN / mirror port. The switch copies traffic to a port where the sensor listens. Easy and risk free, but a busy switch may drop mirrored frames, so the sensor can miss packets.
  2. Network TAP. A small hardware device that passively copies every frame on a link. More reliable than SPAN, costs money.
  3. Inline. The sensor is a bump in the wire. It can block, but you must plan for failure: most devices offer fail-open (traffic keeps flowing without protection) or fail-closed (traffic stops). Availability-first networks choose fail-open; high-security zones choose fail-closed.

Detection methods at a glance

  • Signature based: compare traffic to patterns of known attacks. Precise, cheap, blind to new attacks. See signature detection.
  • Anomaly based: learn what normal looks like and flag deviations. Can catch the unknown, produces more false alarms. See anomaly detection.
  • Protocol analysis: check that traffic obeys the protocol (an HTTP header that is 60 KB long is suspicious regardless of content).
  • Reputation: drop or flag traffic to and from addresses and domains known to be malicious.

A tiny IDS versus IPS simulation

The program below pushes the same stream of events through a detector and then applies two policies: an IDS that only reports and an IPS that also drops. It is a stand-in that works on made-up events, with no real packets involved.

Python Same detector, two modes

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Both modes raise the same two alerts. Only the IPS keeps the attack from reaching the server. Now imagine the detector had a false positive: a legitimate product called "Script <script> Pro". In IDS mode that costs you an analyst's minute; in IPS mode it blocks a sale.

False positives and false negatives

Every detector makes two kinds of mistakes.

  • False positive: a benign event raises an alert.
  • False negative: a real attack raises none. This is the dangerous one, and you cannot see it, because by definition nothing alerted.

Tuning moves the balance but never removes both. The practical measures are precision (of the alerts raised, how many were real) and recall (of the real attacks, how many were caught). The next program computes both for a small labelled sample.

Python Precision and recall of a detector

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Encrypted traffic

Most traffic is now TLS. A network sensor cannot match a signature inside an encrypted payload. Options: decrypt at a proxy you control (TLS inspection, with legal and privacy considerations), put host sensors behind the point where TLS ends, and fall back on metadata such as destination, timing, packet sizes and the unencrypted parts of the handshake. See the TLS handshake.

Common mistakes

  • Turning on blocking for every rule on day one and causing an outage.
  • Placing a sensor where it sees only one direction of an asymmetric route.
  • Never reading the alerts. An unread IDS is a log file with a power bill.
  • Forgetting to update rules; stale signatures miss recent attacks.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. What is the main functional difference between an IDS and an IPS?

    Both detect; the IPS sits inline and can drop or reset traffic, the IDS watches a copy and reports.
  2. 2. Which deployment gives you a risk-free view of traffic but may miss packets on a busy link?

    Mirror ports copy traffic without sitting in the path, but an overloaded switch can drop mirrored frames.
  3. 3. A detector flags 10 events and 8 are real attacks; there were 16 real attacks in total. What is its recall?

    Recall = caught attacks / all attacks = 8 / 16 = 0.5. Precision would be 8 / 10 = 0.8.
  4. 4. Why should new rules usually start in alert-only mode?

    Alert-only mode lets you measure false positives safely before you let a rule drop traffic.

Summary

  • An IDS watches and alerts; an IPS sits inline and can also block.
  • Network sensors see many hosts; host sensors see decrypted data and local actions. Use both.
  • SPAN ports and TAPs feed passive sensors; inline devices need a fail-open or fail-closed decision.
  • Detection methods: signatures, anomalies, protocol checks and reputation.
  • False positives annoy, false negatives hurt; measure precision and recall and tune before blocking.
  • Encryption limits what network sensors can see.

Next: Signature-Based Detection