How does a firewall differ from an IDS in which OSI layers it mainly works on, and what are each one's strengths and weaknesses?
A classic firewall decides on layer 3/4 headers (IP addresses, ports, protocol, connection state); an IDS inspects up to layer 7, including the payload, and alerts rather than blocks.
| Firewall (packet filter) | IDS | |
|---|---|---|
| Looks at | IP addresses, ports, protocol, connection state (L3/L4) | Headers and payload, up to application data (L3–L7) |
| Job | Enforce a policy: allow or deny | Detect and report suspicious activity |
| Strength | Fast, cheap, blocks unwanted connections outright | Sees attacks hidden inside allowed traffic (SQL injection over port 80) |
| Weakness | Blind to what travels through an allowed port | Does not stop anything by itself; costly at high bandwidth; blind to encrypted payloads |
The two complement each other. A firewall can only say "port 80 to the web server is allowed", so it lets an SQL injection through. An IDS can recognise the injection in the HTTP request, but it only raises an alarm. Pairing them closes the gap: the IDS detects, and the firewall (or an inline IPS) blocks. That is the pattern this lab follows with Suricata and nftables.
(Modern "next-generation" firewalls blur the line by adding application awareness and IPS features, but the conceptual split still holds.)
Go deeper:
BSI-Leitfaden: Zusammenspiel von IDS mit anderen Sicherheitskomponenten — why neither replaces the other, and how an IDS can check that the firewall does what it should.
Firewall (computing) (Wikipedia) — firewall generations from packet filter to application layer, which explains where next-generation firewalls blur the line.