---
title: "AP Networking 3.5: Controlling the Traffic: Firewalls and Filtering"
description: "Learn AP Networking 3.5, Controlling the Traffic: Firewalls and Filtering, with a study guide that covers every learning objective in the topic and the skills it builds."
canonical: "https://fiveable.me/ap-networking/unit-3/controlling-the-traffic-firewalls-and-filtering/study-guide/IKfJrLOczO6yxjT6WDgk"
type: "study-guide"
subject: "AP Networking"
unit: "Unit 3 – Managing Many Connections"
lastUpdated: "2026-11-09"
---

# AP Networking 3.5: Controlling the Traffic: Firewalls and Filtering

## Summary

Learn AP Networking 3.5, Controlling the Traffic: Firewalls and Filtering, with a study guide that covers every learning objective in the topic and the skills it builds.

## Guide

Networks aren't just about moving data from point A to point B. They're also about deciding *what* gets to move and *who* gets to connect in the first place. That's where traffic control comes in. Switches can be told which devices to trust, firewalls can split a network into zones with different rules, and access control lists give you line-by-line control over what gets through. These tools work together to keep attackers out and sensitive data in.

## MAC Filtering and Switch Port Security

Every network device has a **MAC address**, a unique identifier burned into its network interface. **MAC filtering** uses those addresses to decide who's allowed on the network. Only approved MAC addresses get through. Every other address is refused.

On a switch, you can go a step further and lock down individual ports. A specific physical port can be configured to accept just one MAC address, or a limited group of them. If someone unplugs an approved laptop and plugs in their own device, the switch sees a MAC address that isn't on the approved list and blocks it. That's a physical layer of defense: even if an attacker has cable access, they can't just plug in and join the network.

Capping both the *number* and the *range* of MAC addresses tied to a port is what makes this work. It stops unauthorized devices from physically connecting.

### MAC Flooding and the Fail-Open Problem

MAC filtering also helps stop a specific attack called **MAC flooding**. Here's what happens during a flood:

A switch keeps a table called the **[CAM table](/ap-networking/unit-2/identification-needed-documenting-my-network/study-guide/MVK7TBKyX8PT6V2lt11z#the-cam-table "fv-autolink")** (Content Addressable Memory table). It maps MAC addresses to switch ports so the switch knows where to send frames. In a MAC flooding attack, an attacker blasts the switch with a huge number of distinct, fake MAC addresses. The CAM table fills up and runs out of memory.

When the table is overwhelmed, many switches enter a **fail-open state**. Instead of sending frames to the specific port where the destination device lives, the switch starts broadcasting *all network traffic* out to *all nodes*, like a hub. That's a disaster for two reasons:

- The network gets congested because every device is receiving every frame.
- An attacker on the network can now intercept data meant for other devices, including things like passwords or private messages.

By limiting which MAC addresses a port will accept in the first place, MAC filtering prevents an attacker from injecting the flood of fake addresses needed to pull this off.

## Choosing the Right Firewall

A **firewall** divides a network into regions with different levels of access and blocks unauthorized movement between them. Picking the right firewall depends on a few questions:

- How much traffic inspection do you need? Simple filtering, or **deep packet inspection** that looks inside the actual data?
- What are you protecting? A whole organization, one zone, or a single device?
- How exposed is the network? Does it face the internet, hold sensitive data, or have untrusted users?

Firewalls come in different types based on how they filter and where they sit.

### Stateless vs. Stateful vs. Next-Generation

A **stateless firewall** screens traffic using fixed rules based on things like IP addresses, ports, or protocols. It doesn't track or record connections. Each packet is judged on its own. Because it's simple and fast, a stateless firewall fits network segments that are simple or low-risk.

A **stateful firewall** goes further. It monitors active connections and can follow and log suspicious traffic. If a packet tries to sneak in pretending to be part of an existing conversation, a stateful firewall notices. It's ideal for zones that need connection awareness and logging.

A **next-generation firewall (NGFW)** adds advanced capabilities like **intrusion prevention** and **application-based filtering**. Instead of just checking ports, it can tell the difference between, say, regular web browsing and someone trying to tunnel a sketchy app through port 443. NGFWs suit high-risk zones or any situation that calls for detailed traffic inspection.

### Where the Firewall Sits

Beyond how it filters, *where* a firewall lives on the network matters just as much.

A **perimeter firewall** guards the border between your internal network and the outside world. It's the first line of defense against outside threats. It handles high traffic volumes and enforces broad security policies on all incoming and outgoing flows. Think of it as the main gate of a building.

An **internal firewall** sits inside the network to separate sensitive devices or departments. Its job is to stop **[lateral movement](/ap-networking/unit-2/guarding-my-network-identifying-security-needs/study-guide/HLYf0fvNHsXJwDO2MhxJ#lateral-movement "fv-autolink")**, which is when an attacker who already got in tries to hop from one area to another. For example, you might put an internal firewall between the general office network and the HR servers so a random infected laptop can't reach payroll data.

Internal firewalls can also be used to create a **screened subnet**, also called a **demilitarized zone (DMZ)**. A screened subnet is a lower-security zone that hosts public-facing services like a company's website. It sits between internal resources and public networks. That way, if the public web server gets hacked, the attacker is stuck in the DMZ and can't easily reach the sensitive internal network.

A **host-based firewall** is software running on an individual device. It gives that one endpoint extra security and lets you customize settings just for that machine. These typically protect laptops that travel between networks (like going from the office Wi-Fi to a coffee shop) or devices that need their own tailored security rules.

Quick way to match a scenario to a firewall:

- Small, low-risk segment where you just want to block certain ports: **stateless**
- Zone that needs to track connections and log suspicious activity: **stateful**
- High-risk area needing deep inspection or app-level filtering: **NGFW**
- Edge of the network facing the internet: **perimeter**
- Between departments to stop lateral movement: **internal**
- A single laptop that moves around: **host-based**

## Configuring Firewall Rules with ACLs

Firewalls work off of rules that permit or deny traffic, both inbound and outbound. A full list of these rules is called an **access control list (ACL)**.

Here's the critical thing about ACLs: they're evaluated **sequentially from top to bottom**. For any given packet, only the *first rule whose criteria match* gets carried out. After a match, the firewall stops checking. That means rule order isn't just organization, it's logic.

### What's in an ACL Entry

A typical ACL entry includes:

- **Direction** on an interface: inbound or outbound
- **Filtering criterion**: an IP address, a logical port, a service, or an application
- **Action**: permit or deny

Different firewalls can filter on different criteria, but these three parts show up pretty much everywhere.

### Ports You'll See a Lot

Some services and their ports come up constantly in ACLs. The [secure](/ap-networking/networking-skills/secure/study-guide/tbJ0w0h0YOeV6KgATgfF "fv-autolink") ones you usually want to permit:

- **HTTPS** on port 443: encrypted web traffic
- **DNS** on port 53: resolves domain names into IP addresses
- **SSH** on port 22: encrypted remote command-line access
- **SFTP** on port 22: secure file transfer that runs over SSH

And the vulnerable, unencrypted ones you usually want to block whenever possible:

- **HTTP** on port 80: web traffic sent in plaintext
- **Telnet** on port 23: remote CLI access with no encryption
- **FTP** on port 21: file transfer with no encryption

Good ACL design means shutting unused or vulnerable ports while prioritizing the services you actually need. That shrinks the attack surface.

### A Sample Rule Set

Here's an ACL that keeps needed services open and closes vulnerable ones:

```
Rule 101: PERMIT inbound TCP port 443 from any source   (HTTPS)
Rule 102: PERMIT inbound TCP port 22  from any source   (SSH)
Rule 103: DENY   inbound TCP port 80  from any source   (HTTP)
Rule 104: DENY   inbound TCP port 23  from any source   (Telnet)
Rule 105: PERMIT inbound UDP port 53  from any source   (DNS)
```

Secure web, secure remote access, and DNS get through. Unencrypted web and Telnet are shut down.

### Why Rule Order Matters

Because rules run in sequence, swapping two rules can completely change what traffic is allowed. Look at this short ACL:

```
Rule 101: PERMIT inbound TCP port 22 from any source
Rule 102: DENY   inbound TCP from any source
```

As written, SSH is allowed because rule 101 matches first for port 22 traffic. Everything else gets caught by rule 102 and blocked. That's probably what you want.

Now flip them:

```
Rule 101: DENY   inbound TCP from any source
Rule 102: PERMIT inbound TCP port 22 from any source
```

Every inbound TCP packet, including SSH, hits rule 101 first and gets denied. Rule 102 is never reached. SSH is completely blocked, which almost certainly wasn't the goal.

The takeaway: **more specific rules go above broad, general ones.** If you let a catch-all deny sit at the top, nothing below it will ever matter.

### Testing Your Rules

After setting up an ACL, you need to confirm two things: intended access still works, and unauthorized access is blocked. A common quick test is using `ping` to try to reach other network segments and checking that access to the resources you need is still there. If a permitted user can't get to their files, a rule is probably ordered wrong or too restrictive. If an unauthorized device *can* get in, something is missing or too permissive.

Firewall configuration is an iterative process. Build the rules, test them, watch the logs, and adjust. The goal is a rule set that's tight enough to block threats but loose enough that the people and services you actually need can still do their jobs.

## Vocabulary

- **CAM table**: A switch's memory table that maps MAC addresses to physical switch ports so frames can be forwarded to the correct destination.
- **DNS**: Domain Name System, which converts human-readable domain names (such as google.com) into IP addresses.
- **FTP**: File Transfer Protocol, a vulnerable protocol on port 21 that transfers files without encryption.
- **HTTP**: Hypertext Transfer Protocol, a vulnerable protocol on port 80 that sends web communication without encryption.
- **HTTPS**: Hypertext Transfer Protocol Secure, the encrypted version of HTTP used to load webpages.
- **MAC address**: A unique hardware identifier assigned to a network interface, used to identify devices on a local network.
- **MAC address filtering**: A control that permits only approved devices, identified by their MAC addresses, to connect to the network.
- **MAC flooding**: An attack in which a switch receives a large number of distinct MAC addresses, overflowing its CAM table until its memory is exhausted.
- **SFTP**: Secure File Transfer Protocol, a protocol on port 22 that transfers files securely over SSH.
- **SSH**: Secure Shell, a protocol on port 22 that provides protected command-line (CLI) access to a remote device.
- **Telnet**: A vulnerable protocol on port 23 that provides unencrypted remote command-line (CLI) access.
- **access control list (ACL)**: A list of firewall rules that determines which network traffic is permitted or denied, evaluated in order.
- **broadcast**: A transmission sent from one device to all nodes on a network segment.
- **deny action**: The firewall action that blocks matching network traffic from passing through.
- **fail-open state**: A condition in which a switch, after its CAM table overflows, broadcasts all traffic to every node on the network.
- **filtering criterion**: The attribute a firewall rule checks when filtering traffic, such as IP address, logical port, service, or application.
- **firewall**: A security device or software that restricts which network traffic is permitted to enter or leave a network, based on rules that check details such as IP addresses, ports, and protocols.
- **firewall rule**: A single entry in a firewall's rule set that specifies a traffic direction, filtering criterion, and action (permit or deny).
- **inbound traffic**: Network traffic arriving on an interface from outside the network.
- **outbound traffic**: Network traffic that leaves a local network and travels toward external networks.
- **permit action**: The firewall action that allows matching network traffic to pass through.
- **ping**: A network utility that sends test packets to a host and reports response times and packet loss to measure connectivity and performance.
- **port**: A numbered logical endpoint used by network services and protocols to direct traffic to the correct application on a device.
- **rule sequencing**: The principle that firewall rules are evaluated in order from top to bottom, and only the first matching rule is applied to given traffic.
- **rule specificity**: The principle that more specific rules should be placed before broad, general rules in an ACL.
- **switch port**: A physical connection point on a network switch to which a device is plugged; it can be configured to accept only specific MAC addresses.
- **traffic interception**: The capture of data as it travels across a network, allowing an attacker to read or copy it.
- **unused port**: A port that no needed service uses and that should be closed or shut down to reduce the chance of malicious traffic.

## About This Document

Canonical Fiveable pages are available as Markdown at the same path plus `.md`.

- [llms.txt](https://fiveable.me/llms.txt): index of Fiveable's sections and URL patterns
- [llms-full.txt](https://fiveable.me/llms-full.txt): complete subject and unit listing
- [MCP server](https://fiveable.me/mcp): call Fiveable as tools instead of fetching pages (`https://fiveable.me/api/mcp`)
- [MCP server for AP teachers](https://fiveable.me/mcp/teachers): a teacher's classes, assignments and AP-rubric grading (`https://fiveable.me/api/mcp/teacher`)
