Host-based firewall

On this page 7

A host-based firewall is packet-filtering software that runs inside the operating system of a single computer and decides which inbound and outbound network connections that machine may accept or initiate. Unlike a network firewall at the perimeter, it protects the host itself, regardless of which network the device is attached to.

In OS security, the host-based firewall is one of the built-in protections of every major desktop operating system: Windows Defender Firewall, the macOS Application Firewall and packet filter, and nftables or iptables on Linux. It complements process isolation, OS hardening and security updates by limiting how an attacker can reach or abuse network services.

How a host-based firewall filters traffic

A host-based firewall hooks into the network stack of the kernel, where it inspects each packet or connection attempt before the operating system delivers it to an application or sends it to the network. On Windows this happens through the Windows Filtering Platform (WFP), on Linux through Netfilter hooks, and on macOS through the pf packet filter and a socket-level application filter.

Most host firewalls are stateful: they track established connections in a state table, so reply packets to a permitted outbound request are allowed automatically while unsolicited inbound packets are compared against the rule set. Rules are evaluated in a defined order, and a default policy decides what happens to traffic that matches no rule.

The table lists the criteria a typical rule can match and what each criterion is useful for.

CriterionExample valueTypical use
DirectionInbound or outboundSeparate exposure from exfiltration control
Protocol and portTCP 3389, UDP 53Allow or block specific services
Remote address192.168.10.0/24Limit management access to a subnet
Application pathC:\Program Files\App\app.exeBind permission to one program
Network profileDomain, private or publicStricter rules on untrusted networks
InterfaceWi-Fi, VPN adapterRestrict services to one interface
User or service identitySpecific service accountAllow traffic only for a named service
Common matching criteria in host firewall rules

Host-based firewall versus network firewall

The two firewall types solve different problems and work best together. A network firewall enforces policy between network segments, while a host-based firewall enforces policy at the endpoint and can see which local process owns each connection.

This comparison shows where each type is strong and where it is blind.

AspectHost-based firewallNetwork firewall
Scope of protectionOne deviceAn entire segment or site
Visibility of applicationsKnows the local processInfers from traffic only
Lateral movement inside a LANCan block itUsually cannot see it
Protection on public Wi-FiTravels with the laptopAbsent outside the office
Resistance to local compromiseWeak if attacker gains admin rightsIndependent of the host
Central managementNeeds policy tools such as Group Policy or MDMConfigured on one appliance
Host-based and network firewalls compared

The key trade-off is trust in the host. Because the firewall runs on the protected machine, malware with administrative or kernel privileges can disable or bypass it. Defense in depth therefore pairs it with network controls and with privilege separation, so ordinary processes cannot change firewall rules.

Built-in host firewalls in desktop operating systems

Each desktop operating system ships its own firewall with different defaults. Windows enables its firewall by default and blocks unsolicited inbound traffic on all profiles. macOS ships an application firewall that is disabled by default on many installations, with pf available underneath. Linux distributions vary: some enable firewalld or ufw, others leave the rule set empty.

Operating systemFirewall componentKernel mechanismDefault inbound behavior
WindowsWindows Defender FirewallWindows Filtering PlatformBlock unsolicited, per profile
macOSApplication Firewall and pfSocket filter and pfOften off until enabled
Linuxfirewalld, ufw or raw nftablesNetfilterDepends on the distribution
FreeBSDpf, ipfw or ipfKernel packet filtersOff until configured
Host firewall implementations by operating system

Outbound filtering deserves special attention: most defaults allow all outbound traffic. Restricting outbound connections stops some malware from contacting command-and-control servers, but it requires careful rule maintenance, because legitimate software constantly needs updates and cloud services.

Designing an effective host firewall policy

A good policy starts from default deny for inbound traffic and opens only the services a machine genuinely provides. Rules should be as narrow as possible, combining port, application and remote address rather than opening a port to the whole internet.

Endpoint roleRecommended inbound policyReason
Office laptopDeny all inbound on public profileUntrusted networks expose every listening service
Developer workstationAllow local test ports only from localhostPrevents accidental exposure of debug servers
Administrator jump hostAllow remote desktop from admin subnet onlyReduces attack surface for privileged access
Kiosk or shared PCDeny inbound, restrict outbound to allowlistLimits misuse and data leakage
Policy decisions for common endpoint roles

In managed environments, rules should come from central policy through Group Policy, MDM profiles or configuration management, with local rule merging disabled. This prevents users or installers from silently opening ports, and logging of dropped connections gives incident responders useful evidence.

Limitations and common mistakes

  • Disabling the firewall to fix a connectivity problem and never re-enabling it, which leaves every listening service exposed.
  • Allowing broad application exceptions when an installer requests them, which can open ports on public networks.
  • Assuming the firewall inspects content. A host firewall filters connections; it does not detect malicious payloads inside allowed traffic.
  • Forgetting IPv6. Rules written only for IPv4 addresses can leave equivalent IPv6 paths open.
  • Relying on it after compromise. An attacker with administrator rights can rewrite rules, so tamper protection and monitoring matter.

The idea in brief

A host-based firewall is like a doorman for one computer. Every time something on the network knocks, or a program on the computer wants to go out, the doorman checks a list of rules and decides whether to open the door.

Because the doorman lives inside the computer, it protects the machine at home, in the office and in a café. It cannot stop a burglar who already has the master key, but it closes most doors that should never be open.

A practical scenario

A consultant connects a company laptop to hotel Wi-Fi. A file-sharing service on the laptop listens on TCP port 445, and another guest’s infected machine on the same network scans for exactly that port to spread ransomware.

Because the laptop’s firewall detects the hotel network as a public profile, it blocks all unsolicited inbound connections, including port 445. The scan receives no response, and the consultant notices nothing. Back in the office on the domain profile, central policy allows file sharing only from the IT management subnet. The same firewall applies different rules by location, and the infection never reaches the laptop.