Internet and Network Security

Chapter 6
Firewalls, IDS/IPS and Defensive Appliances

Diploma in Cyber security
Internet and Network Security   •   Diploma

Firewalls, IDS/IPS and Defensive Appliances

Introduction and Context

Network security depends on layered controls rather than a single protective product. Firewalls regulate communication between networks or security zones; intrusion detection systems (IDS) identify suspicious activity; intrusion prevention systems (IPS) can block or interrupt it; web application firewalls (WAFs) protect web-facing applications; honeypots generate intelligence and deception; and secure gateways enforce security policy at important network boundaries.

These technologies are most effective when they are designed as part of an architecture. A firewall that permits excessive traffic, an IDS that produces unreviewed alerts, or an IPS that blocks legitimate business activity can reduce security rather than improve it. Professional practice therefore combines accurate rule design, change control, testing, logging, monitoring and periodic review.

This chapter develops the principles required to configure and evaluate these controls. It emphasizes defensible rule sets: rules that are necessary, narrowly scoped, documented, tested, ordered correctly and monitored after deployment.

Learning Objectives

By the end of this chapter, a learner should be able to:

  • distinguish packet-filtering, stateful and next-generation firewalls;
  • explain addresses, ports, protocols, zones and access-control lists;
  • design and test firewall and gateway rules;
  • describe the roles and limitations of IDS, IPS and WAF technologies;
  • explain how honeypots and secure gateways support defence;
  • evaluate false positives, false negatives, performance and operational risk;
  • apply a structured process to an illustrative enterprise security problem.

1. Security Boundaries and Defensive Architecture

A security boundary is a controlled point through which traffic, users or data must pass. Common zones include the Internet, an external demilitarized zone (DMZ), an internal user network, a server network, a management network and a restricted data zone. Segmentation reduces the consequences of compromise: an attacker who compromises a public web server should not automatically reach databases or administrative systems.

A typical request follows this sequence:

  1. A client creates traffic with a source address, destination address, protocol and port.
  2. A firewall or gateway receives the packet and identifies its interface and security zone.
  3. The device evaluates policy, often from the first matching rule.
  4. If permitted, the device may perform network address translation, proxying, inspection or authentication.
  5. The event is logged according to the organisation’s monitoring policy.
  6. IDS, IPS, endpoint and application controls may inspect the same flow or its resulting activity.

Security controls should be placed according to trust, exposure and business function. A firewall is not a substitute for secure coding, patching, identity management or endpoint protection. Defence in depth is valuable because controls fail in different ways.

2. Firewall Fundamentals

A firewall is a hardware or software control that enforces a traffic policy between interfaces or zones. Its policy normally specifies a source, destination, service, action and logging requirement.

Important terms include:

  • Source and destination: the originating and receiving address, host or network.
  • Protocol: such as TCP, UDP, ICMP or an application-layer protocol.
  • Port: a transport-layer identifier associated with a service. A port is not itself proof of application identity.
  • Zone: a logical trust or security domain.
  • Action: commonly permit, deny, reject, reset, inspect or log.
  • Implicit deny: traffic not explicitly permitted is denied.
  • Rule shadowing: an earlier broad rule prevents a later specific rule from being evaluated.
  • Egress filtering: control of outbound traffic.
  • North-south traffic: traffic entering or leaving the organisation.
  • East-west traffic: traffic moving between internal systems or segments.

A sound default policy is to deny unneeded traffic and explicitly permit justified communication. However, an implicit deny should be accompanied by a controlled process for requesting, approving and testing exceptions; otherwise users may create unsafe workarounds.

2.1 Packet-Filtering Firewalls

A packet-filtering firewall examines packet-header information, commonly source and destination IP addresses, protocol and port. A rule might allow TCP traffic from a web client network to a public server on destination port 443.

Packet filters are efficient and comparatively simple. They are suitable for basic segmentation, infrastructure filtering and high-volume traffic. Their limitations are equally important: they have limited awareness of connection context, application meaning and user identity. A packet filter may allow malicious content carried over an otherwise permitted port.

2.2 Stateful Firewalls

A stateful firewall maintains a state table describing active connections. For TCP, it can distinguish an established flow from an unsolicited packet and can verify aspects of the connection sequence. Return traffic for an approved outbound connection may be allowed because it matches an existing state entry, while an unrelated inbound packet is denied.

Stateful inspection improves security and usability, but it does not validate that an application is safe. It also consumes memory and processing resources. Exhaustion attacks, unusual protocols, asymmetric routing and long-lived sessions can create operational difficulties. State time-outs must reflect application behaviour without leaving stale entries unnecessarily long.

2.3 Next-Generation Firewalls

A next-generation firewall (NGFW) combines traditional filtering with features such as application identification, user or identity awareness, integrated intrusion prevention, URL filtering, malware analysis and encrypted-traffic inspection. Its policies can therefore distinguish between applications using the same port.

NGFW features introduce dependencies. Application identification may require updated signatures; user-aware rules may depend on directory integration; TLS inspection requires certificate deployment and creates privacy and performance considerations. A rule that states “permit business collaboration application” is useful only if the device can reliably identify that application and the organisation accepts the associated inspection limitations.

3. Access-Control Lists and Rule Engineering

An access-control list (ACL) is an ordered set of conditions and actions. Many devices evaluate rules from top to bottom and stop at the first match. Consequently, order is part of the policy’s meaning.

A practical rule record should contain:

FieldPurpose
Rule identifierSupports reference and audit
SourceHost, subnet, zone or identity
DestinationHost, subnet, zone or service
ServiceProtocol, port or application
ActionPermit, deny or inspect
LoggingDefines events and log level
OwnerIdentifies the responsible business or technical team
JustificationExplains necessity and risk
Review datePrevents permanent accumulation

3.1 Principles for Defensible Rules

Least privilege permits only the communication required for a defined function. A database should normally accept connections from specified application servers, not from every internal workstation.

Specificity reduces unintended access. Restrict source, destination, service, direction and, where appropriate, time. Avoid “any-to-any” rules except for tightly controlled diagnostic or transitional purposes.

Separation of duties means that request, approval, implementation and review are not concentrated in one unchecked role.

Explicitness makes policy understandable. A named service object is preferable to an unexplained collection of ports, provided the object is accurately defined.

Temporary access should have an expiry date. Emergency rules should be marked, logged and reviewed after the emergency.

Logging proportionality is important. Log denied traffic useful for investigation, successful sensitive access and rule changes, but avoid excessive logging that overwhelms analysts or storage.

3.2 Example of Rule Ordering

Suppose an ACL contains:

  1. Permit internal users to access any destination on TCP port 443.
  2. Deny internal users to a particular high-risk external service.
  3. Deny all other traffic.

If the high-risk service also uses TCP port 443, rule 2 is shadowed by rule 1. The safer order is:

  1. Deny internal users to the high-risk service.
  2. Permit internal users to approved HTTPS destinations.
  3. Deny all other traffic.

This example illustrates why testing must examine both intended and unintended matches.

3.3 Network Address Translation

Network address translation (NAT) changes address information as traffic crosses a device. Source NAT commonly allows private internal addresses to share a public address for outbound connections. Destination NAT or port forwarding can publish a service to external clients.

NAT is not a complete security control. It may obscure internal addressing and require an explicit inbound mapping, but it does not replace authentication, patching or application security. Publishing a vulnerable server through a port-forwarding rule increases exposure even when the rule is technically correct.

4. Intrusion Detection and Prevention

An IDS observes traffic or host activity and generates alerts. An IPS is positioned to take preventive action, such as dropping packets, resetting connections or quarantining a source. IDS is generally passive; IPS is generally inline, although products and deployment modes vary.

4.1 Detection Methods

Signature detection compares activity with known patterns. It is effective for recognised threats and usually easier to explain, but it may miss modified or novel attacks.

Anomaly detection identifies deviation from a baseline. It can detect unusual behaviour but depends on a representative baseline and may produce many false alarms when legitimate behaviour changes.

Stateful protocol analysis evaluates whether traffic conforms to expected protocol behaviour. It can identify malformed or suspicious sequences but requires protocol knowledge and careful tuning.

Behavioural and machine-learning methods model relationships among users, devices and events. They can support prioritisation and discovery, but outputs require validation, quality data and governance. A model’s confidence is not equivalent to proof of malicious intent.

4.2 Detection Outcomes

A true positive is malicious activity correctly identified. A true negative is legitimate activity correctly treated as benign. A false positive is legitimate activity incorrectly alerted or blocked. A false negative is malicious activity missed by the control.

A useful operational measure is precision:

Precision = TP ÷ (TP + FP)

Here, TP is the number of true positives and FP is the number of false positives. Precision is meaningful only when the classification criteria and observation period are defined. It does not measure attacks that were missed. Detection rate or recall is often represented as:

Recall = TP ÷ (TP + FN)

where FN is the number of false negatives. These measures should not be treated as universal product scores because attack prevalence, labelling quality and deployment conditions affect them.

An IPS action should be selected according to confidence and business impact. High-confidence malicious traffic may be dropped automatically. Ambiguous events may be logged, rate-limited or sent for analyst review. Blocking a critical business transaction without a recovery path can create greater immediate harm than delayed investigation.

5. Web Application Firewalls

A WAF examines HTTP or HTTPS requests and responses at the application layer. It can enforce policies concerning methods, URLs, headers, parameters, cookies, request size, sessions and known attack patterns such as some forms of injection and cross-site scripting.

A WAF is particularly useful as a compensating control when application changes cannot be completed immediately. It cannot reliably correct insecure business logic, weak authorisation design or every form of input-handling error. A WAF rule should not be used as an excuse to leave a vulnerable application unpatched.

WAF deployment modes include reverse proxy, cloud service and embedded or host-adjacent approaches. Important design decisions include certificate management, upload handling, API formats, WebSocket support, logging of sensitive data, tuning for legitimate encoded input and protection against WAF bypass through inconsistent parsing.

6. Secure Gateways and Defensive Appliances

A secure web gateway mediates user web access and may provide URL categorisation, malware scanning, data-loss controls, authentication and policy enforcement. A secure email gateway filters spam, phishing, malicious attachments and suspicious links. DNS security gateways can block resolution of known malicious domains and provide useful telemetry.

Unified threat-management and security-service-edge platforms integrate several functions. Integration can reduce administrative complexity but may create concentration risk, licensing dependency and a larger failure domain. Organisations should document which security function is responsible for each decision and maintain resilience if the appliance or cloud service is unavailable.

Encrypted traffic presents a major challenge. TLS inspection may improve visibility, but it requires trust certificates, key-handling controls, privacy safeguards, exception lists and sufficient capacity. Sensitive categories such as personal health, legal or financial communication may require exclusion according to law and policy.

7. Honeypots and Deception

A honeypot is a system intentionally designed to attract or expose unauthorised activity. A low-interaction honeypot emulates limited services and is easier to contain. A high-interaction honeypot provides a more realistic environment and can yield richer intelligence, but it creates greater containment and maintenance requirements.

Honeypots should be isolated, monitored and treated as hostile by design. They must not contain real credentials, personal data or routes into production networks. Deception can reveal scanning, credential attacks and attacker techniques, but absence of honeypot activity does not demonstrate that the wider network is safe. Legal and ethical review is required when collecting attacker data or interacting with external systems.

8. Configuration, Testing and Operations

A professional deployment begins with a requirements statement: protected assets, permitted business flows, prohibited flows, availability requirements, logging obligations and responsible owners. The designer then maps traffic flows and creates zones.

A useful implementation cycle is:

  1. Discover: inventory assets, services, routes and dependencies.
  2. Design: define zones, trust relationships and least-privilege flows.
  3. Build: create objects, rules, inspection profiles and logging settings.
  4. Review: conduct peer review, risk review and rule-shadow analysis.
  5. Test: verify permitted flows, denied flows, logging, failover and performance.
  6. Deploy: use a controlled change window and a rollback plan.
  7. Monitor: inspect alerts, denied traffic, resource usage and user impact.
  8. Improve: remove obsolete rules, tune detections and update documentation.

Testing should include positive tests, which confirm that required traffic works, and negative tests, which confirm that prohibited traffic fails. It should also test malformed packets, unexpected protocols, fragmented traffic where relevant, IPv6 paths, DNS behaviour, NAT mappings, fail-open or fail-closed behaviour and administrative access.

A rule review can classify each rule as necessary, redundant, shadowed, overbroad, unused, undocumented or temporary. Unused rules should not be deleted blindly; logs, application owners and dependency analysis should be consulted first.

9. Illustrative Case: Northbridge College

Background

Northbridge College operates a public learning portal, an internal student network, staff systems and a restricted finance database. The college has one Internet connection and recently experienced repeated scans against its portal and suspicious outbound connections from student devices.

Problem

The existing firewall contains broad rules created during several emergency changes. The portal server can communicate directly with an internal database subnet, student devices can reach administrative interfaces, and the IDS produces more alerts than the small security team can review.

Analysis

The security team maps required flows. External users need HTTPS access to the portal. The portal requires a specific database service, but the database should not initiate sessions to the portal. Staff require authenticated access to selected administrative applications. Students require Internet access but not management interfaces or finance systems. DNS and email services require separate controls.

The team identifies three major risks: excessive east-west access, inadequate egress control and alert fatigue. It also confirms that the portal is vulnerable to a recently disclosed input-validation issue and requires urgent patching.

Approach and Solution

The college creates separate Internet, DMZ, student, staff, server and management zones. It replaces broad rules with specific flows. External HTTPS is permitted only to the portal’s public address. The portal is allowed to reach the database on the required service and destination only. Student access to management and finance zones is denied explicitly before general Internet rules. Administrative access is restricted to the management network and multifactor authentication.

A WAF is placed in front of the portal while the application is patched. The IDS is tuned to suppress duplicate low-value alerts, prioritise exploitation attempts and send high-confidence events to the incident response queue. Egress rules restrict unusual outbound protocols and log connections to newly observed malicious domains. A small isolated honeypot is deployed in a research network, with no route to production.

The change is tested first in a staging environment. Positive tests verify portal access, staff workflows and approved database communication. Negative tests verify that students cannot reach finance systems, external users cannot access the database, and the portal cannot initiate arbitrary internal connections. A rollback configuration is retained.

Outcome

The college reduces reachable services, obtains more useful alerts and improves its ability to investigate outbound connections. Some legitimate research applications initially fail because they use uncommon protocols; these are reviewed individually rather than addressed through an unrestricted rule. The case demonstrates that security improvement is a continuing governance process, not merely the purchase of an appliance.

Learning Points

  • Segmentation limits the impact of compromise.
  • Rule order and specificity are security properties.
  • WAF and IDS controls complement, but do not replace, secure application development.
  • Alert quality matters more than raw alert volume.
  • Temporary exceptions need owners and expiry dates.

10. Challenges, Governance and Contemporary Practice

Defensive appliances face evasion, encrypted traffic, cloud migration, remote work, IPv6 adoption, high-speed links and complex application dependencies. Attackers may use legitimate services, encrypt command traffic or distribute activity across many addresses. Static rules alone cannot solve these problems.

Governance should define acceptable use, monitoring authority, retention periods, privacy safeguards, incident escalation and access to security logs. Logs may contain personal information, credentials accidentally submitted in URLs or sensitive business details. Collection should be necessary, protected and retained according to legal and organisational requirements. Administrative access should be strongly authenticated and audited.

Automation and artificial intelligence can assist with rule analysis, alert correlation, anomaly detection and prioritisation. They should not be treated as infallible. Automated rule generation can reproduce inaccurate assumptions, create overbroad access or obscure accountability. Human approval, testing, explainability and rollback remain essential.

Best practice is therefore a combination of least privilege, segmentation, secure defaults, centralised time-synchronised logging, regular vulnerability management, independent review, resilience testing and continuous improvement.

Chapter Summary

Firewalls enforce communication policy at network and application boundaries. Packet filters use header information, stateful firewalls track connection context, and NGFWs add application, identity and integrated inspection capabilities. ACLs must be ordered, specific, documented and reviewed; an implicit deny is valuable only when legitimate exceptions are governed.

IDS technologies detect suspicious activity, while IPS technologies can block it. Signature, anomaly and protocol-analysis methods have different strengths and weaknesses, and operational performance must consider false positives and false negatives. WAFs protect web traffic but cannot replace secure application design. Secure web, email and DNS gateways provide specialised controls, while honeypots provide controlled deception and intelligence.

Effective defence requires architecture, testing, logging, change control and human oversight. A defensible rule set is not simply one that works; it is one whose purpose, scope, owner, evidence and review status can be demonstrated.

Key Terms

Firewall: A control that enforces traffic policy between interfaces or security zones.

Packet filtering: Filtering based primarily on packet-header fields.

Stateful inspection: Evaluation of traffic using connection state and context.

Next-generation firewall: A firewall with advanced application, identity or integrated security functions.

Access-control list: An ordered set of conditions and actions controlling access.

Implicit deny: Denial of traffic that does not match an allow rule.

Rule shadowing: A condition in which an earlier rule prevents a later rule from being reached.

Egress filtering: Control of traffic leaving a network.

DMZ: A segmented network commonly used for externally accessible services.

Intrusion detection system: A system that identifies and reports suspicious activity.

Intrusion prevention system: A system capable of taking preventive action against detected activity.

False positive: A legitimate event incorrectly classified as malicious.

False negative: Malicious activity that a detection system fails to identify.

Web application firewall: A control that inspects and filters web application traffic.

Secure gateway: An intermediary that applies security policy to a service such as web or email access.

Honeypot: An isolated system designed to attract or reveal unauthorised activity.

Network address translation: A technique that translates address information between network domains.

Least privilege: Granting only the access necessary for an authorised purpose.

Defence in depth: The use of multiple complementary security controls.

Review Questions

Short Answer Questions

  1. What is the principal difference between a packet-filtering firewall and a stateful firewall?
  2. Why can rule ordering affect security?
  3. What is the purpose of egress filtering?
  4. Distinguish an IDS from an IPS.
  5. State one important limitation of a WAF.

Long Answer Questions

  1. Explain how zones, least privilege and implicit deny can be combined to design a defensible firewall policy.
  2. Compare signature, anomaly and protocol-analysis methods used by intrusion detection systems.
  3. Discuss the advantages and risks of TLS inspection at a secure gateway.
  4. Describe a complete lifecycle for creating, testing and reviewing firewall rules.
  5. Explain how honeypots can support security operations and the safeguards required for their use.

Analytical / Application Questions

  1. A public web server requires HTTPS access from the Internet and database access on one service. Design the minimum necessary zone and rule structure, including traffic that should be denied.
  2. An IPS blocks a legitimate examination system during a high-volume assessment. Analyse how the organisation should investigate, contain the risk and tune the policy without simply disabling prevention.
  3. A rule review finds an any-to-any permit rule followed by twenty restrictive deny rules. Explain the security and governance problems, propose a migration approach and identify tests needed before removing the broad rule.

Multiple Choice Questions with Answers

Question 1

Which firewall capability primarily distinguishes a stateful firewall from a basic packet filter?

A. It tracks the context of active connections.

B. It encrypts every packet automatically.

C. It replaces all endpoint security controls.

D. It permits all return traffic without inspection.

Correct Answer: A. It tracks the context of active connections.

Question 2

What is the main security problem with placing a broad permit rule before a specific deny rule?

A. The firewall will always reboot.

B. The deny rule may be shadowed and never evaluated.

C. The permitted service will become encrypted.

D. Logging will be automatically disabled.

Correct Answer: B. The deny rule may be shadowed and never evaluated.

Question 3

Which control is specifically designed to inspect HTTP requests and responses?

A. Network tap

B. Web application firewall

C. Backup server

D. Layer-two bridge

Correct Answer: B. Web application firewall

Question 4

An alert identifies legitimate activity as malicious. What is this classification called?

A. True negative

B. False negative

C. False positive

D. True positive

Correct Answer: C. False positive

Question 5

Which rule best reflects least privilege for a database server?

A. Permit every internal host to every database port.

B. Permit the specified application servers to the required database service.

C. Permit all Internet users to the database address.

D. Permit all protocols from the management network and student network.

Correct Answer: B. Permit the specified application servers to the required database service.

Question 6

What is the primary purpose of a honeypot?

A. To store production backups

B. To attract or reveal unauthorised activity in a controlled environment

C. To guarantee that all malware is removed

D. To replace network segmentation

Correct Answer: B. To attract or reveal unauthorised activity in a controlled environment

Question 7

If TP = 80 and FP = 20, what is the precision of the detection process?

A. 20%

B. 50%

C. 80%

D. 100%

Correct Answer: C. 80%

Question 8

Which statement about NAT is most accurate?

A. NAT alone provides complete application security.

B. NAT changes address information but does not replace authentication or patching.

C. NAT prevents all outbound attacks.

D. NAT eliminates the need for firewall policy.

Correct Answer: B. NAT changes address information but does not replace authentication or patching.

Question 9

Which test verifies that prohibited traffic cannot pass through a security control?

A. Positive testing

B. Negative testing

C. Capacity procurement

D. Asset naming

Correct Answer: B. Negative testing

Question 10

Why can excessive IDS alerts reduce security effectiveness?

A. They prevent all network traffic by definition.

B. They can create alert fatigue and obscure high-priority events.

C. They disable state tracking on every firewall.

D. They make encryption mathematically impossible.

Correct Answer: B. They can create alert fatigue and obscure high-priority events.

Internet and Network Security
Chapter 6 of 15