Appearance
Connect a MikroTik router over WireGuard
Routers join Hive-Sync over WireGuard to two hubs. Both tunnels are up at the same time so that losing one hub does not cut the router off. See Hubs and redundancy.
Before you start
- RouterOS 7.20 or later.
- Hive-Sync gives you, for your tenant: the two hub endpoints, the two hub public keys, and an address for this router on each tunnel.
- Safe access to the router. Use the self-undo pattern below for every change.
The examples use documentation addresses and placeholder names. Replace them with the values from your onboarding details.
Steps
Set a self-undo timer first. Before changing anything, schedule a rollback so a mistake does not lock you out. For example, export the current configuration, then add a one-shot scheduler that restores it in ten minutes. Cancel the scheduler only after you have confirmed the tunnels are up.
/export file=before-hive-syncCreate the WireGuard interface. Let RouterOS generate the key pair, then read the public key to give to Hive-Sync.
/interface wireguard add name=hive-wg1 listen-port=13231 comment="hive-sync: tunnel - link to hub 1" /interface wireguard printSend the interface public key to Hive-Sync. Never send the private key.
Add the hub as a peer.
/interface wireguard peers add interface=hive-wg1 \ public-key="<hub-1-public-key>" \ endpoint-address=hub1.example.com endpoint-port=51820 \ allowed-address=203.0.113.1/32 persistent-keepalive=25s \ comment="hive-sync: tunnel - hub 1 peer"Give the tunnel an address.
/ip address add address=203.0.113.10/30 interface=hive-wg1 \ comment="hive-sync: tunnel - address toward hub 1"Repeat for hub 2 with its own interface (
hive-wg2), key pair, peer and address.Allow the tunnels in the firewall. Allow WireGuard UDP from the hubs on the input chain, and allow RADIUS and management traffic from the hub addresses only. Put these rules above any drop rule and give them comments that start with
hive-sync:.Confirm both tunnels.
/interface wireguard peers print detailEach peer should show a recent
last-handshake.Remove the self-undo scheduler once both handshakes are recent and Hive-Sync shows the router as connected to both hubs.
Check
- Two peers with handshakes under two minutes old.
- Hive-Sync lists the router with hub 1 and hub 2 both up.
- Every object you created has a comment that starts with
hive-sync:.
If it fails
- No handshake: check that the router can reach the hub endpoint on UDP, and that the hub has your interface public key.
- Handshake but no traffic: check
allowed-addressand the tunnel address, and the firewall rule order. - Locked out: wait for the self-undo timer to restore the saved configuration.
Hive-Sync automating this join is Coming soon. Today you apply the steps above or an onboarding script that Hive-Sync provides.