{"id":31640,"date":"2019-10-31T21:42:17","date_gmt":"2019-10-31T18:42:17","guid":{"rendered":"https:\/\/prohoster.info\/blog\/mikrotik-upravlenie-cherez-sms-pri-pomoshhi-web-servera\/"},"modified":"2019-10-31T21:42:17","modified_gmt":"2019-10-31T18:42:17","slug":"mikrotik-upravlenie-cherez-sms-pri-pomoshhi-web-servera","status":"publish","type":"post","link":"https:\/\/prohoster.info\/en\/blog\/administrirovanie\/mikrotik-upravlenie-cherez-sms-pri-pomoshhi-web-servera","title":{"rendered":"Mikrotik. Manage via SMS using a WEB server","gt_translate_keys":[{"key":"rendered","format":"text"}]},"content":{"rendered":"<p>Good day, everyone!<\/p>\n<p>This time, I decided to describe a situation that doesn't seem particularly addressed on the internet, although there are some hints about it; most of it came from long, methodical digging through the code and Mikrotik's wiki. <\/p>\n<p>The task is to implement SMS management of several devices, for example, turning ports on and off.<br \/>\n<noindex><a rel=\"nofollow\" name=\"habracut\"><\/a><\/noindex><br \/>\nAvailable:<\/p>\n<ol>\n<li>Secondary router CRS317-1G-16S+<\/li>\n<li>Mikrotik NETMETAL 5 access point<\/li>\n<li>LTE modem R11e-LTE<\/li>\n<\/ol>\n<p>\nLet's start with the fact that the wonderful Netmetal 5 access point features a soldered SIM card slot and a port for installing the LTE modem. Therefore, we purchased essentially the best modem available that was supported by the access point's operating system, specifically the R11e-LTE. The unit was disassembled, and everything was installed in its place (although you should know that the SIM card is located under the modem and cannot be accessed without removing the main board), so please check the SIM card for functionality, or you will have to disassemble the access point several times.<\/p>\n<p>Next, we drilled a couple of holes in the case, installed 2 pigtails, and secured the ends to the modem. Unfortunately, there are no photos of the process. On the other hand, we attached universal antennas with magnetic bases to the pigtails.<\/p>\n<p>The main setup steps are described quite well online, except for some minor interaction quirks. For example, the modem stops receiving SMS messages when 5 messages are in the Inbox, and clearing messages or restarting the modem doesn't always resolve the issue. However, in version 6.44.1, reception works more stably. The Inbox displays the last 4 SMS messages, while the others are automatically deleted and do not interfere with operation.<\/p>\n<p>The main goal of the experiment is to turn interfaces on and off on two routers within the same physical network. The main difficulty was that Mikrotik does not support management via SNMP but only allows reading values. Therefore, we had to dig in another direction, specifically using the Mikrotik API.<\/p>\n<p>There is no clear documentation on how to manage this, so experimentation was necessary, and this instruction was created for future attempts.<\/p>\n<p>To manage multiple devices, a functional WEB server available on the local network is required; it must be responsible for handling commands to Mikrotik.<\/p>\n<p>1. On Netmetal 5, you need to create a couple of scripts to enable and disable interfaces respectively.<\/p>\n<pre><code class=\"plaintext\">system script\nadd dont-require-permissions=no name=disableiface owner=admin policy=\n    ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon source=\n    \"\/tool fetch http:\/\/WEB_SERVER_IP\/di.php \"\nadd dont-require-permissions=no name=enableiface owner=admin policy=\n    ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon source=\n    \"\/tool fetch http:\/\/WEB_SERVER_IP\/en.php \"\n<\/code><\/pre>\n<p>\n2. Create 2 scripts on the web. <a class=\"wpil_keyword_link\" href=\"https:\/\/prohoster.info\/en\/server\/dts-dronten\/\"   title=\"server\" data-wpil-keyword-link=\"linked\"  data-wpil-monitor-id=\"2468\">server<\/a> (of course, PHP should be installed on the system in this case):<\/p>\n<pre><code class=\"php\">debug=true;\n\nif ($API-&gt;connect('Managed Mikrotik IP', 'admin login', 'admin password')) {\n    $API-&gt;comm(\"\/interface\/ethernet\/enable\", array(\n    \"numbers\"=&gt;\"sfp-sfpplus16\",));\n}\n   $API-&gt;disconnect();\n?&gt;\n<\/code><\/pre>\n<p><\/p>\n<pre><code class=\"php\">debug=true;\n\nif ($API-&gt;connect('Managed Mikrotik IP', 'admin login', 'admin password')) {\n    $API-&gt;comm(\"\/interface\/ethernet\/disable\", array(\n    \"numbers\"=&gt;\"sfp-sfpplus16\",));\n}\n   $API-&gt;disconnect();\n?&gt;\n<\/code><\/pre>\n<p>\n3. Download routeros_api.class.php from the Mikrotik forum and place it in an accessible directory. <a class=\"wpil_keyword_link\" href=\"https:\/\/prohoster.info\/en\/server\/dts-newyork\/\"   title=\"server\" data-wpil-keyword-link=\"linked\"  data-wpil-monitor-id=\"2647\">server<\/a>.<\/p>\n<p>Instead of sfp-sfpplus16, specify the name of the interface to be disabled\/enabled.<\/p>\n<p>Now, when sending a message to the number in the format <\/p>\n<pre><code class=\"plaintext\">:cmd SECRET_CODE script enableiface\nor\n:cmd SECRET_CODE script disableiface \n<\/code><\/pre>\n<p>\nNETMETAL will run the corresponding script, which in turn executes the command on the WEB server.<\/p>\n<p>The speed of operation when receiving SMS is a fraction of a second. It works stably.<\/p>\n<p>Additionally, there is functionality for sending SMS to phones using the Zabbix monitoring system and opening a backup internet connection when the optical link fails. This might go beyond the scope of this article, but I will say right away that when sending SMS, their length should fit within the standard size of a single message since Mikrotik does not split them and simply does not send long messages. Furthermore, it is important to filter characters in the messages; otherwise, the SMS will not be sent.<br \/>\n<br \/>Source: <a content=\"nofollow\" rel=\"nofollow\" href=\"https:\/\/habr.com\/ru\/post\/448124\/\">habr.com<\/a><\/p>","protected":false,"gt_translate_keys":[{"key":"rendered","format":"html"}]},"excerpt":{"rendered":"<p>\u0414\u043e\u0431\u0440\u043e\u0433\u043e \u0432\u0441\u0435\u043c \u0434\u043d\u044f! \u041d\u0430 \u044d\u0442\u043e\u0442 \u0440\u0430\u0437 \u0440\u0435\u0448\u0438\u043b \u043e\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044e, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0432\u0440\u043e\u0434\u0435 \u0431\u044b \u0438 \u043d\u0435 \u043e\u0441\u043e\u0431\u043e \u043e\u043f\u0438\u0441\u0430\u043d\u0430 \u0432 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442\u0435, \u0445\u043e\u0442\u044f \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0430\u043c\u0435\u043a\u0438 \u043d\u0430 \u043d\u0435\u0435 \u0435\u0441\u0442\u044c, \u043d\u043e \u0431\u043e\u043b\u044c\u0448\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u0434\u043e\u0441\u0442\u0430\u043b\u0430\u0441\u044c \u043f\u0440\u043e\u0441\u0442\u043e \u0434\u043e\u043b\u0433\u0438\u043c \u043c\u0435\u0442\u043e\u0434\u0438\u0447\u043d\u044b\u043c \u043a\u043e\u043f\u0430\u043d\u0438\u0435\u043c \u043a\u043e\u0434\u0430 \u0438 \u0432\u0438\u043a\u0438 \u0441\u0430\u043c\u043e\u0433\u043e Mikrotik. \u0421\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0437\u0430\u0434\u0430\u0447\u0430: \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 SMS \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435\u043c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u043c\u0438 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430\u043c\u0438, \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0438 \u0432\u044b\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043f\u043e\u0440\u0442\u043e\u0432. \u0418\u043c\u0435\u0435\u0442\u0441\u044f: \u0412\u0442\u043e\u0440\u043e\u0441\u0442\u0435\u043f\u0435\u043d\u043d\u044b\u0439 \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u0438\u0437\u0430\u0442\u043e\u0440 [&hellip;]<\/p>\n","protected":false,"gt_translate_keys":[{"key":"rendered","format":"html"}]},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[688],"tags":[],"class_list":["post-31640","post","type-post","status-publish","format-standard","hentry","category-administrirovanie"],"aioseo_notices":[],"aioseo_head":"\n\t\t<!-- All in One SEO 5.0.1.1 - aioseo.com -->\n\t<meta name=\"description\" content=\"\u0414\u043e\u0431\u0440\u043e\u0433\u043e \u0432\u0441\u0435\u043c \u0434\u043d\u044f! \u041d\u0430 \u044d\u0442\u043e\u0442 \u0440\u0430\u0437 \u0440\u0435\u0448\u0438\u043b \u043e\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044e, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0432\u0440\u043e\u0434\u0435 \u0431\u044b \u0438 \u043d\u0435 \u043e\u0441\u043e\u0431\u043e \u043e\u043f\u0438\u0441\u0430\u043d\u0430 \u0432 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442\u0435, \u0445\u043e\u0442\u044f \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0430\u043c\u0435\u043a\u0438 \u043d\u0430 \u043d\u0435\u0435 \u0435\u0441\u0442\u044c, \u043d\u043e \u0431\u043e\u043b\u044c\u0448\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u0434\u043e\u0441\u0442\u0430\u043b\u0430\u0441\u044c \u043f\u0440\u043e\u0441\u0442\u043e \u0434\u043e\u043b\u0433\u0438\u043c \u043c\u0435\u0442\u043e\u0434\u0438\u0447\u043d\u044b\u043c \u043a\u043e\u043f\u0430\u043d\u0438\u0435\u043c \u043a\u043e\u0434\u0430 \u0438 \u0432\u0438\u043a\u0438.\" \/>\n\t<meta name=\"robots\" content=\"max-image-preview:large\" \/>\n\t<meta name=\"author\" content=\"Yuri Gagarin\"\/>\n\t<link rel=\"canonical\" href=\"https:\/\/prohoster.info\/en\/blog\/administrirovanie\/mikrotik-upravlenie-cherez-sms-pri-pomoshhi-web-servera\" \/>\n\t<meta name=\"generator\" content=\"All in One SEO (AIOSEO) 5.0.1.1\" \/>\n\t\t<meta property=\"og:locale\" content=\"en_US\" \/>\n\t\t<meta property=\"og:site_name\" content=\"ProHoster | \u041a\u0443\u043f\u0438\u0442\u044c \u043d\u0430\u0434\u0435\u0436\u043d\u044b\u0439 \u0445\u043e\u0441\u0442\u0438\u043d\u0433 \u0434\u043b\u044f \u0441\u0430\u0439\u0442\u043e\u0432 \u0441 \u0437\u0430\u0449\u0438\u0442\u043e\u0439 \u043e\u0442 DDoS, VPS VDS \u0441\u0435\u0440\u0432\u0435\u0440\u044b\" \/>\n\t\t<meta property=\"og:type\" content=\"article\" \/>\n\t\t<meta property=\"og:title\" content=\"\ud83e\udd47Mikrotik. \u0423\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0447\u0435\u0440\u0435\u0437 SMS \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 WEB \u0441\u0435\u0440\u0432\u0435\u0440\u0430 | ProHoster\" \/>\n\t\t<meta property=\"og:description\" content=\"\u0414\u043e\u0431\u0440\u043e\u0433\u043e \u0432\u0441\u0435\u043c \u0434\u043d\u044f! \u041d\u0430 \u044d\u0442\u043e\u0442 \u0440\u0430\u0437 \u0440\u0435\u0448\u0438\u043b \u043e\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044e, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0432\u0440\u043e\u0434\u0435 \u0431\u044b \u0438 \u043d\u0435 \u043e\u0441\u043e\u0431\u043e \u043e\u043f\u0438\u0441\u0430\u043d\u0430 \u0432 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442\u0435, \u0445\u043e\u0442\u044f \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0430\u043c\u0435\u043a\u0438 \u043d\u0430 \u043d\u0435\u0435 \u0435\u0441\u0442\u044c, \u043d\u043e \u0431\u043e\u043b\u044c\u0448\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u0434\u043e\u0441\u0442\u0430\u043b\u0430\u0441\u044c \u043f\u0440\u043e\u0441\u0442\u043e \u0434\u043e\u043b\u0433\u0438\u043c \u043c\u0435\u0442\u043e\u0434\u0438\u0447\u043d\u044b\u043c \u043a\u043e\u043f\u0430\u043d\u0438\u0435\u043c \u043a\u043e\u0434\u0430 \u0438 \u0432\u0438\u043a\u0438.\" \/>\n\t\t<meta property=\"og:url\" content=\"https:\/\/prohoster.info\/en\/blog\/administrirovanie\/mikrotik-upravlenie-cherez-sms-pri-pomoshhi-web-servera\" \/>\n\t\t<meta property=\"og:image\" content=\"https:\/\/prohoster.info\/wp-content\/uploads\/2021\/11\/logo-350.jpg\" \/>\n\t\t<meta property=\"og:image:secure_url\" content=\"https:\/\/prohoster.info\/wp-content\/uploads\/2021\/11\/logo-350.jpg\" \/>\n\t\t<meta property=\"og:image:width\" content=\"350\" \/>\n\t\t<meta property=\"og:image:height\" content=\"350\" \/>\n\t\t<meta property=\"article:published_time\" content=\"2019-10-31T18:42:17+00:00\" \/>\n\t\t<meta property=\"article:modified_time\" content=\"2019-10-31T18:42:17+00:00\" \/>\n\t\t<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/prohoster\" \/>\n\t\t<meta property=\"article:author\" content=\"https:\/\/www.facebook.com\/prohoster\" \/>\n\t\t<!-- All in One SEO -->\n\n","aioseo_head_json":{"title":"\ud83e\udd47Mikrotik. SMS Management via WEB server | ProHoster","description":"Good day to everyone! This time I decided to describe a situation that seems not particularly covered on the internet, although there are some hints about it, but a large part was obtained through long methodical digging through code and the wiki.","canonical_url":"https:\/\/prohoster.info\/en\/blog\/administrirovanie\/mikrotik-upravlenie-cherez-sms-pri-pomoshhi-web-servera","robots":"max-image-preview:large","keywords":"","webmasterTools":{"miscellaneous":""},"schema":null,"og:locale":"en_US","og:site_name":"ProHoster | \u041a\u0443\u043f\u0438\u0442\u044c \u043d\u0430\u0434\u0435\u0436\u043d\u044b\u0439 \u0445\u043e\u0441\u0442\u0438\u043d\u0433 \u0434\u043b\u044f \u0441\u0430\u0439\u0442\u043e\u0432 \u0441 \u0437\u0430\u0449\u0438\u0442\u043e\u0439 \u043e\u0442 DDoS, VPS VDS \u0441\u0435\u0440\u0432\u0435\u0440\u044b","og:type":"article","og:title":"\ud83e\udd47Mikrotik. \u0423\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0447\u0435\u0440\u0435\u0437 SMS \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 WEB \u0441\u0435\u0440\u0432\u0435\u0440\u0430 | ProHoster","og:description":"\u0414\u043e\u0431\u0440\u043e\u0433\u043e \u0432\u0441\u0435\u043c \u0434\u043d\u044f! \u041d\u0430 \u044d\u0442\u043e\u0442 \u0440\u0430\u0437 \u0440\u0435\u0448\u0438\u043b \u043e\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044e, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0432\u0440\u043e\u0434\u0435 \u0431\u044b \u0438 \u043d\u0435 \u043e\u0441\u043e\u0431\u043e \u043e\u043f\u0438\u0441\u0430\u043d\u0430 \u0432 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442\u0435, \u0445\u043e\u0442\u044f \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0430\u043c\u0435\u043a\u0438 \u043d\u0430 \u043d\u0435\u0435 \u0435\u0441\u0442\u044c, \u043d\u043e \u0431\u043e\u043b\u044c\u0448\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u0434\u043e\u0441\u0442\u0430\u043b\u0430\u0441\u044c \u043f\u0440\u043e\u0441\u0442\u043e \u0434\u043e\u043b\u0433\u0438\u043c \u043c\u0435\u0442\u043e\u0434\u0438\u0447\u043d\u044b\u043c \u043a\u043e\u043f\u0430\u043d\u0438\u0435\u043c \u043a\u043e\u0434\u0430 \u0438 \u0432\u0438\u043a\u0438.","og:url":"https:\/\/prohoster.info\/en\/blog\/administrirovanie\/mikrotik-upravlenie-cherez-sms-pri-pomoshhi-web-servera","og:image":"https:\/\/prohoster.info\/wp-content\/uploads\/2021\/11\/logo-350.jpg","og:image:secure_url":"https:\/\/prohoster.info\/wp-content\/uploads\/2021\/11\/logo-350.jpg","og:image:width":350,"og:image:height":350,"article:published_time":"2019-10-31T18:42:17+00:00","article:modified_time":"2019-10-31T18:42:17+00:00","article:publisher":"https:\/\/www.facebook.com\/prohoster","article:author":"https:\/\/www.facebook.com\/prohoster"},"aioseo_meta_data":{"post_id":"31640","title":null,"description":null,"keywords":null,"keyphrases":null,"primary_term":null,"canonical_url":null,"og_title":null,"og_description":null,"og_object_type":"default","og_image_type":"default","og_image_url":null,"og_image_width":null,"og_image_height":null,"og_image_custom_url":null,"og_image_custom_fields":null,"og_video":null,"og_custom_url":null,"og_article_section":null,"og_article_tags":null,"twitter_use_og":false,"twitter_card":"default","twitter_image_type":"default","twitter_image_url":null,"twitter_image_custom_url":null,"twitter_image_custom_fields":null,"twitter_title":null,"twitter_description":null,"schema":{"blockGraphs":[],"customGraphs":[],"default":{"data":{"Article":[],"Course":[],"Dataset":[],"FAQPage":[],"Movie":[],"Person":[],"Product":[],"ProductReview":[],"Car":[],"Recipe":[],"Service":[],"SoftwareApplication":[],"WebPage":[]},"graphName":"","isEnabled":true},"graphs":[]},"schema_type":null,"schema_type_options":null,"pillar_content":false,"robots_default":true,"robots_noindex":false,"robots_noarchive":false,"robots_nosnippet":false,"robots_nofollow":false,"robots_noimageindex":false,"robots_noodp":false,"robots_notranslate":false,"robots_max_snippet":null,"robots_max_videopreview":null,"robots_max_imagepreview":"large","priority":null,"frequency":null,"local_seo":null,"seo_analyzer_scan_date":"2026-02-09 21:45:03","breadcrumb_settings":null,"limit_modified_date":false,"reviewed_by":null,"ai":null,"created":"2021-03-01 03:13:28","updated":"2026-02-09 21:45:03","focus_keyword":null,"additional_keywords":null,"truseo_locale":null},"gt_translate_keys":[{"key":"link","format":"url"}],"_links":{"self":[{"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/posts\/31640","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/comments?post=31640"}],"version-history":[{"count":2,"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/posts\/31640\/revisions"}],"predecessor-version":[{"id":159929,"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/posts\/31640\/revisions\/159929"}],"wp:attachment":[{"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/media?parent=31640"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/categories?post=31640"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/tags?post=31640"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}