Skip to content

Dual SIM Application

The Dual SIM Application enables automatic switching between SIM slots on MikroTik devices with LTE/5G modems. This functionality is essential for mobile vehicle applications where routers travel across borders and need to use different SIM cards for home and roaming networks.

Dual SIM switching enables intelligent SIM card selection based on network conditions. Two primary use cases exist:

  • Roaming-based switching: Automatically use a local SIM card when roaming is detected, switching back to the home SIM when roaming ends
  • Failover-based switching: Switch to the alternative SIM when the current connection is lost

Both scripts require scheduling to run periodically, checking network conditions and performing SIM switches when necessary.

The dual SIM functionality uses several RouterOS sub-menus:

  • /interface lte - LTE interface configuration
  • /system routerboard sim - SIM slot management (RouterOS v6.45 and earlier)
  • /system routerboard modem - Modem SIM slot management (RouterOS v6.45.1+)
  • /interface lte settings - SIM slot configuration (RouterOS v7)
  • /system script - Script execution
  • /system scheduler - Scheduled task execution

Dual SIM functionality is available on MikroTik devices with LTE modems and dual SIM slots, including:

  • LtAP mini series
  • LtAP series
  • SXT LTE series
  • wAP LTE series
  • Other devices with dual SIM capability

Before configuring dual SIM, ensure LTE network parameters are correctly configured for each SIM card. Use the default APN profile or create separate profiles for each SIM:

/interface lte apn add apn=internet.example.com name=sim1-home
/interface lte apn add apn=internet.roaming.com name=sim2-roaming

For detailed LTE setup instructions, see the LTE/5G Quick Setup Guide.

Enable data roaming to allow connection to foreign network providers:

/interface lte set [find name=lte1] allow-roaming=yes

This setting is essential for tracking roaming status and enabling automatic SIM switching.

Configure which SIM slots correspond to home and roaming networks. The command syntax varies by RouterOS version:

RouterOS v6.45 and earlier:

/system routerboard sim set sim-slot=down

RouterOS v6.45.1+:

/system routerboard modem set sim-slot=down

RouterOS v7:

/interface lte settings set sim-slot=down

The roaming script automatically switches SIM cards based on roaming detection. Use the home SIM when on the home network and switch to the roaming SIM when traveling abroad.

Create a script named “roamingScript” in /system/script:

/system script add name=roamingScript source={
# Setup and read current values
:global simSlot [/system routerboard sim get sim-slot]
:global timeoutLTE 60
:global timeoutConnect 60
# Wait for LTE to initialize for maximum "timeoutLTE" seconds
:local i 0
:local isLTEinit false
:while ($i<$timeoutLTE) do={
:foreach n in=[/interface lte find] do={:set $isLTEinit true}
:if ($isLTEinit=true) do={
:set $i $timeoutLTE
}
:set $i ($i+1)
:delay 1s
}
# Check if LTE is initialized, or try power-reset the modem
:if ($isLTEinit=true) do={
# Wait for LTE interface to connect to mobile network
:local isConnected false
:set $i 0
:while ($i<$timeoutConnect) do={
:if ([/interface lte get [find name="lte1"] running]=true) do={
:set $isConnected true
:set $i $timeoutConnect
}
:set $i ($i+1)
:delay 1s
}
# Check if LTE is connected
if ($isConnected=true) do={
:local Info [/interface lte monitor lte1 once as-value]
:local isRoaming ($Info->"roaming")
# Check which SIM slot is used
:if ($simSlot="down") do={
# If "down" (home) slot, check roaming status
:if ($isRoaming=true) do={
:log info message="Roaming detected, switching to SIM UP (Roaming)"
/system routerboard sim set sim-slot=up
}
} else={
# Else "up" (roaming) slot, check roaming status
:if (!$isRoaming=true) do={
:log info message="Not roaming, switching to SIM DOWN (Home)"
/interface lte settings set sim-slot=down
}
}
} else={
:log info message="LTE interface did not connect to network, wait for next scheduler"
}
} else={
:log info message="LTE modem did not appear, trying power-reset"
/system routerboard usb power-reset duration=5s
}
}

The roaming script performs the following actions:

  1. Initialization Check: Waits up to 60 seconds for the LTE interface to appear
  2. Connection Verification: Waits up to 60 seconds for the interface to enter “running” state
  3. Roaming Detection: Monitors the roaming status from LTE interface information
  4. SIM Switching Logic:
    • If on “down” (home) slot and roaming detected → switch to “up” (roaming) slot
    • If on “up” (roaming) slot and not roaming → switch to “down” (home) slot
  5. Failure Recovery: If LTE modem fails to initialize, performs a USB power reset
VariableDescriptionDefault
simSlotCurrent SIM slot selectionRetrieved from system
timeoutLTEMaximum wait time for LTE initialization60 seconds
timeoutConnectMaximum wait time for network connection60 seconds

The failover script switches SIM cards when the current connection is lost, providing resilience against network outages.

Create a script named “failoverScript” in /system/script:

/system script add name=failoverScript source={
# Setup and read current values
:global simSlot [/system routerboard modem get sim-slot]
:global timeoutLTE 60
:global timeoutConnect 60
# Wait for LTE to initialize for maximum "timeoutLTE" seconds
:local i 0
:local isLTEinit false
:while ($i<$timeoutLTE) do={
:foreach n in=[/interface lte find] do={:set $isLTEinit true}
:if ($isLTEinit=true) do={
:set $i $timeoutLTE
}
:set $i ($i+1)
:delay 1s
}
# Check if LTE is initialized, or try power-reset the modem
:if ($isLTEinit=true) do={
# Wait for LTE interface to connect to mobile network
:local isConnected false
:set $i 0
:while ($i<$timeoutConnect) do={
:if ([/interface lte get [find name="lte1"] running]=true) do={
:set $isConnected true
:set $i $timeoutConnect
}
:set $i ($i+1)
:delay 1s
}
# Check if LTE is connected
if ($isConnected=false) do={
# Check which SIM slot is used
:if ($simSlot="down") do={
# If "down" slot, switch to up
:log info message="LTE down, switching slot to UP"
/interface lte settings set sim-slot=up
}
:if ($simSlot="up") do={
# If "up" slot, switch to down
:log info message="LTE down, switching slot to DOWN"
/interface lte settings set sim-slot=down
}
} else={
# Else "running"
:if ($isConnected=true) do={
:log info message="LTE UP"
} else={
:log info message="LTE interface did not connect to network, wait for next scheduler"
}
}
} else={
:log info message="LTE modem did not appear, trying power-reset"
/system routerboard usb power-reset duration=5s
}
}

The failover script operates as follows:

  1. Initialization Check: Waits up to 60 seconds for the LTE interface to appear
  2. Connection Detection: Checks if the LTE interface is in “running” state
  3. SIM Switching Logic:
    • If current slot is “down” and connection is down → switch to “up”
    • If current slot is “up” and connection is down → switch to “down”
  4. Status Logging: Logs connection status changes

Create schedulers to run the scripts periodically. A 3-minute interval is recommended to prevent overlapping executions.

/system scheduler add interval=3m on-event=roamingScript name=Roaming
/system scheduler add interval=3m on-event=failoverScript name=Failover
PropertyDescriptionDefault
intervalTime between script executions3m recommended
on-eventScript to executeroamingScript or failoverScript
nameScheduler identifierUser-defined
start-timeFirst execution timestartup
disabledEnable/disable schedulerno
Use CaseRecommended Interval
High mobility (vehicles)1m - 2m
Standard roaming scenarios3m - 5m
Low mobility / infrequent travel10m - 15m

RouterOS v6.45 and earlier:

/system routerboard sim print

RouterOS v6.45.1+:

/system routerboard modem print

RouterOS v7:

/interface lte settings print
/interface lte monitor lte1 once

Output includes roaming status, signal strength, and connection state.

/interface lte print detail
  1. Verify RouterOS version compatibility with the command syntax
  2. Check that the modem supports dual SIM operation
  3. Review system logs for error messages
  4. Perform a modem power cycle manually:
/system routerboard usb power-reset duration=10s
  1. Verify LTE modem is properly installed
  2. Check SIM cards are correctly inserted
  3. Confirm antenna connections are secure
  4. Review LTE interface configuration:
/interface lte print

Roaming data may be consumed on the home SIM if:

  • The home SIM has roaming enabled
  • The script switches back and forth frequently
  • Network conditions cause rapid status changes

Consider these optimizations:

  • Increase scheduler interval to reduce checks
  • Implement hysteresis in the roaming detection
  • Use time-based restrictions for roaming SIM usage
  1. Verify scripts exist in /system/script
  2. Check scheduler is not disabled
  3. Review execution logs:
/log print where message~"LTE"
  1. Verify the modem model supports hot-swap
  2. Check for sufficient power supply
  3. Review USB power-reset configuration
  4. Consider a hardware reboot if persistent
  1. Test SIM switching manually before automating
  2. Verify roaming detection works correctly
  3. Measure SIM switch timing on your specific device
  4. Test failover scenarios in a controlled environment
  1. Use descriptive names for scripts and schedulers
  2. Document which slot corresponds to which SIM
  3. Implement monitoring for SIM switch events
  4. Set appropriate timeout values based on testing
  5. Regular review of data usage on each SIM

Monitor data consumption on both SIM cards:

/interface lte monitor lte1 once

Track usage through your mobile operator’s portal or API.

Enable comprehensive logging for troubleshooting:

/system logging add topics=interface,lte,debug

Review logs with:

/log print where message~"LTE"
  • /interface lte - LTE interface management
  • /interface lte monitor - LTE connection monitoring
  • /interface lte settings - LTE settings (v7)
  • /system routerboard sim - SIM management (RouterOS v6.45 and earlier)
  • /system routerboard modem - Modem management (RouterOS v6.45.1+)
  • /system routerboard usb - USB power management
  • /system script - Script management
  • /system scheduler - Task scheduling