How Do Firewall Rules Work? (Explained Clearly) - Rule Order, Implicit Deny & Stateful Filtering
Firewall rules explained: Learn how rule order, implicit deny, and stateful filtering affect traffic, and how to use logs to troubleshoot blocked connections.
π Master your Security+ skills with Pluralsight here: Pluralsight
Youβll learn how firewall rules allow or block traffic, why rule order and implicit deny matter, and how stateful and stateless firewalls handle replies. This beginner-friendly Security+ guide shows you how to use firewall logs to troubleshoot access without allowing more traffic than intended.
Chapters: 0:00 Intro 0:13 What does a firewall rule actually check? 1:04 Which firewall rule wins when two rules match? 1:58 Why do replies get through a stateful firewall? 2:53 How do you troubleshoot a firewall rule that should work? 3:51 Outro
Affiliate notice: Some links may earn a commission. Thanks for your support.
Key Takeaways
Write rules for the connection you intend to allow. Specify who can initiate it, the destination, the protocol and port, and where the rule applies. A drop is silent; a reject sends a refusal when supported.
Check which rule wins. On first-match firewalls, a broad block can shadow a narrower allow. Windows Firewall and AWS security groups use different evaluation models.
Distinguish implicit from explicit deny. An implicit deny blocks unmatched traffic when the default policy is deny; an explicit deny blocks traffic that matches a rule. Verify the default in each direction.
Account for reply traffic. Stateful firewalls recognize replies to permitted connections without allowing unrelated inbound connections. Stateless filters evaluate each direction separately, including replies destined for the clientβs temporary port.
Troubleshoot before widening access. Test fresh connections that should pass and fail, then compare them with firewall logs. If the firewall allowed the traffic, check that the service is listening and replies have a working route back.
π Put firewall concepts into practice with Pluralsight through guided labs, feedback, and practice exams for certification prep.
A firewall rule is an if-then instruction: if traffic matches certain conditions, allow it, drop it, or reject it. To predict whether a connection will work, you need to know which rules apply, how the firewall resolves overlapping rules, and whether it tracks replies as part of an existing connection.
Firewall rules explained: What does a rule check?
A ruleset is a collection of rules that turns a network policy into specific permissions. For example, if employees need to reach the payroll portal, a rule can allow the employee subnet to connect to the payroll server on TCP destination port 443. That rule lets employees reach the login page; the application still decides who can sign in and what they can do.
FAQ
Quick answers to the questions people usually ask about this topic.
Does opening a port in a firewall make a service reachable?
Not by itself. A firewall allow rule lets matching traffic pass that firewall. The destination still needs a service listening on the expected port, a working route in both directions, and permission from any other firewalls along the path. The application can also require authentication after the connection succeeds.
Should a firewall rule match the source port or the destination port?
For a new client connection, match the serviceβs destination port, such as TCP 443 for HTTPS. The client usually chooses a temporary source port, so matching a fixed source port can block legitimate connections. In the reply, the ports swap roles: 443 is the source port, and the clientβs temporary port is the destination.
What happens to existing connections when you change a firewall rule?
It depends on the firewall. A stateful firewall may keep an established session active until it closes or its state entry expires, even if the new rule blocks fresh connections. Verify the change with a new connection rather than by refreshing a page in a browser that may reuse an existing connection.
Why is there no firewall log entry for a failed connection?
The traffic may not have reached that firewall, or logging may be disabled for the rule or default action that handled it. Check the expected interface or zone and confirm that the relevant action is logged. No log entry, by itself, doesnβt tell you whether the firewall allowed or blocked the connection.
Will an IPv4 firewall rule also apply to IPv6 traffic?
Donβt assume it will. A rule scoped to an IPv4 address or subnet wonβt match an IPv6 address. Some platforms let one rule cover both address families, while others require separate entries. If a service is reachable over both IPv4 and IPv6, test each against your intended policy.
How can I practice firewall troubleshooting before a Security+ exam?
Practice predicting which traffic should pass, testing both allowed and blocked connections, and checking firewall logs to explain the results. If you want structured practice and feedback, try Pluralsight for guided security labs, assessments, and practice exams that can help you decide what to study next.
Some links may earn a commission. Thanks for your support.
Watch in the video playerOpen the dedicated player for this video.
Rule element
What it tells the firewall
Example
Source and destination
Where the traffic comes from and where it is going
Employee subnet β payroll server
Protocol and port
Which protocol and, where applicable, which port to match
TCP destination port 443
Direction, interface, or zone
Where the rule applies
Employee zone β application zone
Action
What to do when the rule matches
Allow, drop, or reject
Logging
Whether to record the decision
Log a matching denial
A drop silently discards traffic. A reject discards it and sends a refusal when supported. Logging records the decision if enabled; it does not change whether traffic is allowed or blocked.
Direction depends on where youβre looking. A request can be outbound from a laptop but inbound on the gateway interface where it arrives.
Firewall rule order: Which rule wins when two rules match?
Many firewalls use first-match evaluation: they check the applicable rules in order and stop at the first match. Consider this policy for new connections entering a server zone:
Order
Source β destination
Traffic
Action
10
Admin subnet β management server
TCP destination port 22 (SSH)
Allow
20
Any source β management server
TCP destination port 22 (SSH)
Drop and log
Default
Traffic not matched above
Any
Drop
An administrator connecting over SSH matches rule 10 and is allowed. An employee outside the admin subnet skips rule 10 and is blocked by rule 20. An administrator connecting to the same server on TCP port 443 matches neither rule and is blocked by the default.
Move rule 20 above rule 10, and the broad block catches administrators too. The narrower allow is still in the ruleset, but traffic never reaches it. Thatβs rule shadowing.
Not every firewall uses top-to-bottom order. An explicit block takes precedence over a conflicting ordinary allow in Windows Firewall. AWS security groups use allow-only rules: if no applicable rule allows a new flow, it isnβt permitted. Check the platformβs evaluation model before assuming that moving a rule will fix it.
Implicit deny vs. an explicit deny rule
An implicit deny blocks traffic because no rule matched and the policy defaults to deny. An explicit deny is a rule that matches traffic and blocks it. On a first-match firewall, you might add an explicit catch-all deny at the end of a ruleset to log traffic that wasnβt allowed earlier.
Deny by default is a practice described in NISTβs firewall guidance, but it isnβt every productβs default in every direction. Windows Firewall, for example, allows outbound traffic by default unless a rule blocks it.
Stateful vs. stateless firewalls: How replies get through
A stateful firewall keeps track of flows it has permitted. Suppose your browser connects to a web server on TCP port 443 using temporary local port 51514:
Traffic
Source
Destination
Request
Laptop port 51514
Web server port 443
Reply
Web server port 443
Laptop port 51514
The firewall can recognize the reply as part of the connection your laptop started. Letting that reply through does not allow the web server to start an unrelated inbound connection. The temporary client-side port is called an ephemeral port.
A stateless filter checks each packet independently. If it filters both directions, its rules must permit the request and the reply separately. Notice that the replyβs destination port is 51514, not 443. Looking only for inbound traffic destined for port 443 would miss the reply.
Both models can apply to the same connection. In AWS, for example, security groups are stateful, while subnet network ACLs are stateless. An allow from a security group does not override a denial from a subnet ACL.
Common firewall rule examples
The goal is usually more specific than βopen a port.β Write the rule around who needs to initiate the connection, what they need to reach, and which service they need.
Public web access: Allow internet clients to reach a public web frontend on TCP port 443 without granting access to internal servers.
Internal segmentation: Let the application tier initiate database connections without giving employee laptops the same access.
Privileged administration: Allow remote desktop to managed servers only from a designated jump host.
Outbound filtering: Let workstations send ordinary DNS queries only to approved resolvers.
How to troubleshoot a firewall rule that should work
Identify the initiating source, destination, protocol, and destination port. Then identify which firewall, direction, and zone or interface should handle it.
Practice firewall troubleshooting with guided labs
Ready to apply these concepts before changing rules on a live network? Pluralsight offers guided security labs with feedback, plus assessments and practice exams to help you spot gaps and focus your certification prep.
π Try Pluralsight to work through guided security labs and get feedback on your skills.
Affiliate notice: Some links may earn a commission. Thanks for your support.
Layer 4 vs. Layer 7 Firewalls: Whatβs the Difference? (Explained Clearly) - Security+Next
Check the policy the traffic actually encounters. Look for a broader rule that takes precedence, a different network profile, or another firewall on the path. If network address translation (NAT) is involved, verify which address the platform uses to match the rule.
Test both what should pass and what should fail. Start a fresh connection from an approved source, then verify that a source you intend to block still cannot connect. An existing session may behave differently after a rule change, depending on how the firewall tracks it.
Compare the tests with the logs. Look for entries that match the test time, source, destination, protocol, and port. If the log identifies a deny rule, check why that rule matched. If it shows an allow, that tells you what happened at that firewall, not whether the application accepted the connection.
Check the service and the return path before widening access. A timeout can come from a silent drop, but it can also come from a routing problem. Verify that DNS resolves to the expected destination, the service is listening, and replies have a working route back. A reply that travels through a different stateful firewall may reach a device that never saw the original request.
Affiliate link β I may earn a commission at no additional cost to you.
Jay's Recommendation
Turn understanding into hands-on confidence
You've built the foundations. Pluralsight adds opportunities to practice in guided security labs, get feedback, and check your knowledge with assessments and practice exams, so your next step is more than another video.
π Put concepts to workBuild practical skills with guided security labs and feedback.
π―Find your weak spotsUse assessments to focus on what needs more work.
πCheck your understandingUse practice exams to guide your certification preparation.
π§Give study sessions directionOrganize further learning with curated paths and progress tracking.