← Back to News

Hands-On RouterOS SD-WAN Cross-Border Networking Optimization: A MikroTik Multi-Link Intelligent Scheduling Configuration Guide

Against the backdrop of accelerating corporate globalization, RouterOS — with its flexible routing policies and script extensibility — has become the soft-router platform most favored by technical teams in the field of cross-border networking optimization. Combined with the intelligent path selection philosophy of SD-WAN, MikroTik devices can build transnational interconnection channels rivaling commercial solutions at extremely low hardware cost. This article will walk you through a complete cross-border SD-WAN configuration, step by step, to achieve automatic multi-link failover and intelligent traffic scheduling.

Core challenges of cross-border networking optimization

Cross-border network communication faces three core bottlenecks: high latency caused by international bandwidth congestion, packet loss caused by insufficient interconnection between carriers, and service interruption caused by single-link failure. Traditional BGP solutions rely on carrier cooperation, entailing long deployment cycles and high costs; meanwhile, application-layer-based proxy solutions introduce additional protocol overhead.

Since version v7.1, RouterOS natively supports SD-WAN policy routing; combined with MikroTik's Netwatch probing and script triggering mechanisms, it can achieve real-time monitoring of link quality and automatic failover. The following table compares the key metrics of mainstream cross-border optimization solutions:

Solution typeTypical latency (China–US)Failover timeAnnual cost (100Mbps)Deployment complexity
Traditional BGP direct connection140-180ms30-90s¥80,000+High
Commercial SD-WAN appliance120-160ms1-5s¥25,000-60,000Medium
MikroTik RouterOS SD-WAN130-170ms0.5-3s¥3,000-8,000Medium
Pure VPN tunnel150-220msManual / no failover¥2,000-5,000Low
CDN / reverse proxy acceleration80-130msDepends on DNS¥15,000-40,000High
Sources: MikroTik official Wiki v7.16 documentation, compilation of community field-test data from 2025

Environment preparation and network topology

This tutorial assumes you have a MikroTik device running RouterOS v7.12+ (CCR2004 or RB5009 series recommended), with two or more international egress links already configured (for example: China Telecom CN2 GIA + China Unicom international leased line + AWS Global Accelerator).

Recommended network topology:

  • Headquarters node (Shanghai): MikroTik CCR2004-1G-12S+2XS, RouterOS v7.14
  • Overseas node (Los Angeles): MikroTik CCR2004-16G-2S+, RouterOS v7.14
  • Link 1: China Telecom CN2 GIA, bandwidth 50Mbps
  • Link 2: China Unicom international leased line, bandwidth 100Mbps
  • Link 3: AWS Global Accelerator (backup), bandwidth 30Mbps

Before starting the configuration, please ensure that the public IP of each link has been correctly assigned and that basic IP reachability between nodes is in place. We will complete the SD-WAN deployment in the following four steps: link binding, quality probing, policy routing, and failover verification.

Step 1: Multi-link aggregation and marking

First, enable Mangle rules on each WAN interface to apply connection marks to outbound traffic, providing a classification basis for subsequent policy routing.

# === RouterOS CLI configuration: connection marking and routing marking ===

# 1. Define WAN interface variables (modify according to actual interface names)
:global wan1 "ether1-cn2"
:global wan2 "ether2-cu"
:global wan3 "ether3-aws"

# 2. Create Mangle rules — mark inbound connections
/ip firewall mangle
add chain=prerouting in-interface=$wan1 connection-mark=no-mark \
    action=mark-connection new-connection-mark=conn-cn2
add chain=prerouting in-interface=$wan2 connection-mark=no-mark \
    action=mark-connection new-connection-mark=conn-cu
add chain=prerouting in-interface=$wan3 connection-mark=no-mark \
    action=mark-connection new-connection-mark=conn-aws

# 3. Create Mangle rules — mark outbound routing
/ip firewall mangle
add chain=prerouting connection-mark=conn-cn2 \
    action=mark-routing new-routing-mark=route-cn2
add chain=prerouting connection-mark=conn-cu \
    action=mark-routing new-routing-mark=route-cu
add chain=prerouting connection-mark=conn-aws \
    action=mark-routing new-routing-mark=route-aws

# 4. Ensure the default routing table includes all WAN gateways
/ip route
add dst-address=0.0.0.0/0 gateway=<CN2-GATEWAY> routing-mark=route-cn2 distance=1
add dst-address=0.0.0.0/0 gateway=<CU-GATEWAY> routing-mark=route-cu distance=1
add 
dst-address=0.0.0.0/0 gateway=<AWS-GATEWAY> routing-mark=route-aws distance=2

The above configuration achieves three-tier traffic isolation: inbound connections on each WAN port are independently marked, and outbound routes go to the corresponding gateway according to the mark. The AWS link's distance is set to 2 to make it a hot standby, automatically taking over only when the primary link is unavailable.

Step 2: Real-Time Link Quality Probing

RouterOS's Netwatch tool can periodically probe the reachability of a remote IP; combined with scripts, it can automatically trigger route switching when link quality degrades.

# === Netwatch probe configuration ===

# Create a Netwatch probe for each link (pointing to the peer public IP)
/tool netwatch
add host=<CN2-REMOTE-IP> interval=5s timeout=3s \
    up-script="/system script run sdwan-cn2-up" \
    down-script="/system script run sdwan-cn2-down"
add host=<CU-REMOTE-IP> interval=5s timeout=3s \
    up-script="/system script run sdwan-cu-up" \
    down-script="/system script run sdwan-cu-down"

# Example link recovery script (when CN2 recovers)
/system script
add name=sdwan-cn2-up owner=admin policy=read,write,test source={
    :log info "SD-WAN: CN2 link restored, re-enabling route"
    /ip route enable [find routing-mark=route-cn2]
}

# Example link failure script (when CN2 fails)
/system script
add name=sdwan-cn2-down owner=admin policy=read,write,test source={
    :log warning "SD-WAN: CN2 link down, failing over to backup"
    /ip route disable [find routing-mark=route-cn2]
}

The probe interval is set to 5 seconds with a 3-second timeout, allowing link failures to be detected and switchover triggered within 8 seconds (one probe cycle + timeout). For latency-sensitive services, Santi Network T3N7 intelligent scheduling engine can be used for second-level RTT sampling to further compress the switchover window.

The following table summarizes the recommended values for each probe parameter:

Service ScenarioProbe IntervalTimeout ThresholdFailure Detection DelayRecovery Detection Delay
VoIP / Video Conferencing2s1s≤3s≤2s
HTTP / API Services5s3s≤8s≤5s
File Transfer / Backup10s5s≤15s≤10s
Email / Non-Real-Time30s10s≤40s≤30s

Step 3: Policy Routing and QoS Optimization

After link marking and probing are complete, policy routing rules need to be configured so that different service traffic takes the optimal path. RouterOS supports multi-dimensional matching based on source address, destination address, protocol type, port number, and more.

# === Policy Routing Configuration ===

# Pin VoIP traffic (UDP/5060, UDP/10000-20000) to the low-latency link
/ip firewall mangle
add chain=prerouting protocol=udp dst-port=5060 \
    action=mark-routing new-routing-mark=route-cn2
add chain=prerouting protocol=udp dst-port=10000-20000 \
    action=mark-routing new-routing-mark=route-cn2

# HTTP/HTTPS traffic preferentially uses the China Unicom link with the largest bandwidth
/ip firewall mangle
add chain=prerouting protocol=tcp dst-port=80,443 \
    action=mark-routing new-routing-mark=route-cu

# QoS queue tree — guarantees minimum bandwidth for VoIP
/queue tree
add name=qos-voip parent=global packet-mark=voip-pkt \
    limit-at=10M max-limit=50M priority=1
add name=qos-http parent=global packet-mark=http-pkt \
    limit-at=30M max-limit=100M priority=3

In actual deployments, we use Santi Network T3N7 intelligent scheduling engine to uniformly model link quality across the entire network, fusing RouterOS local probe data with the cloud RTT matrix to generate a dynamic weighted routing table, reducing cross-border latency by an average of 18%-25%.

Step 4: Failover Verification and Monitoring

After configuration is complete, be sure to perform the following verification steps to ensure the failover mechanism operates reliably:

  1. Manual link-disconnection test: Unplug the network cable from the CN2 line and observe whether the Netwatch log triggers the down-script within 8 seconds and whether traffic automatically switches to the China Unicom link.
  2. Packet loss simulation: Use /tool traffic-generator or an external traffic generation tool to verify under high load whether the QoS queues rate-limit as expected.
  3. DNS redundancy: Configure multiple DNS servers distributed across different WAN links to avoid a DNS single point of failure causing global unavailability.
  4. Log auditing: Enable /system logging add topics=netwatch,script to record all failover events for later analysis.
# Enable SD-WAN related logging
/system logging
add topics=netwatch,script,info action=memory prefix="SD-WAN"
add topics=netwatch,script,warning action=disk prefix="SD-WAN-CRIT" \
    file-name=sdwan-critical

# View recent failover records
/log print where message~"SD-WAN"

By connecting the Grafana + Prometheus monitoring stack to RouterOS SNMP, you can visualize bandwidth utilization, latency jitter and failover counts for each link in real time, building a complete cross-border networking observability system.

Performance Optimization and Best Practices

In actual operations, the following optimization measures can significantly improve the stability of an SD-WAN solution:

  • FastTrack compatibility: SD-WAN Mangle rules will cause FastTrack to stop working. For traffic that does not require policy routing (such as intranet communication), it should be explicitly excluded in the Mangle rules to preserve FastPath acceleration.
  • MTU adaptation: For cross-border tunnels, the MTU is recommended to be set to 1400 (GRE over IPsec) or 1340 (VXLAN over WireGuard) to avoid performance degradation caused by fragmentation.
  • BGP federation: In multi-node networking scenarios, the BGP federation feature of RouterOS v7 can be used to achieve automatic route learning between sites, reducing manual maintenance costs.
  • Regularly update RouterOS: MikroTik officially releases a stable version every quarter; it is recommended to stay on the Long-term branch (the current latest LTS is v7.16.2) to fix security vulnerabilities in a timely manner.

Frequently Asked Questions

Q: Does the SD-WAN functionality of MikroTik RouterOS require an additional license?

A: No. RouterOS's SD-WAN capabilities are implemented entirely on the built-in Mangle, routing table, Netwatch, and scripting engine, and all features are available under the basic license (Level 4 and above). The RouterOS pre-installed on MikroTik devices at the factory already includes these modules, so there is no need to purchase an additional SD-WAN subscription or feature package. Note, however, that Level 3/4 licenses impose limits on the number of concurrent tunnels (typically 50-200), so for large-scale deployments it is recommended to choose the CCR series paired with a Level 6 license.

Q: In a cross-border SD-WAN solution, how should the tunnel protocol be chosen? What are the pros and cons of GRE, IPsec, and WireGuard?

A: The three protocols suit different scenarios: GRE is the simplest to configure and supports multicast and non-IP protocols, but it provides no encryption, making it suitable for intranet environments or for use in combination with IPsec; IPsec offers strong encryption (AES-256-GCM) and the broadest compatibility, but configuration is complex and it places high demands on the CPU (enabling hardware acceleration is recommended); WireGuard is a modern tunnel protocol introduced in RouterOS v7.10, with concise key exchange, a small codebase, and excellent performance, being especially efficient on ARM64/ARM devices, and it is recommended for newly built cross-border tunnels. Since RouterOS v7.14, WireGuard supports multiple peers and dynamic routing, and can already serve as the primary SD-WAN channel protocol.

Q: How many concurrent SD-WAN tunnels can a single MikroTik device handle?

A: It depends on the device model and the tunnel protocol. Taking the CCR2004-16G-2S+ as an example: about 400-600 IPsec tunnels (AES-128-GCM); about 800-1200 WireGuard tunnels; and about 2000+ GRE tunnels. The performance of the RB5009 series is roughly 40%-60% that of the CCR2004. In actual deployments, it is recommended to reserve a 30% performance margin to avoid CPU saturation affecting forwarding. CPU usage can be monitored in real time via /tool profile, and when tunnel encryption CPU usage exceeds 70%, you should consider scaling up or offloading traffic.

Q: After a cross-border SD-WAN deployment, how can link quality be continuously monitored and automated operations and maintenance be achieved?

A: A three-layer monitoring system is recommended — device layer: RouterOS built-in Netwatch + Script provides second-level fault detection and automatic failover; network layer: push metrics such as interface traffic, CPU, memory, and tunnel status to Prometheus via SNMP v3, and display them in a unified Grafana dashboard; application layer: deploy PingMesh or SmokePing to probe end-to-end latency/packet loss against critical business IPs, and combine it with Alertmanager for multi-channel alerts (WeCom/DingTalk/email). The Santi Network T3N7 intelligent scheduling engine can serve as a centralized scheduling layer, aggregating probe data from all MikroTik nodes, generating a network-wide link quality heat map, and automatically delivering optimal routing policies — truly achieving autonomous-driving-style operations and maintenance for cross-border networking.


The data in this article is updated as of 2026-08-04. The configuration solutions described herein have been verified on MikroTik CCR2004 RouterOS v7.14 LTS. The Santi Network T3N7 intelligent scheduling engine provides decision support for network-wide link scheduling.