Comparisons 8 min read

WAF vs Firewall: Which One Stops Layer 7 DDoS Attacks?

A practical comparison of what network firewalls and Web application firewalls can see, where each one stops attacks, and why Layer 7 floods expose the difference.

By BashPilot Team

The WAF vs firewall question becomes urgent when a website is timing out even though ports, connections and network rules all look normal. A network firewall may be doing its job perfectly while thousands of permitted HTTPS requests keep PHP workers, application threads or database queries busy. Layer 7 DDoS protection depends on understanding that difference before choosing where to enforce a rule.

WAF vs firewall: the practical difference

A firewall controls traffic between networks or hosts according to policy. The NIST firewall glossary describes it as a control over the flow of network traffic between systems with different security postures. In normal server operation, that means allowing the services you intend to publish, denying unnecessary ports and restricting sensitive services to trusted sources.

A Web application firewall works deeper in the request path. It inspects HTTP traffic after a connection has been accepted and, where HTTPS is used, after TLS has been terminated somewhere that can read the request. The OWASP Web Security Testing Guide notes that a WAF can inspect request content and apply controls such as blocking, rate limiting or browser verification.

QuestionNetwork firewallWeb application firewall
What does it primarily inspect?Addresses, ports, protocols, connection state and directionHTTP host, URI, method, headers, parameters, body and request behaviour
What is it best at?Reducing exposed services and stopping unwanted network accessStopping malicious or abusive requests sent to an allowed Web service
Can it understand a login or checkout request?Usually noYes, when it has access to the HTTP request context
Can it rate-limit an expensive URL?Not with ordinary packet and connection rulesYes, with path-aware request policies
Does it replace the other control?NoNo

Why Layer 7 DDoS traffic passes ordinary firewall rules

A public Web server must accept connections to HTTP or HTTPS. Once the firewall has allowed that connection, its basic decision is complete. The request may fetch a tiny cached file, or it may start a search, generate a report, call PHP and run several database queries. Those requests can look identical at the network layer while having completely different costs inside the application.

That is why simply closing a port is not a Layer 7 defence. Closing port 443 stops the attack by stopping every customer too. Limiting concurrent connections can reduce pressure from a small group of sources, but modern clients reuse connections and distributed attacks can keep each address below a simple threshold.

What the network firewall should still stop

The firewall remains the first boundary around the server. It should expose only required services, limit management access, reject obviously unwanted networks when that policy is justified and protect non-Web services from direct access. During an incident, it can quickly drop a confirmed abusive source before the connection reaches the Web stack. That is cheap and useful, but it is a source decision rather than an application decision.

Review listening services and the active firewall policy
ss -lntup
nft list ruleset

On systems managed by another firewall frontend, use its supported command to inspect the effective policy. Do not mix rule managers during an active incident.

  • Keep databases, internal APIs and administration ports unavailable to arbitrary Internet sources.
  • Apply source restrictions to SSH and control-panel access where operations permit them.
  • Use temporary address or subnet blocks only when evidence is strong and the collateral impact is understood.
  • Keep connection tracking and anti-spoofing controls, but do not mistake them for HTTP inspection.

What the WAF adds for Layer 7 DDoS protection

A WAF can make a narrower decision because it sees the request the application is about to process. Instead of blocking every visitor from a network, it can monitor or contain repeated requests to a costly route, reject a forbidden method, identify malformed clients or verify a suspicious browser before the request reaches application code. This is where Web application firewall DDoS protection differs from a port rule.

Observed attack patternBetter controlWhy
Known address repeatedly attacks several servicesNetwork firewall blockThe source is hostile before any application context is needed
Many sources flood one expensive HTTP routeWAF path and behaviour ruleThe shared request pattern matters more than any single address
Automation imitates a browser and rotates identitiesWAF verification or challengeThe decision needs request and client-behaviour context
Unused server port is exposed publiclyNetwork firewall deny ruleThere is no reason to accept the connection
Inbound bandwidth is already saturatedUpstream network mitigationOrigin controls act after the bandwidth has been consumed

Rate limits need a measured baseline. A copied requests-per-second value can block a legitimate sale, API client or crawler while still allowing a slow but expensive endpoint to exhaust workers. NGINX provides limit_req_dry_run, which counts excessive requests without enforcing the limit. Its request limiting documentation is a useful model for testing impact before changing live traffic.

Measure a candidate per-client limit before enforcement
limit_req_zone $binary_remote_addr zone=per_client:20m rate=10r/s;

server {
    location /expensive-route/ {
        limit_req zone=per_client burst=30 nodelay;
        limit_req_dry_run on;
        limit_req_log_level notice;
    }
}

Treat the numbers as placeholders. Set them from normal peak traffic for the specific route, validate the complete configuration, then review dry-run matches.

Where BashEdge fits between the request and the Web server

The manual controls are effective when the attack pattern is clear and one administrator can keep watching it. BashEdge brings the server firewall, Web application firewall and Layer 7 request evidence into one server-wide view. It connects sources with hosts, paths, request rates and attack rules, then lets the operator monitor, verify or contain the traffic before it becomes application work. You can inspect the workflow safely in the interactive BashEdge demo.

BashEdge WAF and firewall dashboard showing Layer 7 DDoS requests challenged and blocked before reaching Web applications
BashEdge connects request-level attack evidence with server-wide protection. Click the image to enlarge.

Use both controls without duplicating every rule

  1. 1

    Reduce network exposure

    Publish only required services and restrict administrative access at the firewall.

  2. 2

    Inspect permitted Web traffic

    Reserve WAF rules for decisions that require routes, methods, content, rates or coordinated behaviour.

  3. 3

    Measure before enforcement

    Start new rules in monitor or dry-run mode, then review legitimate matches.

  4. 4

    Escalate at the correct layer

    Block sources at the firewall, request behaviours at the WAF and bandwidth floods upstream.

Verify the protection instead of trusting the configuration

A successful reload proves only that the syntax was accepted. Verify that unwanted requests stop before expensive application work, legitimate journeys still complete and server pressure returns toward its normal baseline. Compare the same measurements from before and after the rule, then keep watching long enough to see whether the campaign changes sources or routes.

  • Confirm that required ports remain reachable and unnecessary services remain closed.
  • Check WAF or rate-limit logs for the host, path, action and reason that matched.
  • Test normal browsing, login, checkout, API and monitoring flows from outside the server.
  • Compare Web worker CPU, request latency, queue depth, error rate and database activity with the pre-change sample.
  • Review false positives before turning a temporary incident rule into permanent policy.
Share LinkedIn X
Questions

Frequently asked questions

What is the main difference between a WAF and a firewall?

A network firewall controls connections using information such as source and destination addresses, ports, protocols and connection state. A Web application firewall inspects HTTP requests sent through an allowed Web service. It can make decisions using the host, path, method, headers, parameters, request body, rate and behaviour. Most public Web servers need both because they solve different parts of the traffic path.

Can a firewall stop a Layer 7 DDoS attack?

A firewall can block known hostile addresses or limit certain connection patterns, but a Layer 7 attack uses HTTP or HTTPS ports that the website must keep open. When many sources send permitted-looking requests, application-aware controls are needed to identify the shared path, rate or behaviour. If the attack saturates bandwidth, mitigation must also occur upstream of the server.

Does a WAF replace a network firewall?

No. A WAF protects Web requests but does not replace network segmentation, port policy or access restrictions for SSH, databases, mail and other services. The network firewall should reduce the exposed surface first. The WAF should then inspect traffic that is intentionally allowed to reach HTTP and HTTPS services. Combining both controls avoids forcing either layer to make decisions without enough context.

Can a WAF stop every DDoS attack?

No. A WAF is useful for application-layer floods when it can inspect requests and act before expensive application processing. It cannot restore bandwidth after a volumetric attack has saturated the network connection. It can also produce false positives if rate or behaviour rules are copied without a baseline. Effective protection combines upstream capacity, network controls, request inspection and careful monitoring.

Should WAF rate limits be enabled immediately?

Use monitor or dry-run mode first whenever the server still has enough capacity. Measure ordinary peaks for each important route, review which clients would match and allowlist only systems you can verify. Then enable enforcement narrowly and watch customer journeys, error rates and application latency. An arbitrary global threshold can cause more disruption than the attack it was meant to contain.

Put your servers on autopilot.

Connect a server in about a minute. The first week is on us.