Fun with Learning Technology
LearnCoursesQuestionsTracksToolsNewsExplorePractice
Fun with Learning Technology

A new problem, explained clearly, every day.

Subscribe
Learn
  • Lessons
  • Topics
  • News
  • Tools
  • Courses
  • Career tracks
  • Everything
Site
  • About
  • Contact
  • Support
  • Privacy
  • Terms
Get the daily one

One email per new problem. No spam.

Request a tutorial

Requests shape what gets made next.

© 2026 Fun with Learning TechnologyRSS
Home›Courses›cyber security›Firewalls, IDS, and IPS: Configuration and Management

Defensive Security and Incident Response

Firewalls, IDS, and IPS: Configuration and Management

Firewalls, IDS, and IPS form the core perimeter and internal defensive layers that control traffic flow and identify malicious activity within a network. Understanding these tools is essential for maintaining a secure posture by enforcing segmentation and enabling automated threat detection. These technologies are your primary instruments when you need to restrict unauthorized access or gain visibility into ongoing attack patterns within an enterprise environment.

Firewall Fundamentals: Filtering by Logic

A firewall acts as the gatekeeper of your network, operating primarily based on a defined set of rules that dictate which traffic is permitted or denied. The core logic relies on evaluating packet headers—specifically source and destination IP addresses, port numbers, and transport protocols—against an ordered rulebase. It is crucial to understand that firewalls are inherently restrictive; the best practice is to employ a 'deny-all' default policy and explicitly permit only the traffic necessary for business operations. When configuring a firewall, you are essentially defining the attack surface of the network. If a rule is too broad, you inadvertently invite attackers to exploit services that should be isolated. By applying the principle of least privilege, you ensure that even if an internal host is compromised, the damage is contained because the firewall blocks lateral movement to sensitive network segments that the host does not strictly require access to.

# Using standard filtering rules for an internal server
# Default policy is DENY ALL
iptables -P INPUT DROP
iptables -P FORWARD DROP

# Permit established connections to maintain active sessions
iptables -A INPUT -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT

# Explicitly permit SSH from a trusted management workstation only
iptables -A INPUT -p tcp -s 10.0.5.20 --dport 22 -j ACCEPT

Stateful Inspection: Monitoring Connection Life Cycles

Unlike static packet filtering which evaluates packets in isolation, stateful inspection maintains awareness of the context of a connection. The firewall tracks the state of active sessions—from the initial handshake to termination—by maintaining a state table. This is why it works so effectively: it prevents attackers from spoofing return traffic or bypassing security by simply crafting a packet that looks like a valid response to an internal request. If a packet arrives that does not match an existing, tracked connection and does not initiate a new, permitted connection, it is dropped immediately. This mechanism provides a deep layer of security because the firewall 'remembers' the traffic history. When designing security policies, you must account for this statefulness to avoid disrupting legitimate application protocols that dynamically negotiate ports, such as certain voice-over-IP or complex client-server applications that rely on persistent, tracked sessions to function correctly without exposing wide port ranges.

# Stateful inspection requires tracking connection status
# Ensure we accept traffic associated with known internal state
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT

# Block incoming packets that don't start a valid connection (invalid state)
iptables -A INPUT -m state --state INVALID -j DROP

Intrusion Detection Systems (IDS): Passive Visibility

An Intrusion Detection System operates as a passive observer that mirrors network traffic to analyze it for signatures of known malicious activity. Because it sits out-of-band—meaning it does not actually touch the traffic moving to its destination—an IDS can perform deep packet inspection without introducing latency or becoming a point of failure for the network path. It works by comparing the contents of packets against a database of known attack patterns or by establishing a statistical baseline of 'normal' network behavior to identify anomalies. If an IDS identifies a potential threat, it triggers an alert for security analysts to investigate. This is critical because it provides visibility into threats that might have bypassed perimeter defenses. When managing an IDS, the challenge is tuning the detection logic; too sensitive, and you face alert fatigue from false positives; too lax, and you miss genuine stealthy reconnaissance attempts or data exfiltration events occurring in real-time.

# Configuration snippet for a passive network monitoring tool
# Define the network interface to monitor in promiscuous mode
interface "eth1" {
    # Alert on suspicious ICMP payloads often used in covert channels
    alert icmp any any -> any any (msg: "Potential ICMP covert channel"; dsize:>128; sid:10001;)
}

Intrusion Prevention Systems (IPS): Active Mitigation

An Intrusion Prevention System is the logical evolution of the IDS; it is deployed in-line, meaning the traffic must physically pass through the device to reach its destination. This allows the IPS to take immediate, active action when a threat is identified. Instead of just sending an alert, the IPS can drop malicious packets, terminate TCP sessions, or dynamically update firewall rules to block the source IP address. It works by combining the detection capabilities of an IDS with the enforcement power of a firewall. The trade-off is the operational risk; because the IPS sits in-line, a misconfiguration or a failure of the device itself can cause a total network outage. Therefore, effective IPS management requires rigorous testing of signature updates and 'fail-open' hardware configurations to ensure that security measures do not inadvertently result in denial-of-service for legitimate users during high-traffic periods or device malfunctions.

# IPS rule to drop traffic matching a specific exploit signature
# Unlike IDS, the action is to drop the traffic directly in-line
-A INPUT -p tcp --dport 80 -m string --string "/etc/passwd" --algo bm -j DROP
# Drop packets matching common brute-force signature patterns
-A INPUT -p tcp --dport 22 -m recent --set --name SSH --rsource
-A INPUT -p tcp --dport 22 -m recent --update --seconds 60 --hitcount 4 --name SSH -j DROP

Integrated Management and Security Orchestration

Modern security management requires the integration of firewall, IDS, and IPS technologies into a unified defensive strategy. Managing these components in silos leads to inconsistent security policies and gaps in coverage. An integrated approach involves centralized logging and correlation, where alerts from the IPS are automatically forwarded to a central management console to trigger real-time updates to firewall filtering rules. For example, if the IPS identifies a brute-force attack from a specific geographic region, the management system can automatically push a temporary blocking rule to all edge firewalls. This creates an automated feedback loop that significantly reduces the 'time-to-remediate' for known threats. Success in this domain relies on rigorous change management, documented baseline configurations, and regular audits of the rulebase to remove redundant, permissive, or outdated entries that could be exploited by an adversary to gain unauthorized persistence.

# Automated script to update blocking list from threat intelligence
# Add malicious source IPs dynamically to a blacklist set
ipset create blacklist hash:ip hashsize 4096
# Block all traffic from IPs currently in the dynamic blacklist
iptables -I INPUT -m set --match-set blacklist src -j DROP
# Script triggered by IPS to add identified attacker to the block list
ipset add blacklist 192.0.2.55

Key points

  • Firewalls enforce security boundaries by filtering traffic based on source, destination, and protocol.
  • The default policy for any firewall should be to deny all traffic that is not explicitly allowed.
  • Stateful inspection allows firewalls to track the life cycle of connections, preventing unauthorized return traffic.
  • An IDS functions passively out-of-band, providing visibility into potential threats without impacting network throughput.
  • An IPS operates in-line and provides active mitigation by blocking malicious traffic before it reaches its target.
  • Successful defensive security requires balancing detection sensitivity against the risk of false positives.
  • Centralized management enables automated responses to threats by correlating alerts from multiple security sensors.
  • Regular audits of firewall and IPS configurations are necessary to remove outdated rules and reduce the attack surface.

Common mistakes

  • Mistake: Deploying an IPS in inline mode without testing in passive (IDS) mode first. Why it's wrong: It can cause massive network downtime due to false positives blocking legitimate traffic. Fix: Deploy in IDS mode to tune signatures before switching to active blocking.
  • Mistake: Allowing 'Any/Any' rules as a fallback for internal traffic. Why it's wrong: This violates the principle of least privilege and allows lateral movement if a host is compromised. Fix: Implement strict micro-segmentation and explicit 'deny all' rules.
  • Mistake: Neglecting to update firmware or signature databases regularly. Why it's wrong: Outdated signatures fail to detect zero-day exploits or newer attack vectors. Fix: Enable automated, scheduled updates and monitor version logs.
  • Mistake: Over-reliance on signatures while ignoring anomaly detection. Why it's wrong: Signature-based detection is blind to novel or polymorphic threats that don't match existing patterns. Fix: Combine signature-based detection with behavioral analysis for a defense-in-depth approach.
  • Mistake: Placing an IDS/IPS on the wrong side of the gateway. Why it's wrong: Placing it behind the NAT firewall obscures source IP data, making it difficult to trace attacks to their origin. Fix: Place the sensor at the network perimeter, typically between the external router and the internal firewall.

Interview questions

What is the fundamental difference between a firewall and an Intrusion Detection System (IDS)?

A firewall is a preventative control that acts as a gatekeeper, inspecting traffic based on predefined rules like source, destination, and port, and either permitting or blocking it to stop unauthorized access. In contrast, an IDS is a detective control designed to monitor network traffic for suspicious patterns or policy violations. While a firewall enforces a security perimeter, an IDS alerts administrators to potential threats that have already bypassed or circumvented that perimeter, providing visibility into the internal network behavior.

How does an Intrusion Prevention System (IPS) differ from an IDS, and why might you choose one over the other?

The primary distinction is active versus passive intervention. An IDS only identifies and alerts on malicious activity, whereas an IPS is placed inline, allowing it to actively drop packets or block connections in real-time when it detects an attack. You would choose an IPS when immediate, automated response is required to mitigate threats like zero-day exploits. However, an IDS is often preferred in sensitive environments where the risk of an IPS accidentally blocking legitimate traffic—known as a false positive—could cause unacceptable business downtime.

Can you explain the difference between signature-based and anomaly-based detection methods in security appliances?

Signature-based detection relies on a database of known attack patterns, essentially 'fingerprints' of malicious code or traffic, similar to how antivirus software functions. It is highly accurate for known threats but fails against new, unknown attacks. Anomaly-based detection, conversely, establishes a baseline of 'normal' network behavior—such as standard traffic volume or typical protocol usage—and flags anything that deviates from this profile. It is better at catching zero-day threats but frequently generates more false positives due to natural shifts in network behavior.

When configuring a firewall, what is the best practice regarding the 'default deny' rule, and why?

The 'default deny' or 'implicit deny' rule is the cornerstone of a Zero Trust architecture. It ensures that any traffic not explicitly permitted by a defined rule is automatically dropped. By strictly defining only required ports and protocols (e.g., allow TCP 443 for web traffic and drop everything else), you minimize your attack surface significantly. Without this, you might inadvertently leave open dangerous ports like Telnet or SMB to the public internet, which can be easily exploited by automated bots scanning for vulnerabilities.

How would you approach the placement of an IDS or IPS within a multi-tiered network architecture?

Proper placement involves strategic positioning based on traffic flow and trust zones. I would place an IDS at the perimeter to monitor external threats, but also implement sensors between internal network segments—such as between the web server and database server. For an IPS, I would place it inline between the external router and the firewall to clean traffic before it reaches the internal network. This layered approach ensures that if a malicious actor traverses the perimeter, they are still subject to deep packet inspection during lateral movement, effectively creating a 'defense-in-depth' strategy that covers both external and internal traffic paths.

Explain the concept of 'stateful inspection' in firewalls and why it is superior to simple static packet filtering.

Stateful inspection is superior because it tracks the state of active network connections. A simple static firewall evaluates each packet in isolation, which is dangerous; an attacker could send a packet with a 'reply' flag set to sneak through an open port. A stateful firewall keeps a 'state table' that records the context of the connection, such as the source IP, destination IP, and sequence numbers. For example, if a client initiates a request, the firewall remembers that the connection is active and allows the return traffic automatically, while ensuring that subsequent packets belong to that valid, pre-established session, effectively thwarting session hijacking attempts.

All cyber security interview questions →

Check yourself

1. When configuring an IPS to mitigate a volumetric DoS attack, which strategy is most effective for maintaining availability while protecting the resource?

  • A.Enable deep packet inspection for all incoming traffic to identify malicious payloads.
  • B.Implement rate limiting at the network boundary rather than packet-level analysis.
  • C.Disable the IPS temporarily to prevent CPU exhaustion on the security appliance.
  • D.Configure the IPS to drop all UDP traffic originating from external networks.
Show answer

B. Implement rate limiting at the network boundary rather than packet-level analysis.
Rate limiting is the most effective defense against volumetric attacks as it prevents resource exhaustion; deep packet inspection (Option 0) is too resource-intensive during high traffic, disabling the IPS (Option 2) leaves the network defenseless, and dropping all UDP (Option 3) blocks legitimate services like DNS.

2. A firewall is configured with a rule to allow SSH traffic from a specific subnet, but connections are failing. Which of the following is the most likely culprit regarding stateful packet inspection?

  • A.The firewall is not configured to perform reverse DNS lookups on the source IP.
  • B.The return traffic is being blocked by a rule that denies all incoming traffic not initiated by the firewall.
  • C.The firewall's state table is full and cannot process the initial TCP three-way handshake.
  • D.The IPS signatures are flagging the SSH session initiation as a buffer overflow attempt.
Show answer

B. The return traffic is being blocked by a rule that denies all incoming traffic not initiated by the firewall.
Stateful firewalls track the connection state; if the return path is not dynamically allowed by the state table or an explicit rule, the connection fails. Reverse DNS (Option 0) is irrelevant, a full state table (Option 2) causes packet loss regardless of rule, and false positives (Option 3) are less likely than a basic rule configuration error.

3. Why is it critical to ensure an IPS has a high-availability (HA) configuration in a high-traffic environment?

  • A.To provide load balancing across multiple security appliances.
  • B.To ensure that signature updates can be applied without interrupting network flow.
  • C.To prevent the IPS from becoming a single point of failure that denies all traffic if it crashes.
  • D.To allow for the decryption of SSL/TLS traffic before it reaches the end host.
Show answer

C. To prevent the IPS from becoming a single point of failure that denies all traffic if it crashes.
Fail-open or HA configurations ensure that if the security appliance fails, traffic is not automatically blocked, maintaining uptime. Load balancing (Option 0) is a separate feature, updates (Option 1) are a benefit but not the primary driver for HA, and SSL inspection (Option 3) is a separate functional requirement.

4. How does an IDS differ from an IPS in the context of network placement and risk management?

  • A.An IDS must be inline, whereas an IPS is typically off-span.
  • B.An IDS is reactive and blocks threats, whereas an IPS is passive and monitors only.
  • C.An IDS acts as a sensor to inform administrators, while an IPS actively interacts with the traffic stream.
  • D.An IDS is only used for internal traffic, while an IPS is only used for external traffic.
Show answer

C. An IDS acts as a sensor to inform administrators, while an IPS actively interacts with the traffic stream.
IDS is passive, meaning it sits on a span/mirror port and reports threats without touching the live traffic flow. IPS is active/inline and can block traffic. Options 0, 1, and 3 misidentify the fundamental operational differences between the two.

5. When auditing firewall logs, you notice a large number of 'Deny' entries originating from an internal server to an external blacklisted IP. What should your first management step be?

  • A.Modify the firewall rule to allow the traffic so the logs stop filling up.
  • B.Immediately isolate the internal host to prevent potential data exfiltration or command-and-control communication.
  • C.Increase the logging level to capture full packet payloads for forensic analysis.
  • D.Check the IDS signature database for updates to see if the activity is a false positive.
Show answer

B. Immediately isolate the internal host to prevent potential data exfiltration or command-and-control communication.
Evidence of internal-to-external communication with a malicious IP suggests a compromise; isolation is the priority. Allowing the traffic (Option 0) creates a breach, increasing logging (Option 2) delays response, and checking signatures (Option 3) is ineffective if the IP is already confirmed malicious.

Take the full cyber security quiz →

← PreviousEthical and Legal Aspects of Cyber SecurityNext →Endpoint Protection: Antivirus, EDR, and Anti-Malware Solutions

cyber security

34 lessons, free to read.

All lessons →

Track your progress

Sign in to mark lessons done, score quizzes and keep notes.

Open in the app