The best Linux firewalls for servers in 2026

Updated November 15, 2026By HostCrust7 tools compared12 min read

Use the firewall your distribution already ships. On Debian, use nftables, the kernel's current packet filter. On AlmaLinux, Rocky and RHEL, use firewalld: zones and service names on top of nftables. On Ubuntu, use ufw, the simplest way to write a safe rule set.

Add Fail2ban or CrowdSec if you want brute-force sources banned automatically. Neither is a firewall. CSF still works, but its developer closed in August 2025, so avoid it on new servers unless a control panel needs it.

Our top picks

Compare at a glance

ToolBest forPricingOpen sourceDeploymentTested by us
nftablesDebian servers, and anyone who wants one modern rule setFree to use under its open-source license (GPL-2.0)YesBuilt into the Linux kernel, managed with the nft commandYes
firewalldAlmaLinux, Rocky Linux and RHEL serversFreeYesDaemon on the server (nftables backend by default)Yes
ufw (Uncomplicated Firewall)Ubuntu servers and the simplest safe setupFreeYesPackage on the server (front end to iptables)Docs only
iptablesexisting scripts and tools that still expect iptablesFreeYesBuilt into Linux, managed with the iptables commandYes
CSF (ConfigServer Security & Firewall)existing cPanel and DirectAdmin servers that already run itFreeYesSelf-hosted (Perl scripts plus the lfd daemon)Docs only
Fail2banbanning brute-force sources (an add-on, not a firewall)FreeYesDaemon on the serverYes
CrowdSecbehavior-based detection with optional shared blocklists (an add-on)Security Engine and Community plan free; Console Premium pay-as-you-grow; Platinum Blocklists from $1,900 per monthYesSelf-hosted engine, optional SaaS consoleYes

The full ranking

nftables

Best for: Debian servers, and anyone who wants one modern rule set

nftables is the packet filter in today's Linux kernel, so it ranks first: most other tools on this list either drive it or sit beside it. One inet table covers IPv4 and IPv6 together. It has been Debian's default framework since Debian 10, and firewalld on the RHEL family uses it as its backend. Rules live in /etc/nftables.conf, and nft -c -f checks a file without loading it. The syntax takes an afternoon to learn, and there are no zones or app profiles, so teams that want the simplest possible commands should start with ufw or firewalld.

Pricing
Free to use under its open-source license (GPL-2.0) (checked November 15, 2026, source)
License
Open source (GPL-2.0; newer code GPL-2.0-or-later)
Deployment
Built into the Linux kernel, managed with the nft command
Runs on
Linux kernel 3.13 and later; the default framework on Debian since Debian 10

Pros

  • Built into the kernel; nothing extra to run
  • One rule set for IPv4 and IPv6
  • Check mode (nft -c) before you load a file
  • The base layer that firewalld and iptables-nft write to

Cons

  • Steeper syntax than ufw
  • No zones or service profiles of its own
  • Other tools (Docker, firewalld) add their own tables, which you have to read alongside yours

Tested by us: Debian 12 (web-01), nftables 1.0.6, 14 Nov 2026: nft list ruleset showed an inet filter table with an input policy of drop that accepts loopback, established traffic, ICMP and TCP 22; nft -c -f /etc/nftables.conf passed. Read-only.

firewalld

Best for: AlmaLinux, Rocky Linux and RHEL servers

On AlmaLinux, Rocky and RHEL, firewalld is the standard firewall service and should be your default. It groups interfaces and sources into zones, names rules after services, and keeps runtime and permanent settings apart, so you can try a change before saving it. Its backend is nftables by default: on our AlmaLinux 9.8 server the config said FirewallBackend=nftables and the rules sat in one inet firewalld table. That's also why iptables -S showed an empty, all-ACCEPT rule set while the firewall was active. It's heavier than ufw (a daemon with a D-Bus API), so Debian and Ubuntu users usually pick nftables or ufw instead.

Pricing
Free (checked November 15, 2026, source)
License
Open source (GPL-2.0)
Deployment
Daemon on the server (nftables backend by default)
Runs on
RHEL, AlmaLinux and Rocky Linux (their standard firewall service); also packaged by Debian

Pros

  • Default on the RHEL family
  • Zones and named services
  • Runtime and permanent settings are separate
  • Uses nftables underneath

Cons

  • A long-running daemon, heavier than ufw
  • Its nftables tables are verbose to read directly
  • Less common on Debian and Ubuntu

Tested by us: AlmaLinux 9.8 (web-01), firewalld 1.3.4, 14 Nov 2026: firewall-cmd --list-all (public zone: dhcpv6-client and ssh), --check-config (success), FirewallBackend=nftables, nft list table inet firewalld. Read-only.

ufw (Uncomplicated Firewall)

Best for: Ubuntu servers and the simplest safe setup

ufw is Ubuntu's default firewall tool and the easiest to get right: allow OpenSSH, enable it, and you're done. Ubuntu ships it disabled, and the Ubuntu docs say its back end is iptables-restore. Its weak spot is Docker: Docker's own documentation calls the two incompatible, because published container ports are routed before ufw's rules see the traffic. The last upstream release, 0.36.2, came out in May 2023, so it's stable rather than fast-moving. Pick it for simple Ubuntu servers; on Docker hosts, read Docker's firewall notes first or write nftables rules directly.

Pricing
Free (checked November 15, 2026, source)
License
Open source (GPL-3.0)
Deployment
Package on the server (front end to iptables)
Runs on
Ubuntu (default, disabled out of the box); also packaged by Debian

Pros

  • Ubuntu's default; very short commands
  • Application profiles such as OpenSSH
  • Good fit for single-purpose servers

Cons

  • Docker-published ports bypass it
  • Uses iptables-restore under the hood
  • No zones; complex setups outgrow it

Not tested by us yet: based on the vendor's documentation.

iptables

Best for: existing scripts and tools that still expect iptables

The iptables command still works almost everywhere and is still maintained (1.8.13 shipped in March 2026), but on current distributions it's mostly a compatibility layer. On our AlmaLinux 9.8 server, iptables -V printed v1.8.10 (nf_tables), and Debian has used iptables-nft by default since Debian 10. Keep it for old scripts and tools that call it; Fail2ban's default ban action in Debian 12 still does. Don't start a new rule set in it. Mixing iptables-nft rules with native nftables tables works, but the full picture gets harder to read, as the empty iptables -S next to an active firewalld showed us.

Pricing
Free (checked November 15, 2026, source)
License
Open source (GPL-2.0)
Deployment
Built into Linux, managed with the iptables command
Runs on
Linux; on current distributions the iptables command usually drives nftables (iptables-nft)

Pros

  • Familiar to almost every Linux admin
  • Huge body of examples and scripts
  • Still maintained upstream

Cons

  • Superseded by nftables for new rule sets
  • Can't see native nftables tables
  • Separate commands for IPv4 and IPv6

Tested by us: AlmaLinux 9.8 (web-01), 14 Nov 2026: iptables -V (v1.8.10, nf_tables) and iptables -S, which listed only ACCEPT policies while firewalld's nftables rules were active. Read-only.

CSF (ConfigServer Security & Firewall)

Best for: existing cPanel and DirectAdmin servers that already run it

CSF is here because many hosting servers still run it, not because we'd install it on a new one. It wraps the kernel firewall in one config file and adds lfd, a login-failure daemon that blocks brute-force sources. Its developer, Way to the Web Ltd, shut down on 31 August 2025 and released csf under GPL-3.0. configserver.com didn't respond when we checked on 15 November 2026. cPanel maintains a fork for cPanel & WHM servers only, and a community fork (Aetherinox/csf-firewall) is active. If you run CSF, move to a maintained fork. On a server without a panel, use nftables or firewalld plus Fail2ban or CrowdSec.

Pricing
Free (checked November 15, 2026, source)
License
Open source (GPL-3.0) since the 2025 shutdown
Deployment
Self-hosted (Perl scripts plus the lfd daemon)
Runs on
RHEL- and Debian-family Linux; integrates with cPanel, DirectAdmin and other panels

Pros

  • One config file plus a login-failure daemon (lfd)
  • Panel integrations for cPanel, DirectAdmin and others
  • Now GPL-3.0

Cons

  • Original developer closed in August 2025; no official updates or downloads
  • Maintenance now depends on forks
  • Overkill on servers without a hosting panel

Not tested by us yet: based on the vendor's documentation.

Fail2ban

Best for: banning brute-force sources (an add-on, not a firewall)

Fail2ban isn't a firewall. It reads logs, counts failures such as bad SSH logins, and asks the firewall to ban the source for a while, which makes it the classic add-on to any tool above. On Debian 12 we hit a real gotcha: with the stock 1.0.2-2 package, the sshd jail fails its config test with Have not found any log file for sshd jail, because Debian 12 logs SSH to the journal, not /var/log/auth.log. Adding backend = systemd fixed it. In the Debian 12 package the default ban action is iptables-multiport, so check that it matches your firewall.

Pricing
Free (checked November 15, 2026, source)
License
Open source (GPL-2.0)
Deployment
Daemon on the server
Runs on
Linux and other POSIX systems; packaged by Debian

Pros

  • Small, mature, works offline
  • Filters for SSH and many common services
  • fail2ban-regex lets you test filters against real logs

Cons

  • Not a firewall: needs nftables, firewalld or iptables underneath
  • Debian 12's default sshd jail needs backend = systemd
  • Debian 12's default ban action uses iptables

Tested by us: Debian 12 (web-01), Fail2ban 1.0.2-2, 14 Nov 2026, installed with the sshd jail switched off so nothing could be banned. The packaged default config failed fail2ban-client -t (no sshd log file); with backend = systemd it passed. fail2ban-regex reported 561 failregex matches in about 2.5 hours of sshd journal entries. Removed afterwards.

CrowdSec

Best for: behavior-based detection with optional shared blocklists (an add-on)

CrowdSec isn't a firewall either. Its open-source Security Engine reads logs and detects behavior such as SSH brute force; blocking only happens once you add a bouncer, such as its firewall bouncer. On our AlmaLinux server, the 1.8.2 package found the sshd, Linux and auditd logs and enabled those collections by itself. With no bouncer installed it blocked nothing, exactly as its documentation says. It's a bigger install than Fail2ban (dnf reported 330 MB) and it opens local API ports (8080 and 6060 on localhost). Pick it for richer detection and its blocklists; pick Fail2ban for a small single server.

Pricing
Security Engine and Community plan free; Console Premium pay-as-you-grow; Platinum Blocklists from $1,900 per month (checked November 15, 2026, source)
License
Security Engine open source (MIT); Console and premium blocklists are proprietary
Deployment
Self-hosted engine, optional SaaS console
Runs on
Linux, with official package repositories for RHEL-family and Debian-family systems

Pros

  • Detects behavior, not just repeated failures
  • Auto-detected sshd and system logs on install
  • Engine is MIT-licensed

Cons

  • Not a firewall: needs a bouncer to block anything
  • 330 MB installed on our AlmaLinux VM
  • Listens on localhost ports 8080 and 6060 by default

Tested by us: AlmaLinux 9.8 (web-01), CrowdSec 1.8.2 from its official package repository, engine only, 14 Nov 2026: collections sshd, linux and auditd enabled automatically; cscli metrics showed it reading /var/log/secure, /var/log/messages and the audit log; no bouncers, no decisions. Removed afterwards with its repository and keys.

How we picked

We ranked host firewalls, the ones that run on the Linux server itself, on five things: whether the tool is maintained today, whether major distributions ship it by default, how hard it is to lock yourself out, how it copes with IPv6 and Docker, and how good its documentation is. We checked every project's own site or repository on 15 November 2026.

On 14 November 2026 (UTC) we inspected the live firewalls on two test servers, called web-01 here: nftables on Debian 12 and firewalld on AlmaLinux 9.8. We only listed and checked rules. We never added, changed or reloaded one, because a wrong firewall rule can cut off SSH. We also installed Fail2ban and CrowdSec, ran them in a way that couldn't ban anyone, and removed them. ufw and CSF are covered from their documentation.

Fail2ban and CrowdSec are ranked last on purpose. They aren't firewalls; they feed one.

Which Linux firewall should you use?

Start with the one your distribution is built around, because that's what its documentation, packages and other admins expect. On Debian, that's nftables: it has been Debian's default framework since Debian 10, you write rules in /etc/nftables.conf, and systemctl enable nftables loads them at boot. On AlmaLinux, Rocky Linux and RHEL, it's firewalld, the family's standard firewall service, which stores its rules in nftables. On Ubuntu, it's ufw, which Ubuntu calls its default firewall tool and ships turned off. All three end up as rules in the kernel's netfilter, so the choice is about the interface you and your team will use every day, not about raw protection. Once the firewall allows only what the server serves, add Fail2ban or CrowdSec if you want repeated SSH failures banned automatically. Avoid stacking two front ends, such as ufw and firewalld, on one server.

DistributionDefault toolOut of the boxWrites rules to
UbuntuufwInstalled, disablediptables-restore
Debian 10 and laternftablesFramework in place; you write the rulesnftables
AlmaLinux, Rocky, RHELfirewalldStandard firewall service; on our 9.8 server, the public zone allowed ssh and dhcpv6-clientnftables (FirewallBackend=nftables)

Is CSF still maintained?

Not by the company that made it. Way to the Web Ltd, the company behind ConfigServer, closed on 31 August 2025, and cPanel reports that its free scripts, csf included, remain available under the GPLv3 license. Since then there have been no official updates, downloads or support, and on 15 November 2026 configserver.com itself didn't respond to us. Existing installs keep working, which is why so many hosting servers still run it. Maintenance has moved to forks: cPanel publishes one for cPanel & WHM servers only, and an independent community fork on GitHub supports RHEL- and Debian-family systems and is still active. That makes CSF community software with no single owner, much like any other GPL project that outlived its company. For a new server without a hosting panel, the distribution's own firewall plus Fail2ban or CrowdSec covers the same ground with less risk. Here is what each source says, as of 15 November 2026:

  • configserver.com: the site didn't respond to our requests from two different networks (the connection was reset or refused). Its last archived announcement, from late August 2025, said Way to the Web Ltd and configserver.com were “closing down permanently on 31 August 2025”. It said the closure covered the free csf too, that there would be no further support or downloads after that date, and that installed copies of csf would keep working but no longer be updated. An update on the same page said they were working on releasing csf under GPLv3 on GitHub before closing.
  • cPanel (blog post, 18 September 2025): ConfigServer's tools, CSF included, were officially discontinued as of 31 August 2025. The free scripts remain available under GPLv3, with no more patches, updates or support. cPanel recommends moving to Imunify360.
  • cPanel's fork (cpanel/cpanel-csf on GitHub, GPL-3.0): its README says the package is for cPanel & WHM systems only and fails to install when cPanel isn't present. The latest commit on its main branch is dated 25 February 2026.
  • A community fork (Aetherinox/csf-firewall on GitHub, GPL-3.0) supports RHEL- and Debian-family distributions. Its latest release is v15.10 (28 February 2026), and it had commits as recent as 14 November 2026.

So CSF is now community software. If you already run it, point updates at a maintained fork and watch its releases, or plan a move to the distribution's own firewall plus Fail2ban or CrowdSec. If your control panel depends on CSF, follow the panel vendor's advice first.

What we saw on our test servers

On Debian 12, the nftables rule set allows SSH and nothing else that starts a connection from outside. This is the whole rule set as nft list ruleset printed it:

table inet filter {
	chain input {
		type filter hook input priority filter; policy drop;
		iif "lo" accept
		ct state established,related accept
		ct state invalid drop
		meta l4proto { icmp, ipv6-icmp } accept
		tcp dport 22 accept
	}
	chain forward {
		type filter hook forward priority filter; policy drop;
	}
	chain output {
		type filter hook output priority filter; policy accept;
	}
}
$ nft -c -f /etc/nftables.conf && echo OK
OK

On AlmaLinux 9.8, firewalld does the same job with zones. The interesting part is what iptables shows on the same server:

$ firewall-cmd --get-active-zones
public
  interfaces: eth0
$ firewall-cmd --list-services
dhcpv6-client ssh
$ grep FirewallBackend /etc/firewalld/firewalld.conf
FirewallBackend=nftables
$ iptables -V
iptables v1.8.10 (nf_tables)
$ iptables -S
-P INPUT ACCEPT
-P FORWARD ACCEPT
-P OUTPUT ACCEPT

The firewall is on, but iptables -S sees none of it, because firewalld writes native nftables rules that the iptables layer doesn't display. If you inherit a RHEL-family server, check with firewall-cmd or nft list ruleset, not iptables -L.

Fail2ban on Debian 12 showed why testing the config matters. We installed the stock package with its sshd jail switched off (so nothing could be banned), then tested a copy of the default config:

$ fail2ban-client -c ./default-config -t
ERROR   Failed during configuration: Have not found any log file for sshd jail
# after adding "[sshd] backend = systemd" in jail.d/
$ fail2ban-client -c ./default-config -t
OK: configuration test is successful

How not to lock yourself out of SSH

  • Allow SSH before you change the default policy. With ufw, run ufw allow OpenSSH before ufw enable. With nftables, keep a tcp dport 22 accept rule above any drop.
  • Check before you load. nft -c -f file parses a rule file without applying it, and firewall-cmd --check-config checks firewalld's saved configuration.
  • Use firewalld's runtime layer. Change the runtime configuration first, confirm you can still open a new SSH session, then save it with --runtime-to-permanent. A reload or reboot drops runtime changes you haven't saved.
  • Keep a second way in. Make sure you can reach your provider's web console before touching a remote firewall.
  • Test from a new session. An open SSH session usually survives a new rule because established traffic is allowed. Only a fresh login proves the rule is right.

What about OPNsense and pfSense?

They're excellent, but they're a different kind of firewall, which is why they aren't in the ranking. OPNsense (built on FreeBSD, BSD-licensed) and pfSense (from Netgate) are network firewalls and routers. They run on their own hardware appliance or virtual machine and filter traffic between networks, for example in front of a rack of servers, a private network or an office, and they add things a host firewall doesn't do, such as routing and VPN gateways for the whole network. They don't run on your Linux server, though, and they don't replace its host firewall: traffic between two servers behind the same appliance, or from a compromised neighbour, never passes through it. If you have several servers on one network, a network firewall in front plus a host firewall on each server is a sound combination. If you have one VPS, a host firewall is enough, and a separate firewall appliance would be one more system to patch.

Do you need a host firewall if your cloud has security groups?

Usually yes, as a second layer. A provider's security group or cloud firewall filters traffic before it reaches the server, which is good, and you should use it. But it doesn't follow the server if you move providers, it doesn't see traffic between containers or services on the same host, and it's easy for a console change, a Terraform edit or a teammate to open more than you meant. It also can't tell a database that should listen only on localhost from one that was accidentally bound to every interface. A host firewall that allows only the ports the server actually serves costs nothing to run and protects you on the day the outer layer is wrong. It's also the layer you control from the server itself, with the same tools on every provider. On a server whose only public service is SSH, the short nftables rule set shown above is about all you need, and it takes a few minutes to set up.

How we checked this: On 14 Nov 2026 (UTC), on two test VMs we call web-01. Debian 12 with nftables 1.0.6: nft list ruleset and nft -c -f /etc/nftables.conf (check mode). AlmaLinux 9.8 with firewalld 1.3.4: firewall-cmd --list-all, --check-config, the backend setting, nft list table inet firewalld, and iptables -V and -S (read-only). We also installed Fail2ban 1.0.2-2 on the Debian VM with its sshd jail switched off and ran its config test and fail2ban-regex, and the CrowdSec 1.8.2 engine (no bouncer) on the AlmaLinux VM; both were removed afterwards and the firewall rules were checked unchanged. No firewall rule was added, changed or reloaded. ufw and CSF are covered from documentation, and CSF's status from the archived configserver.com announcement, cPanel's notice and the fork repositories. Anything we didn't run ourselves comes from the official documentation listed under Sources.

Check which CVEs are really open on your server

HostCrust Patch Proof compares every installed package with your distribution's own security data. It counts fixes your distro backported and checks the kernel that is actually running, not just the one on disk. Read-only, no root, free.

Run the free check About Patch Proof

FAQ

What is the default firewall on Ubuntu, Debian and RHEL?

Ubuntu's default firewall tool is ufw, and Ubuntu ships it disabled. Debian has used nftables as its default framework since Debian 10; you write the rules in /etc/nftables.conf and enable nftables.service. RHEL, AlmaLinux and Rocky Linux use firewalld, which on our AlmaLinux 9.8 server used nftables as its backend and allowed only SSH and DHCPv6 client traffic in the public zone.

Is CSF (ConfigServer Firewall) still maintained?

Not by its original developer. Way to the Web Ltd closed configserver.com on 31 August 2025 and released csf under GPL-3.0, and the site didn't respond when we checked on 15 November 2026. cPanel maintains a fork for cPanel & WHM servers only, and a community fork on GitHub (Aetherinox/csf-firewall) had commits as recent as 14 November 2026. If you run CSF, switch to a maintained fork or plan a move.

Is iptables deprecated?

The iptables command is still maintained (1.8.13 came out in March 2026), but nftables replaces it as the kernel's packet-filtering framework. On most current distributions the iptables command is the iptables-nft compatibility layer, which writes nftables rules. On our AlmaLinux 9.8 server, iptables -V printed v1.8.10 (nf_tables). Keep iptables for old scripts, but write new rules in nftables or a front end.

Is Fail2ban a firewall?

No. Fail2ban reads logs, counts failures such as bad SSH logins, and asks your firewall to ban the source for a while. You still need a firewall (nftables, firewalld or ufw) underneath. CrowdSec works the same way: its engine only detects, and a separate bouncer does the blocking.

Does Docker bypass ufw?

Yes, for published container ports. Docker's documentation says Docker and ufw are incompatible, because Docker routes container traffic in the nat table before it reaches the chains ufw filters. A port you publish with -p can be reachable even if ufw denies it. Read Docker's packet-filtering notes before relying on ufw on a Docker host.

ufw or firewalld: which is better?

Neither is better in general; use the one your distribution is built around. ufw is simpler and is Ubuntu's default. firewalld adds zones, named services, and separate runtime and permanent settings, and it's the default on the RHEL family. Both are front ends: the rules end up in the kernel's netfilter either way.

Sources

  1. Netfilter: the nftables project (kernel 3.13+, nft tool, replaces iptables, ip6tables, arptables and ebtables)
  2. Netfilter: the iptables project (latest release 1.8.13)
  3. Debian Wiki: nftables (default framework since Debian 10, iptables-nft)
  4. Ubuntu Server documentation: firewalls (ufw is the default tool, disabled by default)
  5. ufw on Launchpad (GPL-3.0, release 0.36.2)
  6. firewalld project site (zones, runtime and permanent configuration)
  7. firewalld.conf(5): FirewallBackend defaults to nftables
  8. configserver.com announcement, as archived by the Wayback Machine on 28 Aug 2025
  9. cPanel blog: The End of ConfigServer (18 Sep 2025): discontinued 31 Aug 2025, free scripts available under GPLv3
  10. cPanel's CSF fork on GitHub (cPanel & WHM only, GPL-3.0)
  11. Community CSF fork on GitHub: Aetherinox/csf-firewall (GPL-3.0)
  12. Fail2ban on GitHub
  13. CrowdSec docs: Linux installation (the engine alone does not block)
  14. Docker docs: packet filtering and firewalls (Docker and ufw)
  15. OPNsense project site
  16. pfSense project site (Netgate)