The Big Picture: A Doorman for Network Traffic
Your PC talks over the network all the time. Programs listen for connections, and other computers try to connect. Some of that traffic is welcome (a web page you asked for). Some is not (a stranger on the café Wi-Fi trying to reach a service on your PC).
A firewall is a doorman that looks at network traffic and decides: let it through, or drop it. Windows Defender Firewall is built into Windows and runs by default. It is a host firewall: it protects this one PC, rather than a whole network (a router's firewall protects the network edge).
Network words, explained:
| Word | Plain meaning |
|---|---|
| Packet | A small chunk of data sent over a network |
| IP address | The number that identifies a computer on a network |
| Port | A numbered "door" on a computer. Web servers use 80 and 443; remote desktop uses 3389 |
| Protocol | The rules of a conversation: TCP and UDP are the two common ones |
| Inbound | Traffic coming into your PC |
| Outbound | Traffic going out of your PC |
Stateful. The Windows firewall is stateful: it remembers the connections your PC started. If you open a website (outbound), the reply coming back (inbound) is automatically allowed because it belongs to a conversation you began. An unrelated, unrequested packet from the outside is a different matter.
Outbound request ──────────► Internet
(you asked for a page)
Reply (inbound) ◄────────── Internet allowed: matches your request
Stranger knocks (inbound, unrequested) ──► BLOCKED by default
Networking is covered in more depth later in the course. Here we only need the idea of packets, ports and who started the conversation.
7.1 Inbound/Outbound Rule Model
What it is: The firewall is a list of rules. Each rule says: for traffic that matches these conditions, do Allow or Block.
The defaults (very important):
| Direction | Default | Meaning |
|---|---|---|
| Inbound | Block | Unrequested incoming traffic is dropped unless a rule allows it |
| Outbound | Allow | Your programs may connect out unless a rule blocks it |
Why this way? Incoming connections are the main way attackers reach a PC, so everything is closed by default. Outgoing traffic is mostly your programs doing things you wanted, so it is open by default. (Some companies and security tools switch outbound to block by default, but that takes much more rule-writing.)
What a rule can match on:
| Condition | Example |
|---|---|
| Program | C:\Program Files\Mozilla Firefox\firefox.exe |
| Port and protocol | TCP port 3389 |
| Remote or local address | Only allow computers from 192.168.1.0/24 |
| Profile | Apply only on Private networks (see 7.2) |
| Service or app package | A Windows service, or a Store app |
| Action | Allow, Allow if secure (needs IPsec), Block |
How rules are evaluated:
Packet arrives (inbound)
│
▼
┌───────────────────────────────┐
│ Part of a connection you │── yes ──► ALLOW (stateful)
│ already started? │
└──────────────┬────────────────┘
│ no
┌──────────────▼────────────────┐
│ Any BLOCK rule matches? │── yes ──► BLOCK (block beats allow)
└──────────────┬────────────────┘
│ no
┌──────────────▼────────────────┐
│ Any ALLOW rule matches? │── yes ──► ALLOW
└──────────────┬────────────────┘
│ no
▼
PROFILE DEFAULT: BLOCK (inbound)
In general, a matching Block rule wins over an Allow rule. (The full ordering has extra steps, such as IPsec-related rules and service-hardening rules, but the idea above is the one to remember.)
Where rules come from:
- Built in: Windows ships with hundreds of rules, mostly turned off (for example, File and Printer Sharing). Turning one on opens a door.
- Installed programs: Many apps add their own rules when installed.
- The pop-up: When a program tries to listen for incoming connections, Windows may ask "Allow access?". Your answer creates a rule. On a Public network, be especially careful.
- You or your organisation: through Windows Defender Firewall with Advanced Security (
wf.msc), PowerShell, or Group Policy.
Under the hood. The firewall's rules are enforced by the Windows Filtering Platform (WFP), a set of kernel filtering hooks in the network stack. Other security products can also add filters to it. (This is a simplified view; depends on version.)
Useful commands:
Get-NetFirewallProfile # state of the 3 profiles
Get-NetFirewallRule -Enabled True -Direction Inbound | Select DisplayName, Action -First 10
netsh advfirewall show allprofiles # older command, same ideaWindows tip: Rules named for something you do not recognise are not automatically bad. But if you see an Allow rule for a program you never installed, or a rule that opens a high port to Any address, look it up before deleting. Do not disable the firewall to "fix" a problem; add a narrow rule for the one program or port instead.
7.2 Profiles (Domain, Private, Public)
What it is: Not all networks are equally trustworthy. Your home Wi-Fi is not the same as an airport hotspot. Windows lets you have different firewall settings per network type, called profiles.
| Profile | When it applies | Typical trust |
|---|---|---|
| Domain | The PC is joined to a company's Active Directory domain and can reach its domain controller | Work network, managed by IT |
| Private | A network you marked as trusted: home, small office | You trust other devices there |
| Public | Any other network: café, hotel, airport (the default for new networks) | Do not trust anyone |
What changes between profiles:
| Item | Domain | Private | Public |
|---|---|---|---|
| Network discovery (PC visible to others) | Per policy | Can be on | Off by default |
| File and printer sharing | Per policy | Can be on | Off |
| Rules that apply | Rules marked for Domain | Rules marked for Private | Rules marked for Public (usually the strictest) |
Each profile has its own on/off switch and its own default actions. One network connection uses one profile at a time. If you have several network cards, each can use a different profile, with the most restrictive one being applied where needed.
You join "Cafe-WiFi" ──► Windows asks: private or public?
│
┌────────────┼────────────┐
▼ ▼ ▼
Public rules Private rules Domain rules
(strict) (more open) (company policy)
How to see and change it:
| Where | What to do |
|---|---|
| Settings → Network & internet → Wi-Fi (or Ethernet) → your network | Choose Public network or Private network |
| Windows Security → Firewall & network protection | See which profile is active; turn the firewall on/off per profile |
| PowerShell | Get-NetConnectionProfile shows the profile for each connection |
Safe habit: On any network you do not control, choose Public. Only use Private at home and at places where you trust every device.
Why the firewall matters even with antivirus. A firewall acts before a bad packet reaches a program, so a bug in a listening service never gets a chance to be attacked. Defender (Section 6) acts on files and behaviour. They protect different things; use both.
Summary
| Term | Plain meaning |
|---|---|
| Firewall | Allows or blocks network traffic by rules |
| Host firewall | Protects one PC (Windows Defender Firewall) |
| Stateful | Remembers connections you started and allows their replies |
| Inbound / outbound | Traffic into / out of the PC |
| Default policy | Inbound blocked, outbound allowed |
| Rule | Conditions (program, port, address) plus an action (Allow/Block) |
| Profile | Domain, Private, Public: different settings per network type |
| Public profile | Strictest; the default for unknown networks |
| WFP | Windows Filtering Platform, the engine that enforces the rules |
Get-NetFirewallProfile | PowerShell view of the three profiles |