Skip to main content
← Unit 3: Securing Networks

Code Scholars Tutoring · AP Cybersecurity

Firewall and Rule Reasoning

Related Unit 3 topic notes: 3.4.

How it works

Firewall rules describe source, destination, protocol, port, and action. The safest rule set permits required traffic and blocks unnecessary paths.

Translate rules into plain English before answering: who can talk to whom, over what service, and what is blocked.

Common error

Do not allow all traffic just because one application must be reachable.

Unit 3 topics and evidence practice

Investigate a fictional Mosaic Design Studio network through five topics: attack evidence, wireless policy, segmented paths, firewall decisions, and detection. All addresses, devices, domains, events, and measurements are teaching examples. Public-looking addresses use documentation ranges, and .test names are not live services. Existing foundation lessons and exercises remain available. Configuration artifacts describe a lab policy, not changes to a live network.

3.4 Protecting Networks: Firewalls

Read a firewall by its traffic fields, processing model, state, and placement. The studio table is an abstract first-match view of new forwarded IPv4 TCP/UDP initiations after the stated destination translation. It is a teaching subset: stateful returns, required control traffic, IPv6, and other approved services are considered separately.

Read topic 3.4 notes, evidence, and quick checks

3.4.A: Choose inspection behavior appropriate to the task

A stateless packet filter evaluates packet fields without connection tracking. A stateful firewall tracks relevant sessions and applies configured state policy. A proxy mediates supported application exchanges; next-generation products can combine application awareness, intrusion prevention, and other functions. Actual capabilities, configuration, visibility, and resources matter. A label does not guarantee better security, decrypted inspection of every TLS session, or absence of false blocks.

3.4.B: Match every relevant field

For the stated lab model, read priority, action, source, destination, transport protocol, and destination port. Source and destination are not interchangeable, and a TCP rule does not match a UDP flow with the same number. A named group must have a documented membership. A service port is a traffic clue, not proof of user identity, encrypted content, or a completed application task.

Stop at the first matching row under this model

The studio policy is explicitly top-to-bottom first match. A narrow DNS, administration, or front-end exception must appear before a broad denial that would otherwise match it. Later permits cannot rescue an already denied packet. Some real products use different chains, stages, priorities, or defaults; read the actual rule context rather than assuming every list implements this exact model.

Keep initiation, return state, and application authentication distinct

A permitted new flow can establish a transport path without completing a user login. Stateful return handling can allow replies to an approved session without permitting an unrelated new reverse initiation. Stateless designs need appropriate separate return rules. A state entry or TCP handshake is not a database authorization result, and a deny at one boundary does not prove every possible path was blocked.

Make the unmatched result explicit

The example finishes with an explicit deny for remaining new TCP/UDP initiations. An implicit deny is a configured/default behavior when no explicit row matches; do not infer it from a missing screenshot row or a product name. Define the intended fallback, logging and required exceptions. Broad any-to-any permits or an undocumented allow default can undermine the stated design.

3.4.C: Place enforcement on the path that needs controlling

Perimeter filtering controls relevant external crossings; internal boundaries restrict role-to-role paths; host controls can cover local service or same-zone exposure. A DMZ isolates published roles through the appropriate routed policy. A firewall that traffic never traverses cannot enforce that path. Include both directions, management access, failover routes, and relevant protocol families when verifying placement.

3.4.D: Correct the narrow requirement instead of widening everything

Translate the required task into exact source/destination/service and compare it with the current rules and state. Save the approved prior configuration, identify the first match, make the justified narrow change, and verify permitted work plus intended denials. A source-any SSH suggestion may remove an error while exposing administration to guests. Review the service need and rollback process before consequential use.

Read permit and deny as enforcement observations

A firewall PERMIT entry records the decision at that control, not a successful password, session ownership, or data read. Repeated denied connections can suggest probing or a configuration issue; they are not automatically password guesses because denied traffic may never reach authentication. A later permit can follow a policy change or an approved exception. Correlate identity, application, endpoint, and change records before labeling the outcome.

Firewall inspection models and practical limits
ModelWhat it evaluates or mediatesLimit to check
Stateless packet filteringRelevant packet headers under configured rules.No inherent connection tracking; correct return handling and context still need design.
Stateful inspectionRelevant packet/session state plus configured policy.A tracked flow is not proof of successful user authentication or safe content.
Application proxySupported application exchange through a mediating service.Protocol support, trust/identity handling, capacity, and actual payload visibility matter.
Next-generation functionsConfigured combinations such as app awareness and IPS.Features require supported configuration and visibility; encrypted payload inspection is not automatic.
Studio new-initiation policy: IPv4 TCP/UDP, after destination translation
Priority / actionSourceDestinationProtocolDestination port
10 · PERMITGUESTS, STAFFDNS · 10.186.33.53TCP/UDP53
20 · PERMITADMIN · 10.186.44.14FRONT · 10.186.55.10TCP22
30 · PERMITANYFRONT · 10.186.55.10TCP443
40 · PERMITFRONT · 10.186.55.10DB · 10.186.33.20TCP5432
50 · PERMITFRONT · 10.186.55.10LOG · 10.186.33.60TCP6514
60 · DENYGUESTSORG · 10.186.0.0/16TCP/UDPANY
70 · DENYDMZORG · 10.186.0.0/16TCP/UDPANY
80 · PERMITGUESTSREFERENCE · 203.0.113.160TCP443
90 · DENYANYANYTCP/UDPANY

Rule trace: define the groups and the scope before selecting a row

FICTIONAL POLICY SCOPE
GUESTS = 10.186.11.0/24; STAFF = 10.186.22.0/24
DMZ = 10.186.55.0/24; ORG = 10.186.0.0/16
Named single-host destinations/sources are shown in the rule table.
REFERENCE is only the documentation host 203.0.113.160, not the whole internet.
First match applies to NEW forwarded IPv4 TCP/UDP initiations in this view.
Stateful returns, required control traffic, and IPv6 are separate design items.

TRACES
Guest .11.28 -> DNS .33.53 UDP/53: rule 10 PERMIT
Guest .11.28 -> front .55.10 TCP/443: rule 30 PERMIT
Guest .11.28 -> front .55.10 TCP/22: rule 60 DENY
Admin .44.14 -> front .55.10 TCP/22: rule 20 PERMIT
Front .55.10 -> DB .33.20 TCP/5432: rule 40 PERMIT
Front .55.10 -> staff .22.47 TCP/445: rule 70 DENY
Guest .11.28 -> reference 203.0.113.160 TCP/443: rule 80 PERMIT
Guest .11.28 -> reference 203.0.113.160 UDP/443: rule 90 DENY

Evaluate complete fields in order. DNS and published-gallery exceptions precede the guest internal denial; the UDP reference flow does not match its TCP-only exception. That denial is a property of this teaching subset, not a claim that HTTPS never uses UDP. A permit still needs a real service, correct identity, allowed application action, and a usable return path.

Two unsafe fixes: shadowed exceptions and an overbroad source

FICTIONAL REVIEW DRAFTS
Broken order: put DENY GUESTS -> ORG TCP/UDP ANY above rule 10.
Observed effect: guest DNS and the translated internal front-end destination
match that denial before their intended exceptions.
Narrow repair: preserve the required exceptions before the broad denial.

Separate AI suggestion: change rule 20 source from ADMIN to ANY.
Requirement: only designated admin .44.14 may initiate front-end SSH.
Consequence: the earlier ANY permit would admit guest SSH before rule 60.
Review: reject the broad source and verify the actual admin need and policy.

The ordering fault explains a failed required path without justifying an allow-all rule. The proposed SSH source change violates the stated requirement even though a later guest denial still exists. Verify guest DNS/gallery success, designated-admin success, and guest SSH/database denials after the approved correction. Keep the prior configuration and current tests tied to the actual change.

Vocabulary in context

ACL
A set of access rules interpreted under the stated processing model.
First match
In this exercise, the first row matching all relevant fields decides the new flow.
Stateful inspection
Using tracked connection context together with configured policy.
Default deny
An explicit or configured fallback denying unmatched traffic in the stated scope.
Shadowed rule
A rule whose intended traffic is already handled by an earlier matching rule.
Enforcement perspective
The traffic fields and processing stage visible to the policy or reporting device.

Quick checks

Form your answer, then open the question to compare your reasoning.

1. Which rule handles guest DNS over TCP as well as UDP?

Rule 10 explicitly permits both transports from GUESTS or STAFF to the stated resolver on destination port 53.

2. What permits guest access to the translated front-end destination on TCP 443 before the internal guest denial?

Rule 30 matches first. The exercise explicitly views the private destination after the public-service translation.

3. Which rules handle designated-admin SSH and guest SSH to the same front end?

Designated admin .44.14 matches rule 20 and is permitted. Guest SSH does not match that source and reaches rule 60, which denies it.

4. Can the front end initiate TCP 445 to the staff workstation under this table?

No. Its required DB/log exceptions do not match that flow; the DMZ-to-ORG denial at rule 70 does.

5. Why does guest UDP 443 to the reference host reach rule 90?

The reference exception at 80 is TCP-only. The TCP/UDP fallback at 90 denies the unmatched UDP initiation; service names do not override protocol matching.

6. What happens if a broad GUESTS-to-ORG denial moves above the DNS and front-end exceptions?

It matches those internal destinations first and shadows the intended permits. Put the required narrow exceptions before the broad denial under this model.

7. Why is changing the SSH permit source to ANY unsafe even with a later guest denial?

The earlier broad permit matches guest SSH first, so the later denial cannot rescue the requirement. Keep the designated source and test it.

8. Does PERMIT TCP 22 prove the correct password was supplied?

No. It records an enforcement decision for the flow. Authentication and command/session activity need service or identity evidence.

9. Does a stateful response allowance authorize every unrelated reverse initiation?

No. Matching return state is different from a new session in the reverse direction. Verify the actual device state and policy.

10. Can an IPv4 rule screenshot or a perimeter firewall prove complete IPv6 or same-VLAN protection?

No. Check each relevant protocol family and actual path, including host or workload enforcement where traffic does not cross the shown boundary.

Worked example

Evaluate a first-match rule table for a management service.

Evidence

1 ALLOW admin-subnet -> server TCP 22
2 DENY any -> server TCP 22
3 ALLOW any -> server TCP 443
4 DENY any -> any ANY

Administrator-subnet SSH is permitted by rule 1. Other SSH reaches rule 2 and is denied. HTTPS reaches rule 3 and is allowed. Rule order and all matching fields matter; a narrow exception must appear before a general deny when using first-match processing.

Exercises

Exercise 1

Which rule handles a guest SSH request, and which handles a guest HTTPS request?

Show solution

Guest SSH matches rule 2 and is denied. Guest HTTPS does not match the SSH rules, so rule 3 allows it.

Exercise 2

What goes wrong if rule 2 is moved above rule 1?

Show solution

The general SSH denial matches administrator SSH first, so the administrator exception is never reached. Test required access after reordering rules.

Need help with this topic?

Work through questions with a tutor and get help with the steps you find difficult.

Get help with this topic