Kontakt

MikroTik WireGuard Site-to-Site VPN für Multi-Site-ISPs

Startseite / Blog

9 Min. Lesezeit
ZILL E ALINovember 9, 2026Mikrotik

Getting a MikroTik WireGuard site to site VPN right the first time saves hours of troubleshooting later.

A MikroTik WireGuard site to site tunnel is usually the fastest way to connect two ISP locations on RouterOS. It is lighter than IPsec, the config is short, and RouterOS v7 has had native WireGuard support for a while now. But two problems show up constantly once you move past a single-peer test lab: adding dual WAN PCC load balancing on top of the tunnel, and losing access to WinBox or WebFig on the remote router once the tunnel comes up. Both are live questions on the MikroTik forums right now, and both come down to a handful of specific config details that are easy to miss the first time.

This guide walks through a working, production-tested setup for a multi-site ISP: the base tunnel, dual WAN load balancing without breaking the handshake, and the exact fix for the WinBox/WebFig access gap. By the end you will have a tunnel that survives real traffic, not just a ping test.

Voraussetzungen

  • RouterOS v7.x on both ends (WireGuard has been part of the kernel since v7.0, but use a current stable release)
  • Two sites, each with its own MikroTik router acting as the tunnel endpoint
  • Dual WAN on at least one end (this guide assumes dual WAN at the hub site, single WAN at the branch, which is the most common real-world case)
  • A static public IP, or at minimum a predictable DDNS hostname, on each WAN you want the tunnel to use
  • Admin access to both routers, ideally via a console or out-of-band connection the first time you touch the tunnel (so a mistake in the firewall or routing table does not lock you out)

Basic MikroTik WireGuard Site to Site VPN Setup

Start with the simplest working tunnel between two routers before layering anything else on top. Every WireGuard interface needs a private key, and every peer needs the other side’s public key and allowed address range.

On the hub router:

/interface wireguard add name=wg-branch1 listen-port=13231 private-key="<hub-private-key>" /ip address add address=10.90.0.1/30 interface=wg-branch1 /interface wireguard peers add interface=wg-branch1 public-key="<branch-public-key>" \ allowed-address=10.90.0.2/32,192.168.20.0/24 \ endpoint-address=branch1.yourdomain.com endpoint-port=13231 \ persistent-keepalive=25s

On the branch router, mirror it:

/interface wireguard add name=wg-hub listen-port=13231 private-key="<branch-private-key>" /ip address add address=10.90.0.2/30 interface=wg-hub /interface wireguard peers add interface=wg-hub public-key="<hub-public-key>" \ allowed-address=10.90.0.1/32,192.168.10.0/24 \ endpoint-address=hub.yourdomain.com endpoint-port=13231 \ persistent-keepalive=25s

Add routes so each side knows how to reach the other’s LAN over the tunnel:

/ip route add dst-address=192.168.20.0/24 gateway=wg-branch1 ;# on the hub add dst-address=192.168.10.0/24 gateway=wg-hub ;# on the branch

Set persistent-keepalive on both ends, not just one, especially if either side sits behind NAT. Without it, NAT mappings time out and the tunnel appears to hang until traffic restarts it. 25 seconds is the usual safe value; you rarely need to go lower.

At this point, a ping from the hub LAN to the branch LAN (and back) should work. Confirm that before moving on, because every problem below assumes the base tunnel is already solid.

MikroTik WireGuard site to site VPN topology: hub with dual WAN PCC on ISP-A and ISP-B, tunnel 10.90.0.0/30 to the branch, linking 192.168.10.0/24 and 192.168.20.0/24
Hub with dual WAN PCC and a single WireGuard tunnel to the branch.

Adding PCC-based dual WAN load balancing

The question that comes up constantly on the MikroTik forums right now is how to add dual WAN PCC (Per Connection Classifier) load balancing on top of a WireGuard site-to-site VPN. The key thing to understand is that PCC load-balances outbound sessions by WAN interface, and your WireGuard interface does not care which physical WAN the UDP packet that carries it actually goes out on, as long as routing sends it somewhere that reaches the internet.

There are two different things people usually mean when they say “dual WAN with WireGuard,” and they need different setups:

  1. Load-balance the WireGuard tunnel’s own outbound traffic across two WANs for redundancy (if WAN1 drops, the tunnel should still come up over WAN2).
  2. Load-balance everything else (general LAN traffic going to the internet) across two WANs, while the WireGuard tunnel itself still needs a single, predictable path so the remote peer’s endpoint-address keeps resolving.

For case 2, which is the far more common real setup, keep PCC marking general traffic as usual, but explicitly exclude WireGuard UDP traffic from the PCC mangle rules so it always follows a fixed route (its own routing-mark or a plain static route to a chosen WAN). Something like this in /ip firewall mangle, placed above your PCC rules:

/ip firewall mangle add chain=prerouting protocol=udp dst-port=13231 action=mark-routing \ new-routing-mark=to-wan1 passthrough=no comment="WireGuard fixed path" add chain=prerouting protocol=udp src-port=13231 action=mark-routing \ new-routing-mark=to-wan1 passthrough=no comment="WireGuard fixed path"

For redundancy instead (case 1, failing the tunnel itself over to WAN2 if WAN1 dies), use /tool netwatch or a recursive gateway check on WAN1, and have a second WireGuard peer entry pointed at the branch’s WAN2 address as a backup endpoint, or script a routing-mark swap on failure. A single peer cannot have two live endpoints simultaneously, so true automatic failover needs either a second peer/interface pair or a script that rewrites the endpoint-address on WAN1 failure.

Either way, keep PCC’s own two-rule classifier (by src-address, dst-address, or both, depending on what you are balancing) exactly as it is for normal traffic. The only change is making sure WireGuard’s own UDP conversation is not caught up in that classifier and bounced between WANs mid-session, which breaks the handshake.

Fixing local service access over the tunnel

This is the other thing people keep hitting: the tunnel comes up, routing works, LAN-to-LAN traffic passes fine, but WinBox and WebFig on the remote router itself are unreachable from the other side. The tunnel is not broken; this is almost always one of three things.

1. The router’s own services are not listening on the WireGuard interface’s address. By default WinBox/API/WebFig listen on all interfaces, but if you have an /ip services entry restricting by address, or an available-from list, it will silently exclude the WireGuard subnet unless you add it.

2. The input chain firewall is blocking it. Most production MikroTik firewalls drop everything in the input chain that is not explicitly allowed. If your “accept established/related, accept from LAN, drop everything else” rule set does not also accept from the WireGuard interface/subnet, WinBox traffic destined for the router itself (not routed through it) gets dropped before it reaches the service.

/ip firewall filter add chain=input in-interface=wg-branch1 action=accept \ comment="Allow management over WireGuard" place-before=0

3. The allowed-address on the peer entry is too narrow. If allowed-address on either peer only lists the far LAN subnet and not the router’s own tunnel IP (the /32 of the other end), WireGuard’s own cryptokey routing will not accept packets destined for that router’s tunnel address, and traffic aimed at managing the router itself gets silently dropped at the WireGuard layer, before it ever reaches the firewall. This is the single most common cause of “LAN-to-LAN works, but I can’t reach the router itself over the tunnel.”

Go back and check the earlier config: both peer entries above already include the far router’s own /32 tunnel address in allowed-address alongside the LAN subnet. If you set this up without that /32, add it now and the router’s own services should become reachable immediately, with no other change needed.

Common mistakes and troubleshooting

  • Clock skew. WireGuard’s handshake is time-sensitive. If either router’s clock is badly off (common on a router that just rebooted and has not reached NTP yet), the handshake can silently fail. Check /system clock and make sure NTP is configured on both ends.
  • MTU problems. WireGuard adds overhead per packet. If you are tunneling over a PPPoE WAN (common for ISPs) the effective path MTU is already reduced, and stacking WireGuard on top can push you into fragmentation issues that look like “slow” or “some things work, some don’t.” Try lowering the WireGuard interface’s MTU to 1420 as a starting point if you see intermittent failures on larger transfers.
  • Checking tunnel status. /interface wireguard peers print shows the last handshake time for each peer. If it is not updating, you have a reachability or key mismatch problem before you even get to routing.
  • Wrong public/private key pairing. Easy to mix up when generating keys for multiple sites. Always confirm with /interface wireguard print on each side that the public key you pasted into the peer entry on the other router actually matches.
  • NAT between the WireGuard peers. If either endpoint sits behind NAT without a forwarded UDP port matching listen-port, the handshake from the other side will never arrive. Port-forward the WireGuard UDP port if the router is not directly on a public IP.

FAQ

Kann ich mehr als zwei Standorte auf demselben Hub‑Router betreiben?
Ja. Fügen Sie pro entferntem Standort einen WireGuard‑Peer zur einzigen WireGuard‑Schnittstelle des Hubs hinzu (WireGuard unterstützt mehrere Peers auf einer Schnittstelle, im Gegensatz zu einem typischen Punkt‑zu‑Punkt‑IPsec‑Tunnel), jeweils mit einem eigenen erlaubten Adressbereich und einer Route.

Unterstützt WireGuard automatisch ein vollständiges Mesh zwischen den Zweigstellen?
Nein. Standardmäßig ist diese Konfiguration Hub‑and‑Spoke: Zweigstellen erreichen einander über die Routing‑Tabelle des Hubs, nicht direkt. Ein vollständiges Mesh erfordert einen Peer‑Eintrag zwischen jedem Paar von Standorten, was bei mehr als ein paar Standorten schwer zu verwalten wird.

Ist WireGuard tatsächlich sicher genug für Produktions‑ISP‑Verkehr?
Ja. Es verwendet moderne, gut geprüfte Kryptografie (ChaCha20, Poly1305, Curve25519) und hat eine deutlich kleinere Angriffsfläche als die Verhandlungsprotokolle von IPsec. Die praktischen Risiken im Produktionseinsatz sind fast immer Konfigurationsfehler (offene erlaubte Adressbereiche, fehlende Firewall‑Regeln), nicht das Protokoll selbst.

Fazit

Ein MikroTik‑WireGuard‑Site‑to‑Site‑Tunnel ist unkompliziert, sobald die Basis‑Konfiguration stimmt, aber zwei Dinge entscheiden, ob er Produktionsverkehr übersteht: die UDP‑Konversation des Tunnels aus Ihrem PCC‑Load‑Balancing‑Classifier herauszuhalten, damit der Handshake nicht zwischen WANs hin‑und‑her springt, und die eigene Tunnel‑Adresse jedes Routers einzubeziehen in allowed-address damit der Verwaltungszugriff über den Tunnel tatsächlich funktioniert. Wenn Sie diese beiden Details korrekt umsetzen, ist der Rest (Routing, Firewall, Keepalives) Routine. Testen Sie zuerst den Basis‑Tunnel, fügen Sie anschließend das Dual‑WAN hinzu und bestätigen Sie den WinBox\/WebFig‑Zugriff, bevor Sie ihn als produktionsreif deklarieren.

Geschrieben von

ZILL E ALI

MTCNA- und MTCRE-zertifizierter Netzwerkingenieur und ISP-Infrastrukturspezialist sowie Gründer von Developer Zon. Schreibt hier über MikroTik, Cisco, ISP-Infrastruktur und gelegentlich über Build-Logs.

Antwort hinterlassen

Diese Seite verwendet Akismet, um Spam zu reduzieren. Erfahren Sie, wie Ihre Kommentardaten verarbeitet werden.