VPNGeek
Purchase
Guides FIREWALLS & ROUTERS

MikroTik RouterOS: site-to-site IKEv2 tunnel to a VPNGeek gateway

RouterOS 7IKEv2CLI 15 min · Updated Jun 2026

Build a policy-based IKEv2 IPsec tunnel from a MikroTik RouterOS 7 device to a VPNGeek gateway — peer, identity, proposals, policy, and the NAT-bypass rule that makes traffic flow.

This guide connects a LAN behind a MikroTik RouterOS 7 router to a VPNGeek gateway with a policy-based IKEv2 tunnel. RouterOS builds IPsec from small, composable objects — a peer, an identity, proposals, and a policy — so the order matters. The steps use the CLI because it is unambiguous, but each command maps to a tab under IP > IPsec in WinBox.

Before you start

Collect these before you begin. A single mismatched parameter will hold the tunnel in negotiation.

  • A VPNGeek plan that includes IPsec Gateways, and admin access to the dashboard.
  • Admin access to a MikroTik device running RouterOS 7.
  • A static public IP or resolvable DDNS hostname on the WAN.
  • Non-overlapping subnets — for example 10.20.0.0/16 on the VPNGeek side and 192.168.20.0/24 behind the MikroTik.

1. Create the tunnel in VPNGeek

In the dashboard open Gateways > Tunnels and add a new site-to-site tunnel. Enter the MikroTik WAN address as the peer and the local/remote subnets. The dashboard returns the values to mirror on RouterOS:

peer_address: 203.0.113.50 # MikroTik WAN IP
gateway_address: 198.51.100.60 # VPNGeek gateway
local_subnet: 10.20.0.0/16 # VPNGeek side
remote_subnet: 192.168.20.0/24 # MikroTik LAN
ike_version: 2
enc_algorithm: aes-256
hash_algorithm: sha256
dh_group: modp2048 # group 14
psk: (shown once)
Note. The pre-shared key is displayed only once. Copy it into your password manager before leaving the page — you cannot read it again afterwards, only regenerate it.

2. Create the profile and proposal

The profile holds phase 1 (IKE) parameters; the proposal holds phase 2 (ESP) parameters. Create both first so the peer and policy can reference them.

# Phase 1 profile
/ip ipsec profile
add name=vpngeek-p1 hash-algorithm=sha256 \
enc-algorithm=aes-256 dh-group=modp2048 lifetime=8h

# Phase 2 proposal
/ip ipsec proposal
add name=vpngeek-p2 auth-algorithms=sha256 \
enc-algorithms=aes-256-cbc pfs-group=modp2048 lifetime=1h

3. Configure the peer and identity

The peer points at the VPNGeek gateway and uses the profile from step 2. The identity carries the authentication — here a pre-shared key.

# Peer — the VPNGeek gateway, IKEv2
/ip ipsec peer
add name=vpngeek address=198.51.100.60 profile=vpngeek-p1 \
exchange-mode=ike2

# Identity — PSK authentication for that peer
/ip ipsec identity
add peer=vpngeek auth-method=pre-shared-key \
secret="<your-psk>"

4. Add the policy

The policy is the phase 2 selector — it decides which traffic is encrypted and sends it to the peer. The src/dst addresses must mirror the VPNGeek subnets exactly.

/ip ipsec policy
add peer=vpngeek tunnel=yes \
src-address=192.168.20.0/24 \
dst-address=10.20.0.0/16 \
proposal=vpngeek-p2 \
action=encrypt
Warning. Mismatched selectors are the top cause of "tunnel up, no traffic". The src-address/dst-address here must be the exact mirror of the local/remote subnets on the VPNGeek side.

5. Add the NAT-bypass rule

RouterOS masquerades LAN traffic out the WAN by default, which would rewrite the source before the policy can match. Add an accept rule in the NAT chain, placed above the masquerade rule, so VPN traffic is excluded.

# Exclude tunnel traffic from NAT — must sit ABOVE masquerade
/ip firewall nat
add chain=srcnat action=accept place-before=0 \
src-address=192.168.20.0/24 \
dst-address=10.20.0.0/16
Note. Order matters in the NAT chain. If the masquerade rule runs first, the source IP is rewritten and the IPsec policy never matches. Use place-before to force the accept rule to the top.

6. Verify the tunnel

From the VPNGeek dashboard the tunnel should reach ESTABLISHED within about 30 seconds. Confirm from the MikroTik side:

# Phase 1 — look for an established SA to 198.51.100.60
/ip ipsec active-peers print

# Phase 2 — installed SAs and byte counters
/ip ipsec installed-sa print

# Policy state — ph2-state should be "established"
/ip ipsec policy print

# prove traffic flows from the LAN side
/ping 10.20.0.1 src-address=192.168.20.1

Troubleshooting

Stuck negotiating / no active peer

Check the log with /log print where topics~"ipsec". A stuck phase 1 is almost always a PSK, enc-algorithm, hash, or dh-group mismatch, or UDP 500/4500 blocked on the WAN. Confirm the profile and proposal match the VPNGeek side.

Peer up but no traffic

Usually the NAT-bypass rule is missing or below the masquerade rule, or the policy src/dst do not mirror the remote side. Check the policy's ph2-state and confirm the accept rule sits above masquerade.

Tunnel drops after the lifetime expires

Set matching lifetimes on both peers and enable DPD on the profile (dpd-interval) so a dead tunnel is detected and re-keyed cleanly.

Did this guide get you connected?