A real branch WAN through an ISP that won't route your private LANs: GRE tunnels carry the traffic, IPsec encrypts them, and OSPF runs on top so every site learns the others automatically. This lab builds an HQ hub and two branches on RouterOS 7 — the twin of the Cisco GRE-over-IPsec lab, done the MikroTik way.
Why not just IPsec? Because policy-based IPsec alone can't easily carry a routing protocol — OSPF uses multicast, which plain IPsec tunnels won't transport. Wrap the traffic in GRE first and you get a real point-to-point interface that carries anything, including OSPF's multicast hellos; then IPsec encrypts the GRE. On RouterOS the encryption is almost free: the GRE interface takes an ipsec-secret and auto-builds the IPsec policies for you. Run OSPF over the GRE tunnels and each site learns every other site's LAN with no static-route bookkeeping.
This is the exact pattern of the Cisco GRE-over-IPsec lab — hub-and-spoke tunnels, encrypted, with a dynamic routing protocol on top. HQ is the hub with a tunnel to each branch; branches tunnel only to HQ. (For a many-branch version without per-tunnel config, see the WireGuard hub-and-spoke.)
01
The hub builds one encrypted GRE interface toward each branch, each with a small transit subnet. ipsec-secret turns on the encryption without a single manual IPsec policy.
# One GRE per branch; ipsec-secret auto-creates the IPsec that protects it. /interface gre add name=gre-b1 remote-address=198.51.100.2 local-address=203.0.113.1 ipsec-secret="Str0ng-B1!" add name=gre-b2 remote-address=198.51.100.3 local-address=203.0.113.1 ipsec-secret="Str0ng-B2!" # A tiny transit /30 on each tunnel for OSPF to run over. /ip address add address=172.31.1.1/30 interface=gre-b1 add address=172.31.2.1/30 interface=gre-b2
Two things bite here. GRE isn't TCP or UDP — it's IP protocol 47 — so if either side is behind a firewall/NAT, you must permit protocol 47 and the IPsec transports (UDP 500/4500, ESP), not just "open a port." Second, GRE + IPsec adds significant header overhead; the tunnel's usable MTU drops well below 1500, and if you don't lower it, large packets fragment or black-hole (the dreaded "ping works, file transfers hang"). Set the GRE interface MTU sensibly (≈1400) and consider mss-clamp so TCP negotiates a size that fits. This overhead trap is identical on Cisco.
02
Each branch is the mirror: one encrypted GRE back to HQ, the other end of the transit /30. Copy it per site, changing only the addresses and secret.
/interface gre add name=gre-hq remote-address=203.0.113.1 local-address=198.51.100.2 ipsec-secret="Str0ng-B1!" /ip address add address=172.31.1.2/30 interface=gre-hq # Same secret as HQ's gre-b1, mirrored endpoints. Branch 2 mirrors gre-b2.
03
Now the payoff. Run OSPF on the GRE interfaces and each site's LAN is learned everywhere — add a third branch later and its subnet just appears, no static routes to edit.
/routing ospf instance add name=v7 router-id=10.0.0.1 /routing ospf area add name=backbone area-id=0.0.0.0 instance=v7 /routing ospf interface-template add interfaces=gre-b1,gre-b2 area=backbone cost=10 network-type=ptp add interfaces=bridge-lan area=backbone cost=10 passive # advertise the LAN, don't peer on it # Branches run the mirror: OSPF on gre-hq + their own LAN (passive).
Two small settings that matter. Mark the LAN interface-template passive so OSPF advertises the LAN subnet but never tries to form an adjacency with a host down there (and can't be tricked into one by something on the LAN). Set the GRE tunnels to point-to-point (ptp) network type — they're literally point-to-point links, and ptp skips DR/BDR election for faster, simpler adjacencies. These are the same choices the Cisco lab makes; good hygiene on any tunnel-based WAN.
04
Walk it in layers: GRE up, IPsec actually encrypting it, OSPF adjacent, LANs learned, and a LAN-sourced ping across.
/interface gre print # tunnels running (R flag) /ip ipsec active-peers print # auto-built SAs established /routing ospf neighbor print # both branches Full /ip route print where ospf # 10.1.0.0/24 and 10.2.0.0/24 learned /ping 10.1.0.1 src-address=10.0.0.1 # HQ LAN -> Branch 1 LAN
Takeaways
ipsec-secret on the GRE auto-builds the IPsec policies.NOCTIS builds encrypted, dynamically-routed branch WANs on MikroTik and Cisco across Crete — GRE/IPsec or WireGuard overlays where new sites drop in cleanly and OSPF handles the rest.
Book a Discovery Call →