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

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:

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.

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.

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.

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.

This page on GitHub, at v0.7.0