Skip to content

Load Balancing

Overview

Durantic's Load Balancing features — VIPs, Routes, and Route Policy Sets, grouped under Load Balancing in the dashboard — are built on BGP (Border Gateway Protocol). Each Durantic agent runs an embedded BGP speaker that peers with other agents in the same mesh, enabling dynamic route advertisement, failover, and traffic engineering.

BGP integration is automatic — when machines join a mesh network, they establish BGP sessions with their peers and begin exchanging routes. You can then create VIPs or Routes to advertise specific IPs or network prefixes, attach health checks, and apply route policies to control traffic flow.

VIPs and Routes

Durantic provides two types of BGP advertisements, each managed on its own page under Load Balancing in the main menu:

Type Page Purpose Use Case
VIP (Virtual IP) Load Balancing → VIPs Advertises a single IP address with optional health checks Floating IPs for high availability — the IP moves to a healthy machine if the primary fails
Route Load Balancing → Routes Advertises a network prefix for static routing Exposing a subnet behind a machine, such as a local network or container CIDR

VIPs

A VIP advertises a single IP address (a /32 route) and optionally ties it to a health check. If the health check fails, the machine withdraws the route and another machine advertising the same VIP takes over. This provides automatic failover without external load balancers.

See the VIPs page for details on creating VIPs, configuring health checks, and the holdoff setting.

Routes

A Route advertises a network prefix (for example, 192.168.1.0/24). This is useful when a machine acts as a gateway to a local network and you want other machines in the mesh to know how to reach that network. Routes do not have health checks — they are announced from any enabled, assigned machine.

See the Routes page for details on creating routes and assigning machines.

Health Checks

VIP announcements can be tied to health checks that determine whether the VIP should be advertised. A VIP is only announced to peers when its health check passes. If the check fails, the VIP is withdrawn.

Durantic supports three health check types:

Check Type Description
TCP Attempts a TCP connection to a specified host and port. Passes if the connection succeeds.
HTTP Sends an HTTP request to a URL. Passes if the response status code is in the expected range.
gRPC Performs a gRPC health check against a service endpoint.

HTTP and gRPC checks also have TLS variants (HTTPS, gRPCs).

Health check behavior is configurable:

Setting Description
Interval How often the check runs
Timeout Maximum time to wait for a check to complete
Healthy threshold Number of consecutive successes before the VIP is announced
Unhealthy threshold Number of consecutive failures before the VIP is withdrawn

Route Policy Sets

Route policy sets give you fine-grained control over how routes are accepted, modified, and distributed. A policy set is an ordered list of rules, each with match conditions and actions.

Route policy sets

Match Conditions

Each rule can match routes based on:

Condition Description
Prefix list Match routes whose destination is one of the listed prefixes, exactly. With a prefix length range, also match more-specific prefixes inside a listed prefix whose length is in the range (see below)
Community Match routes tagged with specific BGP community values
AS path regex Match routes whose AS path matches a regular expression

Actions

When a rule matches, it can modify the route attributes:

Action Description
LOCAL_PREF Set the local preference value to influence path selection (higher is preferred)
MED Set the Multi-Exit Discriminator to influence inbound path selection from external peers
Communities Add, remove, or replace BGP community tags on the route
AS prepend Prepend AS numbers to the AS path to make a route less preferred

A prefix-list entry without a length range matches only that exact prefix: 10.78.0.0/24 matches 10.78.0.0/24, not 10.78.0.0/16 and not 10.78.0.128/25. To match more-specific prefixes, give the rule a length range: a minimum alone means minimum to /32, a maximum alone means the entry's own length to the maximum. A range must lie between an entry's own length and /32; since the range belongs to the rule and the length to each entry, it can suit one entry and not another. How an unusable entry, or a prefix-list rule with no prefixes, is handled depends on where the policy set is attached: in a machine's export policy only that entry is skipped (the agent logs a warning for it) and the rule's other entries still apply, while a rule with no prefixes matches nothing; on an external BGP peer the whole policy is refused and the peer is not brought up. The matching itself is the same in both places.

Import and Export Policies

Policy sets are applied in two places:

  • A machine's export policy — Applied to the routes this machine itself originates: its VIPs and Routes. The policy decides which of them are announced, to the mesh and to the machine's external BGP peers, and with which attributes. It does not apply to anything else the machine passes on: mesh reachability, transit and VIP transit re-announcements are never filtered by it, so an export policy cannot cut a machine off from the mesh.
  • An external BGP peer's import and export policies — The import policy is applied to routes received from that peer, before they are used; the export policy to routes sent to it. Routes a peer sends can carry communities and an AS path, so community and AS-path rules apply there.

Mesh members have no import policy. To make mesh members prefer a machine, give that machine's export policy a higher local preference: it is set on the routes the machine originates (its VIPs and Routes), and mesh members choose between machines by local preference. MED and communities set by the export policy travel with those routes as well, but only external BGP peers that receive them act on them. Where several machines originate the same route with equal local preference, each receiver balances across up to three of them, weighted by measured path quality; a machine that originates the prefix itself uses its own route and ignores the others.

In a machine's export policy only prefix-list and match-any rules can match the machine's own routes; community and AS-path rules never do, because an originated route carries no communities or AS path yet. With a default action of Reject, an own prefix that no rule accepts is not announced at all, and the agent logs a warning naming the prefix and the rule or default action that withheld it. That warning is logged again when what withholds the prefix changes (including when the rule is only renumbered, but not when the same rule number or the default action still withholds it, for example in another policy set or after an edit to that rule), when the prefix is withheld again after having been announced, each time the agent starts, each time BGP is disabled and re-enabled on the machine, and each time the prefix is removed from the configuration and added back. The default action applies to a policy set in advanced mode, whether or not it has rules: an advanced-mode set with no rules and a default action of Reject withholds every own prefix. A simple-mode policy set, which only sets a local preference, accepts every route whatever its default action says.

Upgrade note. Agents released before this change differ in five ways:

  • They matched a prefix-list entry against any prefix whose network address fell inside it. For example 10.0.0.0/8 with Action: Reject used to withhold an own route 10.1.2.0/24, and now announces it; 10.100.0.0/16 with Action: Accept and a local preference of 200 used to give an own 10.100.0.5/32 that preference, and now does not.
  • They announced an unmatched own prefix even with a Reject default.
  • They honoured a length range that starts below an entry's own length. For example 10.9.0.0/16 with Action: Reject and a minimum length of 8 used to withhold an own 10.9.1.0/24; such an entry is now unusable and skipped (with a warning). Its rule's other entries are still checked; if none matches, the prefix falls through to the later rules and the default action, and with an Accept default and no other matching rule it is announced.
  • They ran the machine's mesh reachability routes (the /32 of each mesh peer) through the machine export policy too: a Reject rule covering mesh addresses withheld them, and a local preference (from simple mode or a rule) was set on them. The export policy no longer applies to them, which can change mesh path selection and transit preference.
  • They read a community only in the asn:value form: they dropped a well-known name such as no-export or a decimal value, and from a comma-joined entry such as 65000:100,65000:200 they sent the first community. Agents with this change send well-known names and decimal values, so a no-export that did nothing before now applies and the machine's routes stop beyond the peer's AS; a comma-joined entry is skipped with a warning.

For every own prefix whose outcome differs from the earlier agents' (announced or withheld, and the local preference, MED and communities it carries, with communities compared as the values each agent sends), the agent logs an upgrade warning naming the prefix, both outcomes and both deciding rules. Unlike the withheld-prefix warning above, only the outcomes decide whether the upgrade warning is new: it is logged again when either outcome changes and when a difference goes away and comes back, but not when the deciding rule is only renumbered or reworded. The upgrade warning is kept in memory, so it is also logged again, for every prefix that still differs, each time the agent starts, each time BGP is disabled and re-enabled on the machine, and each time the prefix is removed from the configuration and added back. A length range on the entry (for example minimum 16, maximum 32 for 10.100.0.0/16) keeps the old meaning for prefixes inside the entry; the old matching also matched a shorter own prefix whose network address lay inside the entry, which no range reproduces. Check the warnings rather than relying on the rewrite.

Viewing the RIB

The Routing tab on a machine's detail page shows the machine's Routing Information Base (RIB) — all BGP routes known to this machine.

Machine routing tab

The RIB view includes:

Column Description
Destination The network prefix
Best path Highlighted to indicate the currently active route
Quality indicators Visual indicators of route health and preference
AS path The sequence of autonomous systems the route traverses
Communities BGP community tags attached to the route

Each route row is expandable to reveal alternative paths. When multiple paths exist for the same destination, you can see why the best path was selected and what alternatives are available.

Transit Routing

When two machines in a mesh cannot establish a direct WireGuard connection (for example, due to restrictive NAT on both sides), Durantic can route traffic through a third peer that has connectivity to both.

Transit routing is automatic. The agent detects when a direct path is unavailable and finds an intermediate peer to relay traffic. In the Peers tab, transit connections are displayed with a Transit path type, making it clear which connections are relayed.

Transit routing ensures full mesh connectivity even in challenging network environments, at the cost of slightly higher latency for the relayed connections.