Study Guide

Firewalls, Traffic Filtering and Segmentation

What a firewall checks, how rules are evaluated, why stateful filtering and default deny matter, and how segmentation uses firewalls to control traffic between zones.

Lesson 4.2 Network & Infrastructure Security

Routers and switches are built to deliver traffic, not to judge it. Left alone, a network will carry a request from a visitor’s phone to a staff records server just as happily as a teacher’s request. Firewalls add the missing judgement: they decide which traffic is allowed to pass. This lesson explains how they make that decision and how dividing a network into zones gives them a place to do it.

Stage: Think

The reception desk

A school reception desk decides who may go where. Its instructions are a short list, read from the top:

  1. Staff may go to any room.
  2. Parents may go to the hall.

Think it through

A delivery driver arrives and asks to go to the staff room. They are not on either line of the list. What should reception do, and why?
Show the answer

Answer: A. Turn them away: nobody has said that drivers may go anywhere.

A safe list says who is allowed, and refuses everyone else. Nobody could list every person who must be kept out.

Think it through

Someone adds a new first line: “Visitors may go to any room.” Line 2 still says parents may go only to the hall. A parent signs in as a visitor. Where can they go now?
Show the answer

Answer: B. Any room, because the first line that fits them says so.

When a list is read from the top and the first line that fits decides, a broad line placed too high makes the lines below it pointless.

A network firewall works in exactly this way: a short list of what is allowed, read from the top, with everyone else refused. The rest of the lesson shows how.

Stage: Explain

Why firewalls keep coming up

Firewalls come up in security from several angles:

  • Device security: enabling and correctly configuring firewalls is among the basic practices that improve device security.
  • Baseline schemes: firewalls are one of the five technical control areas of Cyber Essentials, the UK baseline scheme.
  • Networking: NAT is not a firewall and is not a substitute for one.

Those points establish that firewalls matter. The rest of this lesson explains how they actually decide what to allow.

Stage: Explain

Where firewalls sit

A firewall is a control that decides which network traffic may pass. It can only judge traffic that passes through it. There are two common placements:

TypeWhere it runsWhat it protects
Host firewallSoftware on one device, such as the firewall built into Windows or Linux.That device, including from other devices on its own network. This is the firewall that everyday device-security advice refers to.
Network firewallA dedicated device, or a feature of a router, placed where traffic passes between networks.Every network behind it, but only for traffic that actually crosses it.

Check your understanding

Two laptops are on the same guest Wi-Fi network, and one of them is infected. Can the network firewall where the school meets the internet stop the infected laptop connecting to the other?
Show the answer

Answer: A. No: that traffic never crosses it; a host firewall can stop it.

Traffic between two devices on the same network does not cross the edge firewall, so only the laptops’ own host firewalls can filter it.

The two work together. A network firewall cannot see traffic between two laptops on the same network; each laptop’s host firewall can.

Stage: Explain

What a firewall checks

A traditional firewall reads the headers that the network models lesson described, not the application data inside. For each packet it can check:

A firewall rule combines some of these conditions with an action, allow or deny. “Allow staff devices to reach the records server on TCP 443” is a rule. Firewall rules express the same idea as least privilege: permit only the traffic a legitimate task needs.

Stage: Predict

First match wins, then default deny

Most firewalls check rules from the top of the list down. The first rule whose conditions all match decides what happens, and the firewall stops checking. If no rule matches, a final default rule applies. In a well-designed policy that default is deny, so only traffic someone deliberately allowed can pass. This is called default deny: the reception desk turning away anyone not on the list.

Think it through

The school’s firewall has three rules: staff may reach the records server on TCP 443, staff may reach the internet on TCP 443, and guests may reach the internet on TCP 443. No rule mentions guests and the records server. What happens when a visitor’s phone tries to open the records system?
Show the answer

Answer: B. It is denied by the default rule.

It is denied by the default rule, because no rule allows it. The walkthrough checks it rule by rule.

A visitor’s phone on the guest network tries to open the records system: Guest → Records server · TCP 443. The firewall compares it with each rule in turn, checking From, To and Service.

  1. Rule 1: Allow Staff → Records server · TCP 443. From is Staff; the phone is Guest. No match, so the firewall moves on.
  2. Rule 2: Allow Staff → Internet · TCP 443. From is Staff again. No match.
  3. Rule 3: Allow Guest → Internet · TCP 443. From matches, but To is Internet and the phone wants the records server. No match: every condition has to fit.
  4. No rules left. The default rule applies.
  5. Result: denied by the default rule, after checking rules 1 to 3.

Change one fact. The same phone now opens a website: Guest → Internet · TCP 443. Rules 1 and 2 still fail on From, but rule 3 fits in every condition, so the connection is allowed by rule 3 and the firewall stops checking. One field, the destination, decided the outcome.

Stage: Experiment

Try it: the school firewall

Here are the same three rules, with five connections checked against them. Find the visitor’s connection to the records system, then test some connections of your own.

A fictional school firewall checking five connections

Staff, guest and server networks are separated. Each connection is compared with the rules from the top; the first match decides, and anything left over is denied.

RuleActionFromToService
1AllowStaffRecords serverTCP 443
2AllowStaffInternetTCP 443
3AllowGuestInternetTCP 443
DefaultDenyAnything that matched no rule above
  1. A teacher opens the records system

    Staff → Records server · TCP 443

    Allowed by rule 1, after checking rule 1.

  2. A teacher visits a website

    Staff → Internet · TCP 443

    Allowed by rule 2, after checking rules 1 and 2.

  3. A visitor’s phone tries the records system

    Guest → Records server · TCP 443

    Denied by the default rule: none of rules 1 to 3 matched.

  4. A visitor’s phone visits a website

    Guest → Internet · TCP 443

    Allowed by rule 3, after checking rules 1 to 3.

  5. A teacher tries Remote Desktop to the records server

    Staff → Records server · TCP 3389

    Denied by the default rule: none of rules 1 to 3 matched.

A real policy would also need rules for services such as DNS. This one is cut down to show the method; the panel models only first match and default deny.

Notice that nothing had to say “deny guests access to the records server”. The default rule did that, because no rule allowed it. The same default blocked Remote Desktop, even for staff, because that service was never needed.

Stage: Experiment

Why rule order matters

Think it through

Someone adds a broad guest rule for an event and puts it at the top. Rule 2, below it, denies guests the records server. Is the records server protected from guests?
Show the answer

Answer: B. No: rule 1 matches guests first, so rule 2 is never reached.

Rule 1 matches every guest connection, so rule 2 never applies. In the panel, move rule 2 above rule 1 and watch the visitor’s connection change.

A broad rule placed first: the deny below it never takes effect

The same school, after someone added a broad guest rule for an event and placed it at the top.

RuleActionFromToService
1AllowGuestAnyAny
2DenyGuestRecords serverAny
3AllowStaffRecords serverTCP 443
DefaultDenyAnything that matched no rule above
  1. A visitor’s phone tries the records system

    Guest → Records server · TCP 443

    Allowed by rule 1, after checking rule 1.

Rule 2 looks as if it protects the records server, but rule 1 matches first. Reading a rule on its own is not enough; its position decides whether it ever applies.

Because checking stops at the first match, a broad rule placed too high can hide a more specific rule below it. The lower rule is then never reached.

Stage: Discover

Stateful filtering: remembering conversations

A connection involves traffic in both directions. When a teacher’s PC requests a web page, the web server’s replies must be allowed back in, yet nobody wants a rule allowing any internet traffic in to staff PCs.

Think it through

The school's rules allow staff to visit websites, and no rule allows anything in from the internet. A teacher opens a web page. How can the website’s reply get back in?
Show the answer

Answer: A. The firewall remembers the request and lets its reply in.

A firewall that remembers the conversations it has allowed out can let their replies in, and nothing else.

A stateless filter judges every packet on its own, so it needs rules for both directions. A stateful firewall remembers the connections it has allowed out, and lets matching replies back in automatically.

A stateful firewall allows replies, not strangers

A fictional teacher's PC at 10.10.0.25 visits a web server at 203.0.113.80, through a stateful firewall using the school’s rules. NAT, if used, is left out to keep the example simple.

  1. Step 1: Teacher’s PC 10.10.0.25 to Web server 203.0.113.80. Opens a TCP connection to port 443Rule 2 allows it. The firewall records the connection: 10.10.0.25:51000 ↔ 203.0.113.80:443.
  2. Step 2: Web server 203.0.113.80 to Teacher’s PC 10.10.0.25. Replies to 10.10.0.25:51000No rule allows traffic in from the internet, but this reply matches the recorded connection, so it is allowed.
  3. Step 3: Teacher’s PC 10.10.0.25 to Web server 203.0.113.80. Sends the HTTPS requestStill part of the same recorded connection.
  4. Step 4: Web server 203.0.113.80 to Teacher’s PC 10.10.0.25. Sends a new, unrequested connection attemptIt matches no recorded connection and no rule, so the default rule denies it.

The record is removed when the connection closes or has been idle for a while, so the way back in does not stay open.

Stage: Explain

Firewalls and NAT are different jobs

A home router often performs NAT and firewall filtering in the same box, which makes them easy to confuse. They are different controls:

NAT can make it harder for unrequested inbound traffic to reach an internal device, because there may be no mapping for it. That is a side effect, not a policy. NAT commonly translates outbound traffic too, but translating addresses does not decide which outbound connections are permitted; that needs a policy. NAT behaviour can also be changed by port-forwarding settings, and does not apply where no translation happens, as is usual with IPv6.

Check your understanding

A small office’s router performs NAT. The manager says: “We don’t need a firewall policy; NAT already blocks everything coming in.” What is the best response?
Show the answer

Answer: B. Disagree: NAT changes addresses; a policy decides what is allowed.

NAT translates addresses. Any blocking it causes is a side effect, which a port-forwarding setting can undo, and it does nothing about outbound traffic. A firewall policy is what decides.

Stage: Discover

Segmentation: giving the firewall a boundary to guard

A flat network, where every device can reach every other, gives a firewall nothing to guard inside it. Segmentation divides the network into zones and routes traffic between them through a point where a policy is enforced.

Switch Ports, VLANs and 802.1Q Trunks showed the first half of this: VLANs separate groups of devices, and moving between VLANs needs a router or a Layer 3 switch (a switch that can also route). Segmentation adds the second half: at that routing point, a firewall decides which crossings are allowed. As that lesson put it, VLANs separate; routing reconnects. The firewall decides what is allowed to reconnect.

A fictional school divided into zones

In this example each zone is one VLAN and one IP subnet, and the network firewall sits between them. Traffic between zones passes that firewall; traffic between two devices in the same zone normally does not.

Enforcement pointRouter with firewall policy, applying the school’s rules from this lesson

  • Staff zone

    VLAN 10 · 10.10.0.0/24

    Teachers’ PCs and laptops.

    Policy allows it to reachThe records server on TCP 443, and websites on the internet.

  • Guest zone

    VLAN 20 · 10.20.0.0/24

    Visitors’ phones and laptops.

    Policy allows it to reachWebsites on the internet only.

  • Server zone

    VLAN 30 · 10.30.0.0/24

    The records server.

    Policy allows it to reachNothing: no rule allows connections out of this zone. Staff may connect in, on TCP 443 only.

  • Internet

    Outside the school

    Everything beyond the school’s connection.

    Policy allows it to reachNothing inside, except replies to connections that were started from inside.

Two teachers’ laptops in the staff zone are in the same VLAN and subnet, so they normally communicate through the local switches without crossing this network firewall. Here, their host firewalls are what can filter that traffic. Other designs differ: a zone can span several subnets with filtering between them, or be divided further.

What segmentation achieves

  • It limits the spread of an attack. The Attack Chain showed an attacker exploring the network after gaining a foothold. If a guest device is compromised, segmentation stops it reaching the records server at all.
  • It protects the most sensitive systems. The server zone accepts only the few connections it needs.
  • It shrinks local attack surfaces. Broadcasts, and the flooding described in MAC Flooding and Port Security, stay inside one VLAN.

Segmentation is enforcement, not labelling. Putting systems in separate VLANs achieves little if the router between them allows every crossing.

Check your understanding

A school puts staff, guests and servers in three separate VLANs. The router between them has one rule: allow everything. Is the network segmented?
Show the answer

Answer: C. No: the router reconnects every zone, so nothing is enforced.

VLANs separate; routing reconnects; the policy decides what may reconnect. With “allow everything”, nothing is enforced, so there is no segmentation in the sense that matters.

Stage: Explain

What a firewall cannot do

  • Allowed traffic can still be harmful. A phishing link opened over HTTPS uses the same allowed port as legitimate browsing. The firewall saw permitted traffic, which is why it is one layer in Defence in Depth, not the whole defence.
  • It cannot see inside encryption. A traditional firewall reads addresses and ports. The content of an HTTPS connection is hidden from it.
  • It only sees traffic that passes through it. In a design like the school’s, where a zone is a single VLAN and subnet, traffic between devices in that zone is switched locally and does not cross the network firewall. Traffic on any route that bypasses the firewall is not checked either. Where filtering is needed inside a zone, it has to come from somewhere else, such as host firewalls or a design that places another enforcement point there.
  • It is only as good as the configuration actually running. A router’s console may, for example, show firewall configure failed! messages at start-up; until their cause is established, no conclusion can be drawn about what that router is filtering. The configuration a device is actually running, not the one someone intended, decides what it does, and it is worth checking.

Other controls look further into traffic than addresses and ports. A web application firewall filters requests to one web application; the DDoS lesson discusses where it helps and where it does not. Intrusion detection and prevention systems examine traffic for signs of attack, and either raise an alert or block it. They are named here so the gaps in a simple firewall are clear.

Firewall policies tend to grow and decay: a temporary rule for an event stays for years, and nobody remembers why a broad rule exists. Good practice is to give each rule a recorded purpose and owner, log what the default rule denies, and review the rule list regularly, removing anything no longer needed and checking the order.

Stage: Apply

Apply it in a new situation

These questions use the lesson in situations it has not shown. For the strongest test of your understanding, come back to them on another day and answer each one at the first attempt.

Apply it

A library’s firewall has two rules, in this order: 1. Allow Public Wi-Fi → Internet, any service. 2. Allow Staff → Catalogue server, TCP 443. Then default deny. A member of the public tries to reach the catalogue server on TCP 443. What happens?
Show the answer

Answer: A. Denied by the default rule, because neither rule matches it.

Neither rule matches: rule 1 goes only to the internet, and rule 2 is only for staff. The default rule denies it.

Apply it

A firewall allows staff to visit websites on TCP 443 and blocks everything else. A member of staff clicks a phishing link to a fake sign-in page over HTTPS. What does the firewall do?
Show the answer

Answer: B. Allows it: it is ordinary HTTPS traffic to a website.

The connection is allowed traffic: a website on TCP 443. A firewall is one layer; training, filtering and multi-factor authentication have to deal with the phishing itself.

Stage: Check

Check your understanding

These questions come from the approved revision bank. Choose an answer and check it; the explanation and its sources follow.

  1. NAT by itself is a firewall and removes the need for a firewall policy.

    Show answer

    Answer: False

    False. NAT changes addressing; firewall policy controls permitted traffic. Translation is not a substitute for a firewall, even though both functions often exist on the same home router.

    Revision sources: Session 5: Networking Fundamentals — Part 1 (Classroom session record)

  2. A fictional clinic’s firewall checks these rules from the top: 1. Allow Any → Patient records, TCP 443. 2. Deny Guest Wi-Fi → Patient records, any service. 3. Allow Staff → Internet, TCP 443. Anything else is denied by default. A visitor’s phone on Guest Wi-Fi tries to reach the patient-records system on TCP 443. What happens?

    Show answer

    Answer: It is allowed by rule 1, because the first matching rule decides and rule 2 is never reached.

    Rules are checked from the top and the first rule whose conditions all match decides. Rule 1 allows traffic from any source to the patient-records system on TCP 443, which includes the guest phone, so checking stops there and rule 2 never applies to this traffic. Deny rules have no automatic priority; their position decides whether they are reached. Moving rule 2 above rule 1, or narrowing rule 1 to staff, would fix the policy. Rule 3 concerns internet traffic, not the records system.

    Revision sources: Firewalls, Traffic Filtering and Segmentation (Supplementary Study Guide explanation)

  3. A fictional office firewall has only these rules, checked from the top: 1. Allow Staff → File server, TCP 445. 2. Allow Staff → Internet, TCP 443. Anything else is denied by default. Which connections are allowed? Select all that apply.

    Show answer

    Answer: A staff laptop opening a website on the internet over TCP 443.; A staff laptop connecting to the file server over TCP 445.

    Only traffic matching an allow rule passes and everything else meets the default deny. A matches rule 2 and D matches rule 1. B asks for a service no rule allows, C comes from a guest device that no rule mentions and E uses TCP 80, which rule 2 does not include. Nothing had to say “deny guests”: the default rule did that.

    Revision sources: Firewalls, Traffic Filtering and Segmentation (Supplementary Study Guide explanation)

  4. A stateful firewall lets staff PCs open HTTPS connections to the internet and allows no inbound connections from the internet. A staff PC opens a connection to a web server. The server sends a reply on that connection, and later tries to open a brand-new connection to the PC. What does the firewall do?

    Show answer

    Answer: Allows the reply, which matches the recorded connection, and denies the new attempt.

    A stateful firewall records the connections it has allowed and lets their replies back in without a separate rule. The reply belongs to the connection the PC opened, so it is allowed. The new attempt is not part of any recorded connection and no rule allows inbound traffic, so the default denies it. A stateless filter, which judges each packet on its own, would need an inbound rule for the replies.

    Revision sources: Firewalls, Traffic Filtering and Segmentation (Supplementary Study Guide explanation)

  5. A fictional school puts each zone in its own VLAN and subnet, with the network firewall routing between zones. Two staff laptops are in the staff zone’s VLAN, and one tries to connect to the other. Which control can filter that traffic in this design?

    Show answer

    Answer: Host firewalls on the laptops, since traffic inside one VLAN and subnet stays off the network firewall.

    Segmentation controls which traffic crosses between zones, and where each zone is one VLAN and subnet, traffic inside a zone is switched locally without crossing the network firewall. Filtering there has to come from somewhere else, such as host firewalls. The laptops share a VLAN, so VLAN membership does not separate them. Enabling and correctly configuring firewalls is a basic device-security practice, which is what a host firewall provides.

    Revision sources: Session 2: Cyber Fundamentals Part 2 (Classroom session record) · Firewalls, Traffic Filtering and Segmentation (Supplementary Study Guide explanation)

Study and revision

Practise through the Security Architecture topic and the Networking & Protocols topic. Questions cover first-match rule order, default deny, stateful replies and traffic inside a segmented zone, and a flashcard compares stateful and stateless filtering. They use this lesson’s supplementary explanation, which their explanations name, and fictional networks. They are learning-only.

Stage: Consolidate

What to remember

  • A firewall decides which traffic may pass, but only traffic that passes through it.
  • Rules are read from the top; the first match decides; anything left over meets the default rule, which should be deny.
  • Order matters: a broad rule placed high can hide every rule below it.
  • A stateful firewall lets replies in without letting strangers in. NAT is not a firewall.
  • Segmentation is zones plus a policy where they meet; VLANs alone are not enough.
  • Allowed traffic can still be harmful. A firewall is one layer of defence.

Common misunderstandings

NAT changes addresses. Only a firewall policy decides which traffic is allowed.

It stops traffic its rules do not allow. An attack that uses allowed traffic, such as a phishing link over HTTPS, passes straight through.

Checking stops at the first matching rule. A rule below a broader one may never be reached.

VLANs separate traffic, but a router can reconnect them. Segmentation needs a policy that restricts which traffic may cross.

Lesson sources and acknowledgements

Sources and scope

  • Taught in Session 2 (see the Session 2 Learning Log): enabling and correctly configuring firewalls as a basic device-security practice.
  • Taught in Sessions 3 and 4 (see Session 3 and Session 4): firewalls as one of the five technical control areas of Cyber Essentials.
  • Taught in Session 5 (see the Session 5 Learning Log): NAT is not a firewall and is not a substitute for one.
  • From the Study Buddy session on 23 September (see the entry): the firewall configure failed! messages observed on the lab VyOS router, whose cause was not established. The session was supplementary to the course, not a numbered classroom session.
  • Supplementary explanation: everything about how firewalls work, including host and network firewalls, the fields a firewall checks, rule evaluation, default deny, rule order, stateful filtering, segmentation and zones, the limitations, the note on other controls, the practical note and the misunderstandings. These go beyond what was taught and are included to explain the classroom points.
  • Guided version (published 1 November 2026, awaiting the site owner’s editorial review): the reception-desk opening and its two questions, every question asked in the lesson with its feedback and hints, the library and phishing examples, the interactive rule panels and the closing summary are supplementary explanation written for the Study Guide. The settings are fictional. The questions in the lesson’s steps are not revision-bank items; those in “Check your understanding” are, unchanged.
  • No practical work is claimed. The school, its networks and its rules are fictional. I have not configured a firewall or segmented a network.