Skip to content

Private networking between sites without a cloud backbone

Part 6 of the bare-metal series. How to connect your own sites into one private network with free software and ordinary internet links: WireGuard tunnels between sites, one tunnel interface per tunnel so ordinary routing can choose between paths, BGP or OSPF with BFD for failover, two independent uplinks per site, MTU and MSS set on purpose, routed links instead of stretched Layer 2, and controlled failover drills before you depend on it. As of 29 November 2026.

By Nishant Gauraw, NG-NeXTPublished Updated 14 min read

This is part 6 of the open series on running distributed bare metal with zero cloud dependence on mostly free software. Part 1 chose the platform, part 2 and part 3 brought DNS in house, part 4 designed offsite backups, and part 5 covered monitoring and alerting without a SaaS. Several of those designs work best when your sites can reach each other privately, and part 4 says so directly. This chapter is about how.

In a hyperscaler, the provider's backbone carries traffic between regions, and inter-region transfer is commonly metered per gigabyte, depending on the provider, service and contract. On your own hardware, you build that private network yourself, over the internet links you already buy. Done well, it can be inexpensive, and the tunnels and routing policy are under your control; the internet paths underneath are not, so performance depends on your uplinks. Done carelessly, it is the part that takes everything down at once.

The design in one paragraph#

Give every site two independent internet uplinks. Between each pair of sites that need to talk, run encrypted tunnels, one tunnel per uplink pair you want to use. Put the routers in pairs too if a router failure should not take a site offline. Treat each tunnel as an ordinary routed link with its own small subnet. Run a routing protocol over the tunnels, add BFD so that failures are detected fast, and let the routing protocol move traffic when a link fails. Keep Layer 2 inside each site. Set MTU and MSS on purpose. Then test failover before you rely on it.

Encryption: WireGuard as the default#

WireGuard is a good default for site-to-site tunnels between Linux routers, BSD firewalls and many network appliances. It has been part of the mainline Linux kernel since version 5.6 (released March 2020), its configuration is small, and it is free software. Its own documentation calls the core idea cryptokey routing: each peer has a public key and a list of AllowedIPs, and the interface uses that list both to choose which peer an outgoing packet goes to and to accept or drop an incoming packet by its source address.

IPsec (for example strongSwan on Linux) is still the right choice when the other end is a vendor appliance that only speaks IPsec. The routing design below carries over if the IPsec is route-based, with tunnel interfaces (for example XFRM or VTI interfaces, or GRE over IPsec), rather than policy-based; the WireGuard-specific details do not. For MTU and MSS on GRE and IPsec tunnels, see our GRE/IPsec MTU guide.

Gotcha 1: one WireGuard interface per tunnel#

This is where many first attempts at dynamic routing over WireGuard go wrong.

On a single WireGuard interface, AllowedIPs decides which peer gets each packet, and one destination lookup selects one peer. If you put two remote sites as peers on one interface and both should be able to carry the same destination, for example a backup path to a third site, changing the next hop in your routing table does not move the traffic: on that shared interface, WireGuard's own table still decides. You could rewrite AllowedIPs from a script when paths change, but that adds a second control plane.

The clean pattern is:

  • one WireGuard interface per tunnel, that is per remote site and per uplink pair;
  • one peer on each interface;
  • a small point-to-point subnet on each tunnel for the routing protocol's neighbours.

Before you widen AllowedIPs, turn off automatic routes. If you use wg-quick, set Table = off on these interfaces. The wg-quick manual says that the default, auto, adds routes to the default table and enables special handling of default routes, and that off disables route creation altogether. With 0.0.0.0/0 or ::/0 in AllowedIPs and no Table = off, wg-quick uses policy routing to send your default traffic into the tunnel, and you can lose remote access. Make the first change from a console.

With routes turned off, AllowedIPs on each single peer can be wide, often 0.0.0.0/0, ::/0, because the routing protocol, not WireGuard, decides what goes where. A narrower list also works, but it must cover the tunnel addresses, every prefix you might route over the tunnel and, for OSPF, its multicast and link-local addresses. Know what you give up with a wide list: WireGuard then accepts any source address from that peer, so add firewall rules or reverse-path filtering on each tunnel interface for the sources you expect.

Gotcha 2: keepalives and NAT#

If one end of a tunnel sits behind NAT, the NAT mapping can expire when the tunnel is quiet. The WireGuard documentation describes PersistentKeepalive for this case and gives 25 seconds as a sensible interval. Set it on the side behind NAT. Between two sites with public addresses, it is usually not needed, although a routing protocol's hellos and BFD packets keep the tunnel busy anyway.

Routing: BGP or OSPF, with BFD#

Both protocols work over tunnels, and both are available as free software in FRRouting and BIRD.

  • OSPF is the simpler choice for a handful of sites under one administration. Configure the tunnels as point-to-point network type so that there is no designated-router election, and keep a single area until you have a reason to split it.
  • BGP takes more configuration, but gives you explicit control over which paths are preferred, clean filtering of what each site may announce, and an easy way to grow. Many operators run private AS numbers between their own sites. RFC 6996 reserves 64512–65534 for private use, and 4200000000–4294967294 in the 32-bit range.

Whichever you choose, add BFD (RFC 5880). Routing protocols notice a dead neighbour through their own hello and hold timers, which can be tens of seconds by default. BFD is a light hello protocol designed to detect a failed path quickly, and both FRR and BIRD can tie it to OSPF and BGP sessions. Detection time is the negotiated interval times the multiplier: FRR documents defaults of 300 ms and 3, which is under a second once the session is up (RFC 5880 keeps the transmit interval at one second or more until then). Do not set the timers too aggressively over the internet: a little packet loss on one uplink should not make routes flap, so a detection time of a few seconds is often the better trade.

Two rules that save trouble:

  • Filter what you accept. With BGP, accept from each neighbour only the prefixes you expect from it, including any transit you intend, such as a backup path to a third site. A mistake at one site should not become a routing problem at all of them. OSPF cannot filter this way inside one area, because every router in the area sees the same link-state database, so keep OSPF for small networks you control fully.
  • Never learn the underlay over the overlay. Do not accept a default route, or any prefix that covers a remote tunnel endpoint's public address, over the tunnels. If a tunnel's own packets are routed into a tunnel, it collapses.
  • Prefer, do not rely on, a path. Set preferences (OSPF costs, BGP local preference or AS-path prepending) so that the normal path is the one you want, and the backup only carries traffic when it must. Set and check them in both directions: local preference steers your outbound choice, prepending only influences the other side, and equal-cost multipath can put traffic on the backup unless you rule it out.

Tunnels are only as independent as the links under them. Two uplinks from the same carrier, through the same building entry, or behind the same upstream router, can fail together. When you buy the second link, ask about the physical path and the upstream provider, not just the speed.

Run a tunnel over each uplink, so that each pair of sites has at least two tunnels that do not share a link. The routing protocol and BFD then handle the failover. Watch for one detail: the tunnel's own packets to the remote endpoint must leave through the right uplink. A plain host route is not enough, because if it is withdrawn when uplink A goes down, the lookup falls back to the default route through uplink B. On Linux, a common pattern is a distinct FwMark on each WireGuard interface, with an ip rule that sends that mark to a per-uplink routing table ending in an unreachable default. Also remember that WireGuard updates a peer's endpoint from the packets it receives, so the remote side may follow traffic to a new source address.

If you run more than one tunnel between two sites, traffic can return on a different tunnel from the one it left on. Strict reverse-path filtering (rp_filter=1) and some stateful firewalls drop such packets, so check those settings on every router.

MTU and MSS, set on purpose#

WireGuard adds 60 bytes of overhead when the outer packet is IPv4 and 80 bytes when it is IPv6: the outer IP header (20 or 40 bytes), UDP (8), a 16-byte data message header and a 16-byte authentication tag. On a 1500-byte path, 1420 is therefore the common tunnel MTU, and it is safe for either outer family. Some uplinks, such as PPPoE, are smaller than 1500 (commonly 1492), so measure the path and subtract the overhead rather than assume 1420.

Set the MTU explicitly on every tunnel, clamp TCP MSS on the routers that forward into the tunnels, and test with do-not-fragment pings of the largest size that should fit. Pings check the MTU, not the MSS: to check clamping, capture a TCP SYN and SYN-ACK through the tunnel. Our GRE/IPsec MTU guide explains why the MSS has to be right in both directions.

Keep Layer 2 inside each site#

It is tempting to stretch a VLAN between sites so that a virtual machine can move without changing its address. Avoid it if you can. A stretched Layer 2 segment carries broadcast storms, loops and duplicate addresses from one site to another, and it makes the services on that segment depend on the tunnel.

Prefer routed links between sites, and design services to move by IP routing or DNS. If you truly need Layer 2 across sites, for example during a migration, use a standards-based overlay such as VXLAN with an EVPN control plane, keep it as small as possible, and plan when it goes away.

Mesh VPNs: in my view, for people, not for the core#

Products and projects such as Tailscale, ZeroTier and Nebula build a mesh between many devices. They are convenient for admin laptops and remote engineers. For the routed core between your own sites, my view is that plain tunnels with a routing protocol are easier to reason about during an outage.

If you use a mesh, check every part it depends on: control plane, relays, identity and DNS. Headscale is an open-source, self-hosted implementation of the Tailscale control server; its README describes it as aimed at a single tailnet for personal use or a small open-source organisation, and its documentation explains how to run your own DERP relays instead of relying on Tailscale's. ZeroTier's controller can be self-hosted, but read its licence: the controller code is source-available, and commercial use needs a separate licence. A self-hosted ZeroTier controller also still relies on ZeroTier's public root servers unless you replace them with your own. Nebula has no central controller: you run your own certificate authority and lighthouses. Otherwise, your private network depends on someone else's service, which is the dependence this series is trying to remove.

Keys and access#

  • Generate each WireGuard private key on the router that uses it, and keep it there. For basic WireGuard authentication only public keys need to be shared; if you also use optional preshared keys, both ends need them, so provision those through your secrets process.
  • Keep tunnel configuration in version control without private or preshared keys.
  • Plan key rotation so it cannot cause an outage. An interface has one private key, and adding a second peer with the same AllowedIPs moves those addresses off the working peer at once. A safe pattern is to bring up a parallel interface with a new key, port and tunnel subnet, let routing move to it, then remove the old interface; or move traffic to the other uplink's tunnel and change keys in a maintenance window.
  • Filter what can arrive through a tunnel. A tunnel to another site is still a path into this one.

Watch it, then break it on purpose#

Using the monitoring stack from part 5, add alerts on:

  • each routing protocol neighbour going down;
  • each BFD session going down;
  • WireGuard handshakes older than a few minutes on tunnels that should be carrying traffic, and peers that never completed a handshake (wg show reports the latest handshake per peer; an idle peer can have an old handshake and still be healthy, but a tunnel carrying routing hellos or BFD should not);
  • packet loss and latency on each tunnel, measured from both ends.

Then test, as a controlled drill. Use a maintenance window, keep console or out-of-band access in case the tunnel is your management path, and confirm that the backup path is up before you start. Take one uplink down at a site, and check that traffic moves to the other tunnel, that the alert fires, and that traffic comes back when the uplink returns. Do the same for one tunnel, and for one router if the site has a redundant pair. Write down how long each failover took. Repeat after every routing change, and on a schedule.

Tests still to run#

This chapter is design guidance from upstream documentation. Nothing here has been run as a lab by NG-NeXT for this post. Before anyone presents these steps as tested:

  • Build two sites with two uplinks each, one WireGuard interface per tunnel, Table = off (needs Nishant's test).
  • Run OSPF or BGP with BFD over the tunnels and measure failover time when one uplink is pulled (needs Nishant's test).
  • Confirm that each tunnel stays on its own uplink when the other uplink fails, using FwMark and per-uplink tables (needs Nishant's test).
  • Verify the calculated tunnel MTU for each path with do-not-fragment pings over a real internet path, including a PPPoE link if available (a 1492-byte PPPoE path gives 1412 with an IPv6 outer header or 1432 with IPv4), and verify MSS clamping with a SYN/SYN-ACK capture and a real TCP transfer (needs Nishant's test).
  • Rotate one WireGuard key with the parallel-interface method without dropping traffic (needs Nishant's test).
  • Confirm rp_filter and firewall behaviour with asymmetric return paths across two tunnels (needs Nishant's test).

Evidence#

As of 29 November 2026. We did not build or test these configurations for this post.

ClaimStatusBasis
WireGuard is in the mainline Linux kernel since 5.6; cryptokey routing uses each peer's AllowedIPs for outgoing selection and incoming acceptanceVerified against a primary sourceWireGuard 1.0.0 announcement for Linux 5.6 (wireguard mailing list, March 2020); wireguard.com home page; WireGuard whitepaper section 2
PersistentKeepalive is for peers behind NAT or stateful firewalls; 25 seconds suggestedVerified against a primary sourcewireguard.com quick start, wg(8) manual
wg-quick's default Table = auto adds routes to the default table with special handling of default routes; Table = off disables route creationVerified against a primary sourcewg-quick(8) manual and wg-quick source
WireGuard overhead is 60 bytes over IPv4 and 80 bytes over IPv6, so 1420 is the common MTU on a 1500-byte pathVerified against a primary sourceWireGuard protocol page and mailing list: outer IP (20/40) + UDP (8) + 16-byte data header + 16-byte tag
On one interface, a destination lookup in AllowedIPs selects one peer; routing-table next hops do not change itVerified against a primary sourceWireGuard whitepaper section 3; kernel allowedips implementation
So routing-protocol failover between peers is cleanest with one interface per tunnelReported, not reproducedDesign conclusion drawn from the above; common operating practice, not lab-tested here
A wide AllowedIPs lets a peer send any source addressVerified against a primary sourceWireGuard whitepaper section 2
FRR BFD defaults (300 ms intervals, multiplier 3)Verified against a primary sourceFRRouting BFD documentation
Private AS ranges 64512–65534 and 4200000000–4294967294Verified against a primary sourceRFC 6996
BFD purpose and designVerified against a primary sourceRFC 5880
FRRouting and BIRD support OSPF, BGP and BFDVerified against a primary sourceFRRouting and BIRD documentation
Headscale is an open-source, self-hosted implementation of the Tailscale control server, scoped to a single tailnet; DERP relays configurableVerified against a primary sourceHeadscale GitHub README and DERP documentation
ZeroTier controller is source-available and needs a commercial licence for commercial useVerified against a primary sourceZeroTierOne nonfree/LICENSE.md
Route-based IPsec is needed for the routed designVerified against a primary sourcestrongSwan route-based VPN documentation
Design advice (two independent uplinks, routed links over stretched Layer 2, filtering, failover tests)Reported, not reproducedCommon operating practice; not lab-tested for this post

FAQ#

Do I need a cloud provider's backbone to connect two data centres?#

No. Encrypted tunnels over ordinary internet links, with a routing protocol on top, give you a private network between sites. What you give up is the provider's managed, usually more predictable backbone, so you plan for that with two independent uplinks per site and with failover you have tested.

Why not run every site as peers on one WireGuard interface?#

WireGuard decides which peer gets a packet from the AllowedIPs of the peers on that interface, and one destination lookup selects one peer. Changing the next hop in the routing table does not change that choice, so a routing protocol alone cannot fail traffic over from one peer to another on a shared interface (a script that rewrites AllowedIPs could, but that is another moving part). Use one WireGuard interface per tunnel, that is per remote site and uplink pair, each with one peer, so each tunnel is an ordinary routed link.

BGP or OSPF between my own sites?#

Both work over tunnels. OSPF is simpler for a handful of sites under one administration. BGP gives you more control over which paths are preferred and is easier to scale and filter as the network grows. Whichever you choose, add BFD so that a dead tunnel is noticed within about a second with typical default timers (FRR's documented defaults are 300 ms intervals with a multiplier of 3), or within a few seconds with the gentler timers that suit internet links, rather than after the routing protocol's own hold timers.

What MTU should I set on a WireGuard tunnel?#

WireGuard adds 60 bytes of overhead over IPv4 and 80 bytes over IPv6, which is why 1420 is the common setting on a 1500-byte path. Set it explicitly on every tunnel, clamp TCP MSS on the routers, and test with do-not-fragment pings, because the underlay path can be smaller than 1500.

Should I stretch a VLAN between sites?#

Avoid it if you can. A stretched Layer 2 segment carries broadcast storms and loops from one site to another. Routed links between sites, with services designed to move by IP or DNS, fail in a smaller way.

Is a mesh VPN like Tailscale, ZeroTier or Nebula a good fit?#

For laptops and admin access they are convenient. For site-to-site routing between your own routers, plain tunnels with a routing protocol are easier to reason about. If you use a mesh product, run its control plane and relays yourself where you can. Headscale, a self-hosted Tailscale control server, describes itself as aimed at a single tailnet for personal use or a small open-source organisation, and Tailscale clients still use Tailscale's DERP relays unless you configure your own. ZeroTier's self-hosted controller has its own licence terms for commercial use, and still uses ZeroTier's public root servers unless you run your own, so read up first.

How often should we test failover?#

At least after every change to the routing configuration, and on a schedule, such as quarterly. Run it as a controlled drill: in a maintenance window, with console or out-of-band access in case the tunnel was your management path, confirm that the backup path is up, then take one uplink or one tunnel down on purpose and check that traffic moves, that monitoring alerts, and that it comes back. Pulling a link does not test silent or partial failures such as packet loss, so add those to the drill over time.

Has NG-NeXT tested the configurations in this guide?#

No. This chapter describes design rules and upstream guidance. The checklist at the end lists what would need to be run in a lab before any of it is presented as tested.

References#

Next in the series: identity and single sign-on without a SaaS identity provider.

The know-how in this series stays open. If you want a private network between your sites designed or built with you, with failover planned and tested, NG-NeXT does consulting and turnkey builds. Tell us what you run today through the contact page.

— Nishant Gauraw, Founder and CEO, NG-NeXT Tech

Talk to us directly.

We reply within one business day. The site assistant answers when it is available.