Getting started#
This guide takes one node from a fresh install to a working standalone firewall. See pairing.md to grow it into an HA pair and operations.md for day-to-day use.
It assumes the usual hardware: a mini PC with two network ports behind a plain switch, with no VLANs. One port is the WAN; the other is the LAN, which is also how you manage the node. A VLAN-aware switch, with management (and in a pair, sync) on networks of their own, is the advanced layout at the end.
Sparewall is pre-release software. Expect rough edges.
Requirements#
| Minimum | Recommended | |
|---|---|---|
| CPU | x86_64, 2 cores | x86_64, 2 cores or more |
| Memory | 2 GiB | 4 GiB |
| Disk | 16 GB | 32 GB |
| Network ports | one, as a VLAN trunk | two or more |
- CPU: the image is built for x86_64 only. The
sparewallCLI also runs on Linux arm64 and macOS, but a node can't. - Memory: a node uses about 0.6 to 0.9 GB, including the kernel's
caches. The pair test suites pass with 1.5 GiB per node, but that
leaves little room. The local Prometheus (
metrics.mode: local) is capped at 512 MB and uses about 50 to 150 MB. - Disk: a node uses about 5 to 7 GB. Of that, about 3 GB holds two
deployments of the OS, the running one and the one to roll back to.
An upgrade downloads the next one before the oldest is removed. The
rest is the container images (0.25 to 0.8 GB), the journal, and the
local Prometheus's data, up to
metrics.retention_size(1 GB by default). - Network ports: any NIC the Fedora kernel supports. The layouts are one port carrying every network as tagged VLANs; two ports, WAN and LAN, with no VLANs; and LACP or active-backup bonds. A pair needs a link between its nodes for sync, either a network of its own or the LAN.
- TPM: optional and recommended. Secrets are sealed to a TPM2 where there is one, and otherwise to a key on the disk.
- Platforms: physical machines, or VMs. The test suites run on QEMU/KVM with virtio NICs; give a libvirt VM a virtual TPM.
1. Get an image#
Images are published to ghcr.io/sparewall/sparewall with testing and
(later) stable tags, signed with the project's cosign key
(cosign.pub):
cosign verify --key cosign.pub ghcr.io/sparewall/sparewall:testing
Each release also has ready-made images, with checksums signed by the same key:
sparewall-VERSION-x86_64.iso: an installer for physical machines. It installs unattended to the first fixed disk it finds (USB sticks are skipped), but only if that disk is blank: no partitions and no filesystem on it. A disk with anything on it stops the install and is left untouched. To install there anyway, wipe it (wipefs -a /dev/sdX), or at the installer's boot menu presseand addsparewall.erase=sdX(ornvme0n1) to thelinuxline: that erases the named disk whatever it holds.sparewall-VERSION-x86_64.raw.zst: a disk image to write to the machine's disk or a USB stick (zstd -dc sparewall-*.raw.zst | sudo dd of=/dev/sdX bs=4M).sparewall-VERSION-x86_64.qcow2: a disk image for VMs.sparewall-VERSION-x86_64-linux.tar.gzandsparewall-VERSION-aarch64-linux.tar.gz: thesparewallCLI for your workstation (a static Linux binary, x86_64 or arm64).sparewall-VERSION-aarch64-darwin.tar.gzandsparewall-VERSION-x86_64-darwin.tar.gz: the CLI for a Mac (Apple silicon and Intel). It is signed ad hoc, not notarized, so macOS quarantines a downloaded copy and refuses to run it; after unpacking, clear that withxattr -d com.apple.quarantine sparewall.
Or install the CLI with Homebrew, on macOS or Linux; it follows releases
with brew upgrade, and needs no quarantine step:
brew install sparewall/tap/sparewall
cosign verify-blob --key cosign.pub --bundle SHA256SUMS.sigstore.json SHA256SUMS
sha256sum -c --ignore-missing SHA256SUMS # on macOS: shasum -a 256 -c --ignore-missing SHA256SUMS
Files named .partNN are pieces of one file: cat them together first.
Or build a disk image yourself with bootc-image-builder:
sudo podman pull ghcr.io/sparewall/sparewall:testing
sudo podman run --rm --privileged --security-opt label=type:unconfined_t \
-v ./output:/output -v /var/lib/containers/storage:/var/lib/containers/storage \
quay.io/centos-bootc/bootc-image-builder:latest \
--type qcow2 --rootfs xfs ghcr.io/sparewall/sparewall:testing
Use --type raw for a USB stick or --type anaconda-iso for an installer.
2. Give the node an identity#
A fresh node needs its name, an admin SSH key and its management NIC:
{"node": "fw1",
"ssh_keys": ["ssh-ed25519 AAAA... you@laptop"],
"management": {"nic": "52:54:00:aa:00:02",
"address": "192.168.1.1/24"}}
The management NIC is the LAN port: the one your workstation's switch is on. The address is the one the LAN will use as its gateway.
The node's name is its hostname too, and the one it has in the
configuration document: up to 31 lowercase letters, digits and -,
starting with a letter and not ending with -. Omit address to use
DHCP on the management port, and vlan if management is untagged.
For a way in at the console before the network is right, add a password
hash for admin, made with openssl passwd -6 (it prompts):
"password_hash": "$6$...". It becomes the cluster's admin password
(operations) unless one is
set already. SSH stays keys-only either way.
- VMs: pass it as the
sparewall.identitycredential (for a VM beside other workloads on one host, see running Sparewall as a VM first). With libvirt, add to the domain XML:xml <sysinfo type='fwcfg'> <entry name='opt/io.systemd.credentials/sparewall.identity'>{"node": "fw1", ...}</entry> </sysinfo>or with QEMU directly:-smbios type=11,value=io.systemd.credential.binary:sparewall.identity=$(base64 -w0 identity.json). Give the VM a fixed MAC (<mac address='52:54:00:aa:00:01'/>). - Physical machines: a seed stick. Put the identity, as
sparewall-identity.yaml(or.json), on a USB stick whose filesystem is labelledSPAREWALL, and plug it in before the first boot:shell sudo mkfs.vfat -n SPAREWALL /dev/sdX1 sudo mount /dev/sdX1 /mnt && sudo cp sparewall-identity.yaml /mnt/ && sudo umount /mntThe node reads it once, and ignores the stick after that. Alternatively, on a console where you can log in as root, runsparewall init --node fw1 --mgmt-nic <MAC> --ssh-key "<key>"(orsparewall init --from identity.yaml).
The node boots into bootstrap mode: only the management port is up
(named mgmt0, or mgmt for a tagged VLAN), SSH is accepted on it for
the admin user, and nothing is forwarded.
ssh admin@192.168.1.1 sudo sparewall status
Until the first configuration serves DHCP, give your workstation an
address on that subnet by hand (192.168.1.10/24).
This first ssh also asks you to accept the node's host key. Do it
before using the sparewall CLI from your workstation: the CLI runs ssh
non-interactively, so it cannot ask, and stops at an unknown host key.
3. Write the configuration document#
Start from examples/two-nic.yaml: the WAN
on one port, and on the other a lan network that is the management
network too. It is in a zone like any other, with DHCP, DNS and policy;
the anti-lockout rule keeps SSH and HTTPS open to the node from it
whatever lan->self says. management.sources names who may use them
(your workstation, by its DHCP reservation); without it, every host on
the LAN can reach the node's SSH and HTTPS (it still needs a key, and the
web UI a login), and validation warns. Use sparewall explain to read
about any field:
sparewall explain networks.users
sparewall explain policy.'users->wan'
Every port must be bound to hardware for this node by permanent MAC (or PCI path), and every network rides on a port role, optionally tagged.
4. Apply it safely#
From your workstation, add a context and apply with a confirm window:
sparewall context add home --host admin@192.168.1.1
sparewall apply -f site.yaml --confirm 120
The CLI shows the diff, applies it, and asks whether to keep it. Your
answer travels over a new connection, so if the change cut you off,
you cannot confirm and it reverts by itself after 120 seconds (or at the
next boot). On a first apply the management port is usually renamed from
mgmt0 to its role name, which may drop the SSH session briefly. The CLI
notices within seconds, reconnects for up to a minute, and asks again
about the pending generation. If it cannot reconnect, run
sparewall status and sparewall confirm <generation> yourself before
the window closes. A longer window (--confirm 300) leaves more room
for that.
Unattended: let the node apply it#
A node can also take its first configuration at install time and apply
it by itself, so it comes up configured with no one at the console. Put
the document next to the identity: sparewall-config.yaml (or .json)
on the seed stick, the sparewall.config credential on a VM, or
sparewall init --config site.yaml on the console.
While the node is in bootstrap mode (generation 0), it applies a
configuration it has not tried before, with a ten-minute confirm window,
and confirms it itself once its health has stayed out of failed for
about fifteen seconds. If health stays failed (a port that does not come
up, say), the window closes and the node returns to bootstrap mode. A
document that is refused (invalid, or not for this node) also leaves it
in bootstrap mode. Either way, sparewall health --verbose says why
under seed, and a corrected seed stick can be put back in. Once the
node is configured, seeds are ignored.
- Bind ports by PCI path (
nic: pci-0000:01:00.0) when the machine's MAC addresses are not known in advance: the path is the same on every unit of one hardware model. - Secrets are not seeded. Set them afterwards with
sparewall secret set; until then, health is degraded where one is missing (backups without a password, say). - Pairs are seeded one node at a time, without
cluster.sync_keys; pairing stays the manual step in pairing, since each node's sync key is generated on the node.
5. Check it#
sparewall status
sparewall health --verbose
sparewall history
Health is ok, degraded (working, but something needs attention) or
failed. The same model answers https://<mgmt address>/readyz.
6. Optionally, turn on the web UI#
A node serves no web UI and no HTTP API until the document turns them on. To try them, turn them on and add a user to sign in as:
sparewall set management.web=true
sparewall user add alice --role operator # asks for the password
Open https://<mgmt address>/ and sign in as alice, or as admin
with the console password.
- Where it's reachable: only on the management network, on the same
port and certificate as the health endpoints. Until
tls.certificateshas amgmtcertificate, the browser warns about the node's self-signed one. - Roles:
viewer,operatororadmin. Each page offers only what the user's role allows. Amonitoruser is for health checks and metrics, and can't sign in to the UI.
See the web UI and HTTP API in operations.md for the pages, users and roles, and for calling the API with a token.
Advanced: a VLAN trunk#
With a VLAN-aware switch, one port can carry every network as a tagged
VLAN, and management can have a segment of its own that no client
reaches: examples/standalone.yaml for a
single node on a trunk, and examples/pair.yaml
for a pair with separate management and sync VLANs. The identity then
names the management VLAN ("vlan": 99), and the management network has
no zone. examples/two-nic-pair.yaml is
the no-VLAN pair: management and sync on the LAN too.