KORTHVEILSecurity firewall
Guides

Site mesh: connect your offices by joining a code

Download as PDF All guides

The site mesh connects your Korthveil firewalls with encrypted WireGuard tunnels, without typing a single key or tunnel address. One firewall, normally the head office, is the controller. Every other office joins with a one-time code from it. After that:

  • every site gets a mesh address (IPv4 and IPv6) and the routes to every other site's networks;
  • sites talk to each other directly, or through the controller when they have no public address;
  • a new office is known to all the others within a minute;
  • VPN › Site mesh on the controller shows every site and every link's health.

Each change on a firewall is its own commit, listed in its revision history as site mesh. The controller can only change the tunnels of the other sites, never their rules, zones or other settings.

The example:

Head office (controller) hq, internet zone wan, public name hq.example.com, LAN 192.168.1.0/24 and fd00:1::/64
Branch leeds, LAN 192.168.3.0/24 and fd00:3::/64
Shop shop-york, behind its provider's carrier-grade NAT, LAN 192.168.3.0/24
Mesh networks 10.255.0.0/24 and fd6b:7673::/64 (the defaults)

Before you start

  1. Korthveil on every site, with the site mesh add-in installed. Each firewall needs its internet line and its internal networks set up.
  2. Every site needs its own networks. Two offices that both use 192.168.1.0/24 cannot be joined: renumber one of them first. The controller refuses a network another site already has.
  3. A reachable controller. The other sites must reach the controller from the internet, by a fixed address or a name:
    • a fixed public address, or a Dynamic DNS name (Network › DNS › Dynamic DNS);
    • if a router sits in front of the controller, forward TCP 51821 and UDP 51822 to it.
  4. Not in FIPS mode. WireGuard is not FIPS approved. On a firewall in FIPS mode, use IPsec site-to-site tunnels (guide IPsec site-to-site).

Create the mesh on the head office

Open System › Wizards › Site mesh on hq, or VPN › Site mesh › Create a mesh here.

  1. Create or join: choose Create a mesh here (controller).
  2. This site:
    • Site name: hq;
    • Networks the other sites may reach here: the wizard fills in your internal networks, IPv4 and IPv6. Remove any that the other sites should not reach;
    • Zones that may reach the other sites: tick lan (and any other internal zone);
    • Internet zone: tick wan. The mesh ports open there only.
  3. Mesh:
    • Controller address: hq.example.com;
    • leave the ports and the mesh networks at their defaults, unless they clash with a network you use. The mesh networks cannot be changed once sites have joined;
    • Full mesh (recommended) or Hub and spoke. See Full mesh or hub and spoke.
  4. Review:
    • the wizard lists what changes: the add-in, a zone sites for the mesh interface kvmesh0, and rules between lan and sites both ways;
    • on the controller, a rule sites > sites lets it pass traffic between sites that cannot reach each other directly;
    • Apply commits. Confirm within 5 minutes, or everything goes back by itself.

Add a site

  1. On the controller, open VPN › Site mesh.
  2. Under Add a site, enter a label such as Leeds (optional), and press Create a join code.
  3. Copy the code with Copy, or keep the QR code on screen. The code:
    • works once, within 24 hours;
    • tells the new site where the controller is, and carries the fingerprint (pin) of the controller's certificate, so the new site talks only to your controller.
  4. On the new site (leeds), open System › Wizards › Site mesh and choose Join a mesh with a code.
  5. This site: check the Site name, the networks, the zones that may reach the other sites, and the internet zone.
  6. Mesh: paste the code, and press Check the controller. It should say that the controller answers and its certificate matches the code.
  7. Review:
    • the wizard makes the site's WireGuard key pair (the private key stays on this firewall) and joins the controller. The controller gives the site its mesh address, such as 10.255.0.2 and fd6b:7673::2;
    • Apply commits, then confirm.

Within a minute:

  • leeds appears as online on the controller;
  • the controller and every other site add their tunnel to it.

If you go back from the review without applying, the site is already known to the controller: remove it there, and create a new code.

Manage your sites from the head office

The controller can also be the site manager: one screen with every site's health, version and logs, and a list of attackers blocked at every site. The tunnel does everything: nothing is set up by hand on the sites, and nothing more is opened to the internet.

Turn it on

  • When you create the mesh: in the wizard's Mesh step, tick Manage the sites from here (ticked by default).
  • On a mesh you already have: on VPN › Site mesh, under Site manager, press Manage the sites, then commit.
The site manager on the controller
The site manager on the controller

Either way, the review lists two changes:

  • the manager, on TCP port 51823, opened only in the zone sites. It is reached only through the tunnels;
  • the syslog server add-in, listening on TCP in the zone sites, so the sites' logs are kept on the controller.

What a site does when it joins

From then on, a join code does three things in one commit on the new site:

  1. The tunnel, as before.
  2. Management: the site's Korthveil Central agent enrolls with the controller's manager through the tunnel:
    • the site makes its own key, and the manager signs a certificate for it, valid one year. The private key never leaves the site;
    • the enrollment token in the join answer works once, only for this site, within 24 hours.
  3. Logs: a log destination site-manager sends the site's logs to the controller's mesh address over TCP. The tunnel encrypts them. Logs never cross the internet as plain syslog.
The join wizard on a new site: what the manager may do
The join wizard on a new site: what the manager may do

In the wizard's Mesh step, the site's own administrator decides:

  • Let the controller manage this site, if it offers to (ticked by default). Untick it to set up only the tunnel;
  • It may change settings (ticked by default). Each change from the manager is a confirmed commit, and rolls back by itself if the manager cannot reach the site afterwards;
  • It may reboot this firewall (not ticked by default);
  • SentinelOps keeps its authority, shown only when SentinelOps manages this firewall with more than read-only (ticked by default). Unticked, SentinelOps becomes read-only while the manager is on, so two managers never change settings at once.

The manager can never change who manages a site: the site's Korthveil Central and site mesh settings stay the site's own. To stop being managed, switch the Korthveil Central add-in off on the site, or remove the site on the controller.

Sites that joined before the manager was on show as not managed. To manage one, remove it on the controller and join it again with a new code.

The managed sites

Under Site manager, each site is one line:

  • reporting (a report in the last 3 minutes) or silent;
  • its Korthveil version, the running configuration revision, and how long it has been up;
  • the time of its last report;
  • what the site allows: settings allowed or view only, and reboot allowed;
  • how many of its add-ins are not healthy, and which;
  • Logs: opens Monitoring › Logs & audit › Syslog server with that site's logs (the sender is the site's mesh address).

A site that is silent for 10 minutes raises an alert on the controller, under the bell. Its tunnel, its internet line or the firewall itself may be down. The link matrix shows the tunnel's last handshake.

One site's logs on the controller
One site's logs on the controller

Baselines: the settings every site must have

A baseline is a named list of settings, each with the value it must have, for example everything a customer's sites must keep the same. Each site checks itself against its baseline every 15 minutes, and Drift shows which sites differ.

Make a baseline (under Baselines on VPN › Site mesh on the controller, with the manager on):

  1. Press New baseline. Name it, for example Customer A standard.
  2. Tick the sites that follow it. A site follows one baseline.
  3. Add items. For each, give the path of the setting and what it must be:

    • exactly this value: /system/changeControl/requireComment must be true;
    • one of these values: /modules/ips/settings/mode must be prevent | prevent-strict;
    • a number in a range: /system/audit/retentionDays minimum 90. A rule is picked by its name: /policy/rules/name=Block telnet/enabled must be true.
  4. Press Save to pending changes, then review and commit.

Some settings are each firewall's own and cannot be in a baseline: the host name, the web console settings, the interfaces, and the failover, Central management, SentinelOps, UPS and site mesh add-ins. In a failover pair or cluster, these are exactly the parts cluster sync never copies.

Read the drift. Each managed firewall is one row:

  • Baseline: meets the baseline, N items differ, checking… or check failed, with the time of the check and the site's revision;
  • Since approved: what changed on the site since its last approved configuration (for example a local change made at the site). Press Approve current configuration to accept the site as it is now;
  • Last push: the last push, undo or approval, and its result.

A setting that holds a password or key is shown as secret, not compared: secrets never leave the site.

Push the baseline to a site. Nothing is ever pushed by itself:

  1. Press Check now if the report is old, then Review and push. The differing items are listed with the site's value and the baseline's.
  2. Write a change note (at least 10 characters, for example Customer A standard (CHG-1042)). It goes into the site's revision history.
  3. Press Test on the site only to have the site validate the change without applying it, or tick Commit these values and press Push.

The site applies the push at its next heartbeat (within a minute), through its own commit pipeline, as a confirmed commit: if the change cuts the site off from the manager, it rolls back by itself. A push needs the site's own administrator to have allowed remote apply when it joined. Undo last push puts the site's values from before the push back the same way.

In a failover pair or cluster, push to the active member: the standby member refuses the push, and cluster sync copies the change to it.

Block an attacker at every site

Under Blocked at every site on the controller:

  1. enter the address or network, such as 203.0.113.7 or 198.51.100.0/24 (IPv4 or IPv6), and why;
  2. press Block at every site, then commit.
Blocked at every site
Blocked at every site

Within a minute, every site in the mesh drops traffic from and to that address, and so does the controller:

  • traffic through the firewall, both ways;
  • connections to the firewall itself, and from it.

Each site commits the list as its own change, listed in its history as site mesh.

A site never blocks its own networks, the mesh, or a network of its own interfaces (the management network among them). It skips such an entry and keeps the rest. On the controller, such an entry is refused at commit.

Unblock removes an entry everywhere at the next commit.

Logs from other firewalls (pfSense, FortiGate and others)

The controller's syslog server also collects logs from firewalls of other brands, and shows pfSense and FortiGate logs as events: action, addresses, ports and rule. Korthveil watches these firewalls; it never changes them.

Send their logs through a tunnel, in this order of preference:

  1. The site-to-site tunnel the site already has to the head office (IPsec or WireGuard). Point the firewall's remote syslog at the controller's internal address, over TCP or UDP. The tunnel encrypts it.
  2. A new IPsec tunnel to the controller, if there is none (guide IPsec site-to-site).
  3. TLS syslog (TCP 6514) to the controller's public address, only when no tunnel is possible. Turn on TLS on the syslog server and open it only in the internet zone, for those senders' addresses. Never send plain UDP syslog over the internet.

pfSense: Status › System Logs › Settings › Remote Logging Options:

  • tick Enable Remote Logging;
  • Remote log servers: the controller's internal address and port, such as 192.168.1.1:514;
  • Remote Syslog Contents: Everything, or at least Firewall Events.

FortiGate: Log & Report › Log Settings › Send logs to syslog, with the controller's internal address. Over a tunnel, set the source interface or address of the tunnel in the CLI: config log syslogd setting, set source-ip <the FortiGate's tunnel address>.

On the controller, Monitoring › Logs & audit › Syslog server then lists each sender, and Vendor shows pfSense or FortiGate for their events.

VPN › Site mesh

On the controller

  • This site: its name, mesh address, how many sites are online, and the topology version.
  • Add a site: join codes, with the open codes listed.
  • Sites:
    • State: online when the site checked in during the last 3 minutes;
    • Public address: where the other sites reach it. A site without one (behind carrier-grade NAT, or not seen yet) shows the address the controller saw, marked not public. It reaches the other sites through the controller;
    • its networks, mesh address, last pull, and the topology version it has applied;
    • Rotate keys: the site makes a new key pair at its next pull, and every other site follows at theirs. On the controller's own row, the controller makes a new pair at once;
    • Always through the controller: the site reaches the others only through the controller. Use it for a site whose public address does not accept connections;
    • Remove: the site's credential stops working at once, and every site drops its tunnel to it within a minute.
  • Site manager and Blocked at every site: see Manage your sites from the head office.
  • Link matrix: each row is what one site reports about the others: the time of the last WireGuard handshake. Hover a cell for bytes received and sent and the address in use.
    • green: a handshake in the last 3 minutes;
    • red: older, or never;
    • via hq: the pair goes through the controller.
  • Peers: the controller's own tunnels, live.
  • Settings: the networks this site offers, the internet zones, the controller's address and the topology. Save puts them in pending changes; commit as usual.

On a member

  • Controller: its address, the last pull, any error, and the address the controller sees this site at.
  • Peers: every tunnel with its state, endpoint, the networks it carries, the last handshake, and the traffic.
  • Settings: the networks this site offers (the controller checks them at the next pull), the internet zones, and an optional public address.

Full mesh or hub and spoke

  • Full mesh (the default):
    • every site has a tunnel to every other site that it can reach, so branch-to-branch traffic does not cross the head office;
    • a site without a public address, such as shop-york behind carrier-grade NAT, still connects out to the sites that have one;
    • two sites that both lack a public address reach each other through the controller.
  • Hub and spoke: every site has one tunnel, to the controller, which passes traffic between them. Choose it when only the head office may have connections from the internet, or to send all traffic between sites through the head office's security services.

How it works

  • Joining:
    • the new site sends its public key, name, networks and WireGuard port to the controller, over HTTPS pinned to the certificate in the code;
    • the controller checks that the networks overlap no other site, gives the site its mesh addresses, and returns a site credential;
    • the controller keeps only fingerprints (hashes) of codes and credentials, never the values.
  • Following: every 60 seconds each site reports to the controller (its tunnels' handshakes and traffic, its networks), then asks for the topology.
    • When something changed, it commits its own new tunnels: peers, endpoints, and routes for IPv4 and IPv6.
    • It checks every topology first. No tunnel may claim this site's own networks, any of its interfaces' networks (the management network included), its mesh address, or the internet (0.0.0.0/0, ::/0). A topology that does not pass is refused, and the controller is told why.
  • If the controller is down, the tunnels keep running with the last topology. Only changes wait until it is back. VPN › Site mesh says so, and the add-in's health shows degraded after 3 minutes.
  • Keepalives: sites send one every 25 seconds, so tunnels through NAT stay open.

Troubleshooting

Symptom Check
Check the controller says it cannot be reached The controller's TCP port 51821 must be open from the internet: the internet zone ticked in the controller's settings, and the port forwarded on any router in front of it
"The controller's certificate does not match the pin" The code was not made by this controller, or the controller's add-in data was erased. Create a new code on the controller
"The join code is not valid, was used already, or expired" Codes work once, within 24 hours. Create a new one
"… overlaps … of site …" Two sites use the same network. Renumber one, or leave that network out of Networks the other sites may reach here
"Too many failed attempts" Ten wrong codes or credentials from one address lock it out for 15 minutes
A site stays offline On that site, VPN › Site mesh › Controller shows the last error. Its outbound connections to the controller's port 51821 must be allowed (in outbound filter mode, the automatic rules allow them)
Online, but the link matrix shows never between two sites UDP 51822 does not get through to either site. Open it in the internet zone, forward it on any router in front, or press Always through the controller for one of the two sites
Tunnels are up, but nothing passes The rules between your zones and sites: the wizard adds them both ways. On the controller, the rule sites > sites is needed for sites that go through it
"The controller no longer knows this site" The site was removed on the controller. Join again with a new code
A site stays not managed It joined before the manager was on, or its administrator unticked management. Remove it on the controller and join it again with a new code
A managed site is silent but its tunnel is up On the site, System › Add-ins › Korthveil Central shows the last error. The Korthveil Central add-in must be on
No logs from a site On the controller, the syslog server must listen on TCP in the zone sites (the Site manager panel says when it does not). On the site, Monitoring › Logs & audit › Audit log › Remote syslog shows the site-manager destination's state

Download as PDF All guides