Skip to content
Back to Series Network Security from Scratch
Security

IDS and IPS: Intrusion Detection and Prevention

Learn how IDS and IPS differ, how signature-based and anomaly-based detection work, where to deploy them, and practical Snort and Suricata examples.

A
Alif Afriza Author
· · 4 min read
IDS and IPS: Intrusion Detection and Prevention

A firewall guards the boundary. But what if an attacker is already inside, or if the threat comes from within the network? This is where IDS (Intrusion Detection System) and IPS (Intrusion Prevention System) come in.

IDS vs IPS: What Is the Difference?

  • IDS: detects and raises alerts. It is passive, monitors traffic, and tells the admin when it finds something suspicious. It does not stop anything directly.
  • IPS: detects and stops. It is active and can block suspicious packets directly.

A simple analogy: IDS is like a surveillance camera that records and informs security; IPS is like a camera that also automatically locks the door when it sees someone suspicious.

CapabilityIDSIPS
Detects intrusionsYesYes
Generates alertsYesYes
Stops trafficNoYes
Risk of hindering normal trafficLowMedium (a false positive can block legitimate services)
Typical position in the networkTAP / monitor portInline in the traffic path

The main risk of IPS is a false positive: blocking something that is actually normal. That is why a good IPS needs tuning so it does not take down your own legitimate services.

Detection Methods

Signature-Based

Matches traffic against known attack patterns (signatures). A real-world example: packet signatures that match a specific exploit.

  • Strengths: fast and accurate for known attacks.
  • Weakness: cannot detect new attacks that do not yet have a signature.

Anomaly-Based

Builds a “normal picture” and then alerts when there is a deviation: traffic spikes, unusual protocols, unusual times of day, and so on.

  • Strength: can detect new attacks.
  • Weakness: many false positives; defining “normal” is difficult.

Combining both is common practice: signatures catch what is known, anomaly detection catches what is not.

Where Should It Be Deployed?

Where you place it determines what the system can see.

  • Outside the firewall (the internet boundary): sees all raw attacks coming in.
  • Inside, in front of critical servers: focuses on the most sensitive assets.
  • On paths between segments: monitors internal communication, where threats often move laterally.

For a homelab, the most realistic place is a passive bridge in front of public servers (for example, mirroring a port from the switch to the machine running IDS), or running an agent on the main machine.

Practical Example: Suricata / Snort

Snort and Suricata are the most popular open source detection engines. Both read rules to recognize patterns. The structure of a Suricata/Snort rule looks roughly like this:

alert tcp $HOME_NET any -> $EXTERNAL_NET 22 (msg:"SSH scan"; flow:to_server,established;
  threshold: track by_src, count 10, seconds 60; sid:1000001; rev:1;)

This means: alert if there are more than 10 connections to port 22 from a single source within 60 seconds, flagged as a possible SSH scan.

Example of running Suricata in Docker:

docker run -d --name suricata \
  --network host \
  -v /etc/suricata:/etc/suricata \
  jasonish/suricata -i eth0

Alert results can be viewed in the fast.log / eve.json log files, or sent to a SIEM (covered in an advanced article).

Proper Tuning

  • Start in IDS mode (alerts only), not IPS right away. Observe for 1-2 weeks first and study the false positives.
  • Create an allowlist for patterns that turn out to be normal in your network (for example, internal monitoring on DNS).
  • Disable rules that are not relevant to your environment.
  • Only then move up to IPS for patterns you already trust.

Honest Limitations

IDS/IPS does not see encrypted traffic (HTTPS, TLS) in full. It only sees metadata (addresses, ports, sizes). For encrypted content, other approaches are needed (for example, TLS inspection at a proxy, or analysis on the endpoint). Do not build expectations that IDS sees everything.

Next in the curriculum: all detection depends on secure data; learn how to protect traffic with TLS, IPsec, and VPN.

References

  • NIST SP 800-94, Guide to Intrusion Detection and Prevention Systems (IDPS), csrc.nist.gov/pubs/sp/800/94/final (the most comprehensive official IDS/IPS guide).
  • Snort user manual (snort.org) and Suricata documentation (suricata.io).
  • RFC 4765, Intrusion Detection Message Exchange Format, rfc-editor.org/rfc/rfc4765 (the IDS message format).
  • NIST SP 800-92, Guide to Computer Security Log Management, csrc.nist.gov/pubs/sp/800/92/final (managing logs produced by IDS/IPS).
Open for Contributors

Your ideas deserve to be read by thousands of people.

ByteNesia is built for everyone. If you have experience, tutorials, or opinions about technology, write and share them here. Your name will be credited as a contributor.

Write anything: tool reviews, homelab tutorials, security tips, or your tech stories.

Discussion & Comments