What is a firewall? Learn how rules allow or block traffic, how stateful and stateless firewalls handle replies, and how to troubleshoot connection issues.
👉 Master your Security+ skills with Pluralsight here: Pluralsight
You’ll learn what a firewall is, how it uses rules to allow or block network traffic, and how stateful and stateless firewalls differ. This beginner-friendly Security+ guide helps you predict which connections will get through and troubleshoot when an app won’t connect.
Chapters: 0:00 Intro 0:11 What is a firewall, and what does it protect? 0:47 How do rule-based firewalls decide what to allow? 1:45 Why do replies get through if inbound connections are blocked? 2:33 What can’t a firewall tell you? 3:33 Outro
Affiliate notice: Some links may earn a commission. Thanks for your support.
Key Takeaways
A firewall allows or blocks network traffic according to a policy. Allowing a connection doesn’t guarantee the traffic is safe.
Rules can match IP addresses, ports, protocols, zones, and direction. Default deny blocks unmatched traffic. On a first-match firewall, a broad rule can override a specific exception by matching first.
Stateful firewalls recognize replies to permitted connections. Stateless firewalls evaluate each packet independently, so rules must permit traffic in both directions.
Layer 4 firewalls filter by transport protocol and port; Layer 7 firewalls inspect application requests. A web application firewall needs access to decrypted HTTPS requests to inspect their contents.
A timeout alone doesn’t prove a firewall blocked the connection. Check the destination, confirm the service is listening, and review the traffic path and firewall logs before making the narrowest rule change needed.
👉 Try Pluralsight to apply what you’ve learned in guided labs, get feedback, and check your Security+ readiness with practice exams.
A firewall is a security control that allows or blocks network traffic according to a policy. It can run on your laptop, sit between a private network and the internet, or protect systems in the cloud. Its job is to decide which traffic can cross a boundary, not to guarantee that everything it allows is safe.
Think of guest Wi-Fi: visitors need internet access, but they don’t need access to the office file server. A firewall can allow the first connection and block the second, even though both start on the same guest network.
How does a rule-based firewall work?
A firewall reads information from packets, the small units of data sent across a network. A rule can match the source and destination IP addresses, source and destination ports, and transport protocol, such as TCP or UDP. IP addresses identify network endpoints, while ports help identify a service or a connection endpoint. Rules can also account for which network zone the traffic came from, which direction it’s moving, or whether it belongs to a connection the firewall already knows about.
FAQ
Quick answers to the questions people usually ask about this topic.
What is the difference between a firewall and antivirus software?
A firewall decides which network traffic can pass. Antivirus software looks for malicious files or behavior on a device. A firewall might allow a download over HTTPS; antivirus software can then inspect the downloaded file. Neither replaces the other.
Do I need a firewall on my computer if my router already has one?
Yes, it’s generally worth keeping your computer’s firewall enabled. A router firewall filters traffic at the network boundary, but it may not see traffic exchanged directly between devices on the same local network. A host firewall protects your computer on that network and when you connect to Wi-Fi elsewhere.
What is the difference between inbound and outbound firewall rules?
Inbound rules apply to traffic entering the device or network zone you’re protecting. Outbound rules apply to traffic leaving it. Direction depends on where the rule is enforced: a laptop’s request to a website is outbound from the laptop but inbound to the web server.
Does opening a firewall port make an app accessible from the internet?
Not necessarily. The rule must allow traffic from the intended source, the app must be listening on the matching port and protocol, and the traffic must have a path to reach it. If the app sits behind a router using IPv4 NAT, inbound access may also require port forwarding. Limit access to the sources that actually need it.
Should I turn off my firewall if an app won’t connect?
Avoid turning off the entire firewall. Check whether the app is listening on the expected port and whether the firewall logs show a matching block. If you confirm that a rule is missing, add a narrow exception for the required source, destination, protocol, and port, then retest.
Where can I get hands-on firewall practice for CompTIA Security+?
After learning how to predict which traffic a rule will allow or block, explore Pluralsight for guided security labs and feedback without changing a live network. Use the assessments and practice exams to identify what to review next.
Some links may earn a commission. Thanks for your support.
Watch in the video playerOpen the dedicated player for this course.
The firewall applies its rules and takes an action. An allow lets the traffic continue. A drop silently discards it. A reject, where supported, blocks it and sends a response. A firewall can also log what it saw and what action it took. If no rule matches, the configured default applies. With default deny, also called implicit deny, unmatched traffic is blocked.
Firewall rule example: Allow the website, not the database
Suppose a company wants anyone on the internet to reach its public website, but only its application servers to reach the database. A simple ruleset for new connections might look like this:
Order
Source
Destination
Protocol and destination port
Action
10
Internet
Public web server
TCP 443 (HTTPS)
Allow
20
Application servers
Private PostgreSQL database
TCP 5432
Allow
Default
Any
Any
Anything unmatched
Drop
A visitor connecting to the public web server on TCP port 443 matches rule 10. A connection from an application server to the database on TCP port 5432 matches rule 20. An internet client trying to reach the database does not match rule 20: the destination and port may match, but the source does not.
Rule order matters on a first-match firewall. If you put a broad rule blocking all internet traffic to the web server before rule 10, the firewall will block the connection before it reaches the HTTPS exception. This is called rule shadowing. Not every firewall uses first-match order, though. Some give an explicit block priority over a conflicting allow, so check how your product evaluates rules before rearranging them.
Stateful vs. stateless firewalls: Why replies get through
If your laptop starts a connection to a website, the website has to send data back. That reply is inbound traffic, but it isn’t a new inbound connection. A stateful firewall keeps track of the connection in a state table, so it can recognize and allow valid replies without giving the website permission to initiate an unrelated connection to your laptop.
A stateless firewall evaluates each packet independently. It doesn’t remember that your laptop started the connection. If the request and reply cross the same stateless firewall, the rules must permit traffic in both directions.
Firewall type
What it checks
How replies get through
Stateful
Packet details and tracked connection state
The firewall recognizes the reply as part of a permitted flow.
Stateless
Packet details without connection history
The reply must match a rule that permits traffic in the reverse direction.
Layer 4 vs. Layer 7: What can a firewall inspect?
A basic Layer 4 firewall can check whether traffic uses TCP or UDP and which ports it uses, typically alongside IP address checks at Layer 3. It can allow TCP port 443, but that rule can’t tell a normal login request from a harmful one. They can both use the same port.
A Layer 7 firewall can inspect details at the application layer. A web application firewall (WAF), for example, can distinguish a request to /login from one to /images and apply different rules. To inspect those details in HTTPS traffic, it needs access to the decrypted request. Even then, a WAF does not fix vulnerable application code or replace authentication and authorization.
These terms describe different features, not mutually exclusive categories. A firewall can use rules, track connection state, and inspect application traffic. A host firewall protects an individual device, a network firewall filters traffic at a shared boundary, and cloud firewall controls can protect workloads or subnets. One connection can pass through several of these controls on its way to an application.
How to troubleshoot a possible firewall block
A timeout doesn’t prove a firewall blocked the connection. A silent drop can cause a timeout, but so can a routing problem. Before opening a port, check the connection from end to end:
Confirm the destination. Does the application’s hostname resolve to the expected IP address? Is it using the correct protocol and destination port?
Verify that the service is listening. An allow rule won’t help if no application is accepting connections on the expected port.
Identify the network, cloud, and host firewalls the traffic crosses. An allow at one boundary doesn’t override a block farther along. If the request and reply take different paths, a stateful firewall may not see enough of the exchange to track it correctly.
Practice firewall decisions for CompTIA Security+ SY0-801
For Security+ practice, take an example connection and predict what happens before checking the answer: Where does it start? Which rule matches? Is the packet part of an existing connection or a new attempt? That exercise makes the difference between memorizing firewall terms and being able to use them when a connection fails.
If you’re ready to put those concepts to work, guided labs let you practice without changing a live network. Feedback, assessments, and practice exams can help you spot gaps and choose what to study next.
👉 Try Pluralsight to practice in guided security labs and check your Security+ readiness with practice exams.
Affiliate notice: Some links may earn a commission. Thanks for your support.
How Do Firewall Rules Work? (Explained Clearly) - Rule Order, Implicit Deny & Stateful FilteringNext
Check the relevant firewall logs. Look for the expected source, destination, protocol, and port around the time of the failure. Logs show what that firewall observed and recorded, not what happened everywhere on the path.
Make the narrowest change that solves the problem. If a rule is missing, specify which source needs to reach which destination and on which port. Then verify that the intended connection works and that traffic you meant to block is still blocked.
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.