---
title: "Host-Based Firewall | FiveStudy"
description: "How a host-based firewall protects a single device on any network, uses ordered ACL rules, blocks unneeded ports, and stops outbound exfiltration such as FTP uploads."
url: https://fivestudy.com/guides/ap-cybersecurity-4-3-d-host-based-firewall
---

[AP Cybersecurity](https://fivestudy.com/ap-cybersecurity) · Study guide

# Host-Based Firewall

[Figure: FiveStudy]

FiveStudy

AP® Cybersecurity · Unit 4 · Device Security, Malware & Authentication

AP® Cybersecurity · Unit 4 · Device Security, Malware & Authentication

# Host-Based Firewall

How a firewall running on a single device controls traffic in and out of that device, and how to configure its rules.

1. What a host-based firewall is 2. Why add one 3. How its rules work 4. Blocking outbound traffic 5. Testing a rule set 6. Worked examples 7. Common mistakes

## 1 What a host-based firewall is

A **host-based firewall** is software that runs on a single device (a laptop, desktop, or server) and allows or denies traffic into or out of that one device. A **host** is any single computer on a network. Most operating systems include one.

## 2 Why add one

A network firewall protects a whole network at its edge. A host-based firewall adds an extra layer for each device, which matters when:

- the device is on a **compromised network**, where another device on the same network has been infected;
- the device leaves the building and joins an untrusted network such as café or hotel Wi-Fi;
- an attacker is already inside the network, past the edge firewall.

**Figure 1.** A host-based firewall travels with the device. It protects the host even on an untrusted network or a network with a compromised device.

## 3 How its rules work

A host-based firewall follows a set of rules, an **ACL**, just like a network-based firewall. Rules can allow or deny traffic based on source or destination port or IP address, service, protocol, or application. Rules are applied in order, and the first matching rule decides.

A host-based firewall should always block ports and services the device does not need. A laptop that never shares files has no reason to accept file-sharing connections.

## 4 Blocking outbound traffic

A host-based firewall can also block specified types of **outbound** traffic. For example, blocking outbound FTP (file transfer protocol, port 21) prevents an adversary who has gained remote access to the host from using FTP to **exfiltrate** (copy out) a file to their own server. Outbound rules limit what an attacker can do even after getting in.

## 5 Testing a rule set

Host-based firewall rules on a staff laptop

```
Rule 1: ALLOW inbound TCP port 3389 from 10.10.9.0/24
Rule 2: DENY inbound ALL ALL from ALL
Rule 3: DENY outbound TCP port 21 to ALL
Rule 4: DENY outbound TCP port 23 to ALL
Rule 5: ALLOW outbound ALL ALL to ALL
```

| Traffic | Result | Deciding rule |
| --- | --- | --- |
| IT help desk remote session from 10.10.9.30 | ALLOW | Rule 1 |
| Remote desktop attempt from the café Wi-Fi | DENY | Rule 2 |
| File-sharing probe from another laptop | DENY | Rule 2 |
| FTP upload to an outside server | DENY | Rule 3 |
| Loading a website | ALLOW | Rule 5 |

The key idea

A host-based firewall protects one device, wherever it is. It uses ordered ACL rules like a network firewall, should block every port and service the device does not need, and can block outbound traffic to stop data from being sent out.

## 6 Worked examples

Worked Example 1 Trace the rules

### Remote desktop from the café

Using the rules above, the laptop is on café Wi-Fi. Someone at `192.168.0.44` tries to connect with remote desktop (inbound TCP 3389). What happens?

1. 1

   Rule 1 allows inbound 3389 only from `10.10.9.0/24` (the IT subnet). `192.168.0.44` is not in that range: no match.

2. 2

   Rule 2 denies all other inbound traffic: match.

**Answer:** Denied by Rule 2. Only the IT help desk subnet can reach remote desktop.

Worked Example 2 Outbound rules

### Stopping the upload

An attacker gets remote access to the laptop and tries to upload a file to their server at `203.0.113.99` using FTP (outbound TCP 21). What happens, and why does this rule matter?

1. 1

   Rules 1 and 2 are inbound: they do not apply.

2. 2

   Rule 3 denies outbound TCP port 21 to any destination: match. The upload is blocked.

3. 3

   Even with remote access, the attacker cannot use FTP to exfiltrate data.

**Answer:** Denied by Rule 3. Outbound rules limit damage after a compromise.

Worked Example 3 Order matters

### Moving the allow-all

If Rule 5 (`ALLOW outbound ALL ALL to ALL`) were moved above Rule 3, what would happen to the FTP upload?

1. 1

   The upload would now match the allow-all rule first.

2. 2

   First match wins, so it would be allowed; the FTP block below it would never be reached.

**Answer:** It would be allowed. Specific denies must come before broad allows.

Worked Example 4 Block what is not needed

### Ports on a kiosk

A library kiosk only needs to load websites. Its host-based firewall currently allows all inbound traffic. What should its rules be?

1. 1

   Inbound: deny all. The kiosk offers no services to other computers.

2. 2

   Outbound: allow web traffic (TCP 443, and 80 if needed) and DNS lookups (port 53); deny everything else.

3. 3

   Everything the kiosk does not need is blocked.

**Answer:** Deny all inbound; allow only the outbound traffic web browsing requires.

## 7 Common mistakes

Common Mistake 1 · Thinking a network firewall makes host firewalls unnecessary

Network firewalls do not see traffic between devices inside the network, and do not travel with a laptop. Host firewalls cover both gaps.

Common Mistake 2 · Only filtering inbound traffic

Outbound rules stop malware from contacting attackers and stop data from being copied out.

Common Mistake 3 · Leaving unneeded ports open

Every open port is a way in. A host firewall should block every port and service the device does not need.

Explain a host-firewall rule like this

“Rule 3 denies outbound TCP port 21 from the laptop. If an adversary gains remote access, they cannot use FTP to exfiltrate files to their server, because the host-based firewall blocks that outbound traffic before it leaves the device.”

Quote the rule, say what traffic it matches, and explain the attack it prevents.

FiveStudy AP® Cybersecurity · Host-Based Firewall
