Blog · Server security

Hardware vs software firewall

A hardware firewall filters packets on the network before they reach your server. A software firewall runs on the server and decides which ports may accept a connection. Production sites usually need both, because each layer sees traffic the other does not. A web application firewall reads the HTTP request and does not replace either one.
A man in a navy polo tapes a cardboard parcel at a warehouse desk, with a laptop open beside shelves of boxes

What does a firewall inspect between public internet traffic and your web server?

A firewall inspects traffic trying to reach a service on your server and applies the policy you set. It sees the source address, destination, port, and, on a stateful device, whether the packet belongs to an existing connection, then allows or drops it. It does not rewrite your site, choose strong passwords, or keep a file backup.

What it can seeDecision it makesWhat it does not do
Address, port, and protocolAllow the packet or drop itEdit application code
Connection state, on a stateful firewallWhether this packet continues an allowed conversationProve the sender is a real customer
Which interface the packet arrived onWhich services are reachable from the public internetStore a copy of your site

If port 443 is allowed, the firewall has done its network job. Anything inside that HTTPS request is a later problem for the application and, if you use one, a web application firewall.

How does a data-center hardware firewall filter network-layer (L3/L4) attacks?

A hardware firewall is a device, or a filter in the routers in front of the servers, at the network and transport layers. It drops packets aimed at closed ports, keeps management addresses off the public internet, and can absorb noisy floods. An allowed web port is still web traffic. A harmful request inside a normal HTTP call stays invisible.

  • Put the filter at the edge, in front of the VPS or dedicated server, not only on the guest after the traffic has arrived.
  • Publish the site on ports 80 and 443. Do not publish the database port.
  • Restrict SSH or Remote Desktop to addresses that actually administer the machine.
  • When a flood is larger than one server, the edge service has to take it. A guest firewall cannot add bandwidth the uplink does not have.

That last case is what a DDoS protection service is for. A small host rule is not a substitute for filtering that happens before the virtual machine.

How do host-based software firewalls (CSF, UFW, firewalld, Windows Firewall) work on a VPS?

A host firewall is software on the virtual machine. Its policy applies only to that machine. Linux admins commonly use CSF, UFW, or firewalld. Windows Server uses Windows Firewall. They can allow HTTP and HTTPS and limit SSH or Remote Desktop even when an upstream rule is wide. They cannot see packets the network never delivers to the guest.

ToolWhere it usually runsWhat you use it for
CSFLinux servers, often beside a panelPort policy plus simple allow and deny lists
UFWUbuntuA short allow list for SSH and the web ports
firewalldAlmaLinux, Rocky Linux, and similar systemsZones that separate public services from admin access
Windows FirewallWindows ServerRules for Remote Desktop and the web server

The clicks and the first rules for CSF are on the CSF firewall install guide. Open the port the application needs. Do not open every port because one test failed.

How is a Web Application Firewall (WAF) different from a network firewall?

A network firewall usually allows port 443 and stops. A WAF then reads the HTTP request. It can block an injection or script pattern, and a too-broad rule can also block a real customer. It is an application-layer control. It does not close SSH, and it is not a second hardware firewall.

Network firewallWeb application firewall
LayerNetwork and transportHTTP
Typical allowPort 443 is openA request that matches no block rule
Blind toThe words inside a form postPackets that never become HTTP
Does not replaceChecks written in the applicationThe edge or host firewall

Rule sets, false positives, and where a WAF sits on an account are covered on the web application firewall guide. Use that page when the question is which requests to block.

Why do production websites need both perimeter hardware filtering and a host/WAF firewall?

The perimeter filter drops traffic that should never reach the machine. The host firewall still matters when a new service or a missed edge rule exposes a port later. The WAF checks the web requests you allowed through both layers. Drop any layer and some traffic goes unwatched. Patches, unique admin passwords, and a restorable backup stay separate jobs.

  • Edge: drop closed ports, and noisy network floods, before they hit the guest.
  • Host: keep SSH, the panel, and databases off the open internet.
  • WAF: inspect the requests that real visitors must be allowed to send.
  • Still required: updated software and a backup you have actually restored once.

Need help with this?

WebJi® support does it for you — free. Talk to our Jaipur team →