Skip to content

SMS

RouterOS provides SMS messaging capabilities for MikroTik devices with LTE modems. Send and receive SMS messages, execute USSD commands for carrier services, and integrate cellular notifications into your network management workflow.

SMS functionality in RouterOS enables:

  • Sending SMS - Send text messages to phone numbers
  • Receiving SMS - Store and retrieve incoming messages in inbox
  • USSD Commands - Execute Unstructured Supplementary Service Data for carrier services like balance checks
  • Auto-respond - Configure automatic replies to incoming messages
  • Script Integration - Trigger actions based on incoming SMS

SMS requires:

  • A MikroTik device with an LTE modem (built-in or USB)
  • A SIM card with SMS capability
  • RouterOS v6 or later

The SMS functionality is accessed through:

  • /tool sms - Main SMS configuration
  • /tool sms inbox - Received messages
  • /tool sms outbox - Messages pending delivery
  • /tool sms sent - Successfully sent messages
  • /interface lte at-chat - Direct AT command interface

Enable the SMS tool and configure the LTE interface:

/tool sms set enabled=yes port=lte1

View SMS settings:

/tool sms print

Parameters:

PropertyDescription
enabledEnable or disable SMS functionality
portLTE interface to use (e.g., lte1)
receive-onWhich SIM to receive messages on (sim1, sim2)
auto-respondMessage to auto-respond with
secretPassword to restrict SMS commands

For dual-SIM devices, specify which SIM to use:

/tool sms set port=lte1 receive-on=sim1
/tool sms set port=lte1 receive-on=sim2

Send a simple SMS message:

/tool sms send phone-number=+1234567890 message="Hello from RouterOS"

Send to a contact saved on the SIM:

/tool sms send phone-number="John Doe" message="Status check"

Send the same message to multiple numbers:

/tool sms send phone-number=+1234567890,0987654321 message="Network alert"

Automate SMS sending from RouterOS scripts:

/system script add name=send-alert source={
/tool sms send phone-number=+1234567890 message="Router reboot detected"
}

Some carriers support custom sender IDs:

/tool sms send phone-number=+1234567890 message="Alert" from="Router-Alert"

List all received messages:

/tool sms inbox print

View messages from a specific phone number:

/tool sms inbox print where phone~"+1234"
PropertyDescription
phoneSender’s phone number
messageMessage body
timestampTime when the message was received (from operator, not router local time)
typeMessage type

Delete a specific message:

/tool sms inbox remove numbers=0

Delete all messages:

/tool sms inbox remove [find]

Configure automatic responses to incoming SMS:

/tool sms set auto-respond="Router is running. Uptime: [/system resource get uptime]"

Require a secret for SMS commands:

/tool sms set secret=MySecret123

When a secret is set, only messages starting with the secret will trigger responses or scripts.

Use a script for dynamic responses:

/system script add name=sms-response source={
:local msg [/tool sms inbox get [find] message]
:local phone [/tool sms inbox get [find] phone-number]
:if ($msg = "status") do={
:local uptime [/system resource get uptime]
:local cpu [/system resource get cpu-load]
/tool sms send phone-number=$phone message="Uptime: $uptime, CPU: $cpu%"
}
}

Schedule the script to check for new messages:

/system scheduler add name=check-sms interval=30s on-event=sms-response

USSD (Unstructured Supplementary Service Data) is used for carrier interactions like checking account balance, activating services, and managing prepaid accounts.

Send a USSD command directly:

/interface lte at-chat input="*123#"

Use the AT+CUSD command for explicit USSD handling:

/interface lte at-chat input="AT+CUSD=1,\"*123#\",15"
CodeService
*123#Balance check (common)
*101#Data balance
*102#Voice balance
*121#Active offers
##002#Cancel call forwarding

Capture the USSD response:

/interface lte at-chat input="AT+CUSD=1,\"*123#\",15"

Response appears in the log:

/log print where message~"CUSD"

Create a script to check balance:

/system script add name=check-balance source={
:local response ""
/interface lte at-chat input="AT+CUSD=1,\"*123#\",15"
:delay 2
:log info "USSD balance check completed"
}

Execute RouterOS commands via SMS for remote management:

/tool sms set secret=AdminPass
/system script add name=sms-command source={
:local msg [/tool sms inbox get [find] message]
:local phone [/tool sms inbox get [find] phone-number]
:if ($msg = "reboot") do={
/system reboot
}
}
  1. Configure SMS command handler:
/system script add name=remote-reboot source={
:local cmd [/tool sms inbox get [find] message]
:if ($cmd = "reboot") do={
:log warning "Remote reboot command received"
:delay 5
/system reboot
}
}
  1. Set up scheduler to check:
/system scheduler add name=sms-check interval=60s on-event=remote-reboot

Receive alerts when LTE signal drops below threshold:

/system script add name=signal-alert source={
:local rssi [/interface lte info [find] rssi]
:if ($rssi < -95) do={
/tool sms send phone-number=+1234567890 message="Warning: LTE signal low: $rssi dBm"
}
}

View SMS-related logs:

/log print where message~"sms\|SMS\|sms"

Send direct AT commands to the modem:

/interface lte at-chat input="AT"

Check modem SMS capability:

/interface lte at-chat input="AT+CMGF?"

List stored messages:

/interface lte at-chat input="AT+CMGL=\"ALL\""
CommandDescription
ATTest modem
AT+CMGF=1Set text mode
AT+CMGS="number"Send SMS
AT+CMGL="ALL"List all messages
AT+CMGD=1Delete message 1
AT+CUSD=1,"code",15Send USSD

Get modem capabilities:

/interface lte info [find] once

Check SIM status:

/interface lte info [find] sim-status

SMS not sending:

/interface lte at-chat input="AT+CMGS=\"+1234567890\""
> Test message
<ctrl+Z>
/log print where message~"error\|failed"

No messages in inbox:

/interface lte at-chat input="AT+CPMS?"

SIM not recognized:

/system routerboard sim reset

Send SMS when router reboots:

/system script add name=startup-notify source={
:delay 30
/tool sms send phone-number=+1234567890 message="Router booted: $[/system identity get name]"
}

Add to startup:

/system scheduler add name=startup on-event=startup-notify startup-time=startup

Monitor primary WAN and alert via SMS:

/system script add name=wan-failover source={
:local pingResult [/ping 8.8.8.8 count=3]
:if ($pingResult = 0) do={
/tool sms send phone-number=+1234567890 message="Primary WAN down! Checking LTE..."
:delay 10
:local lteStatus [/interface lte get [find] running]
:if ($lteStatus = true) do={
/tool sms send phone-number=+1234567890 message="LTE is up - failover active"
} else={
/tool sms send phone-number=+1234567890 message="ALERT: Both WANs down!"
}
}
}

Schedule periodic checks:

/system scheduler add name=wan-monitor interval=5m on-event=wan-failover

Monitor device temperature and alert:

/system script add name=temp-alert source={
:local temp [/system health get temperature]
:if ($temp > 70) do={
/tool sms send phone-number=+1234567890 message="Warning: Router temperature is ${temp}C"
}
}