E-01 firewall: web access only from Cloudflare networks

15 IPv4 prefixes, the exact existing firewall and a separate boot loader. Actual application and disposable VM cold-boot proof are distinct.

Streams from a cloud pass through a gate; a separate green path leads to the server.
Streams from a cloud pass through a gate; a separate green path leads to the server.

Opening the origin only to Cloudflare

The educational E-01 already has protected HTTPS and a verified adoption journal. The next step is to allow incoming IPv4 connections to TCP 80 and 443 only from Cloudflare networks. This changes the firewall on the origin itself. This run created no DNS records or Cloudflare routes; site access through the edge has not yet been tested.

The rules use 15 official IPv4 ranges: two official Cloudflare HTTPS sources returned the same set. This is an explicit list for this plan, rather than permission to trust any address bearing the Cloudflare name. Updating it will require a new check and an agreed transition.

Cloudflare: IP Ranges

Permission inside the existing firewall

E-01’s existing parent firewall is the e01_host table, with SSH and WireGuard management access. The new state adds one named cf_web counter and one rule for each of the 15 prefixes. Each rule restricts the incoming interface, IPv4 source and TCP ports 80 and 443 together. Rules precede the final drop; the rest of the parent model remains exact.

The anonymized standard nft fragment below is neither the actual execution command nor a complete file. Replace the angle-bracket placeholders only after reading your own ruleset. No broad flush is needed: the change must concern only the permitted addition.

# nft grammar fragment, not a complete firewall or a shell command.
# Replace every placeholder after inspecting the exact existing parent.
# Create one named counter; insert one rule for each reviewed IPv4 prefix.
add counter inet example_host cf_web
insert rule inet example_host input handle <DROP_HANDLE> \
  iifname "<UPLINK>" ip saddr <CLOUDFLARE_IPV4_PREFIX> \
  tcp dport { 80, 443 } counter name cf_web accept

An accept in a separate base chain does not guarantee passage: another base chain on the same hook may drop the packet. Drop ends its processing. Adding an independent permissive firewall alongside the existing one is therefore insufficient. Here, permission sits inside the verified parent chain before its denial, while SSH and WireGuard are not rebuilt.

Netfilter: Configuring chains

Application on the real E-01

On E-01, planning, application, built-in fresh verification, separate verify and exact replay succeeded. Each complete observation also performed 8 checks of existing HTTPS. Separate verification and replay made no durable writes. All 14 original files were preserved; original journals were not rewritten.

The new state includes a separate journal and a new systemd drop-in for loading the firewall. A daemon-reload was performed, but no services were restarted or reloaded. E-01 itself was not rebooted. Existing SSH/WireGuard rules and the original configuration, unit and helper files remained unchanged.

Why persistence after boot needs its own check

A correct current ruleset does not establish that the same protection will appear after reboot. Loading order needs a separate check: first the complete permitted model, then dependent services start. An active status alone does not show table contents.

The standard fragment below shows the actual systemd drop-in structure with an anonymized loader name. It is not a complete installer. For this oneshot service, Requires combined with After requires the firewall loader to finish successfully before the dependent service starts. After alone specifies ordering but does not require the dependency to start successfully.

# Standard systemd drop-in fragment; the loader name is anonymized.
[Unit]
Requires=example-firewall-boot.service
After=example-firewall-boot.service

I tested this part on a separate disposable Debian VM. Cold boot created the complete expanded table before systemd-networkd.service, ssh.service and ssh.socket started. In the final VM check, all three were actually active after the loader. This is VM boot evidence, not a report of an E-01 reboot.

Refusals and rollback on the separate VM

VM packet probes allowed only IPv4 traffic from the selected Cloudflare networks to TCP 80 and 443. Other IPv4 sources, IPv6, port 8081 and UDP 443 stayed closed. An initial unfiltered path check established that these refusals came from the firewall rather than a broken test route.

A foreign counter, a parent-only table instead of the complete expected state, and another network namespace caused refusals without writes. A separate exclusive table-creation race test also refused atomically. Exact-state verification does not try to repair unknown rules.

Rollback on this VM removed only its Cloudflare rules, counter and drop-in, restoring the original effective loader command and parent ruleset. All 14 original files were preserved; no services were restarted. The VM was shut down normally after the checks.

The boundary of this step

E-01 now has an accepted exact IPv4 firewall addition. Cold-boot and rollback checks have separate VM evidence. Connecting DNS, Cloudflare routes and a real request through the edge remain the next step. Source filtering does not replace TLS verification or authentication, and does not make the origin ready for any hostname.

  1. Operations & Security nftables default-deny without losing server control
  2. Operations & Security HTTPS and a password for E-01: Nginx, Origin CA and Symfony
  3. Platform Engineering The domain and Cloudflare before connecting E-01
  4. Operations & Security Adopting protected HTTPS with the CLI without a restart
  5. Operations & Security Connecting E-01 through Cloudflare while keeping password protection

A project by the author · Weather Solution200

After reading, a look outside.

Temperature, rain and wind in your city. Check the forecast and plan the hours ahead.

Check the forecast
Next article