{"id":13586796,"url":"https://github.com/gbudny93/RouterOS_Useful_Scripts","last_synced_at":"2025-04-07T18:34:54.287Z","repository":{"id":41395096,"uuid":"180370245","full_name":"gbudny93/RouterOS_Useful_Scripts","owner":"gbudny93","description":"MikroTik RouterOS Useful Scripts for various use ","archived":false,"fork":false,"pushed_at":"2020-07-03T09:30:32.000Z","size":66,"stargazers_count":84,"open_issues_count":0,"forks_count":25,"subscribers_count":18,"default_branch":"master","last_synced_at":"2024-02-14T21:44:41.259Z","etag":null,"topics":["computer-network","mikrotik","mikrotik-routeros","network-monitoring","notifications","rascal","routerboard","routeros","scripting"],"latest_commit_sha":null,"homepage":"","language":"Rascal","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gbudny93.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-04-09T13:13:57.000Z","updated_at":"2023-12-08T02:20:03.000Z","dependencies_parsed_at":"2022-08-27T23:30:44.395Z","dependency_job_id":null,"html_url":"https://github.com/gbudny93/RouterOS_Useful_Scripts","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gbudny93%2FRouterOS_Useful_Scripts","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gbudny93%2FRouterOS_Useful_Scripts/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gbudny93%2FRouterOS_Useful_Scripts/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gbudny93%2FRouterOS_Useful_Scripts/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gbudny93","download_url":"https://codeload.github.com/gbudny93/RouterOS_Useful_Scripts/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247707816,"owners_count":20982855,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["computer-network","mikrotik","mikrotik-routeros","network-monitoring","notifications","rascal","routerboard","routeros","scripting"],"created_at":"2024-08-01T15:05:49.077Z","updated_at":"2025-04-07T18:34:53.967Z","avatar_url":"https://github.com/gbudny93.png","language":"Rascal","funding_links":[],"categories":["Rascal","Scripts"],"sub_categories":[],"readme":"## RouterOS_Useful_Scripts\n\u003e MikroTik RouterOS Scripts for various use and shared among different projects. Repository contains ready to use scripts as well functions ready to use in larger projects. \n**Check also another repository with scripts related strictly to MikroTik CAPsMAN automation :link: [CAPsMAN Automation Scripts](https://github.com/gbudny93/MikroTik_CAPsMAN_Automation).**\n**Here you can find script template that I use :link: [RouterOS_Script_Template](https://gist.github.com/gbudny93/8ad0899576407e5efe9323febb368796).**\n\n![](https://img.shields.io/badge/scripting-routeros-important.svg)\n![](https://img.shields.io/badge/mikrotik-routerBOARD-yellow)\n![](https://img.shields.io/badge/network-automation-informational)\n\n#### Change log\n   - 7/3/2020\n     - RouterOS_All_Software_Download.rsc - typos fix \n     - RouterOS_Array_Append.rsc \n\n   - 4/19/2020\n     - RouterOS_All_Software_Download.rsc\n     - RouterOS_Dual_WAN_Failover.rsc\n\n   - 23/3/2020\n     - RouterOS_Config_Fetch.rsc\n     - RouterOS_Measure_Execution_Time.rsc\n     - RouterOS_RB750GR3_DUDE_Setup.rsc\n\n   - 15/2/2020\n     - RouterOS_Cloud_Backup.rsc\n     - RouterOS_FTP_Backup.rsc\n     - RouterOS_Function_Template.rsc\n     - RouterOS_PPP_Disconnect_Active_Sessions.rsc\n     - RouterOS_Recreate_Bridge.rsc\n\n   - 12/4/2019\n     - RouterOS_RadiusMonitor.rsc\n     - RouterOS_User_Alerts.rsc\n\n   - 12/4/2019\n     - RouterOS_Auto_Firmware_Upgrade.rsc\n     - RouterOS_Port_Knock.rsc\n\n   - 11/24/2019\n     - RouterOS_R_ARP.rsc\n     - RouterOS_Format_Drive.rsc\n     - RouterOS_Substring_Variable.rsc\n     - RouterOS_System_Status.rsc\n\n   - 10/14/2019\n     - RouterOS_Mail_Backup.rsc\n     - RouterOS_Cloud_Backup.rsc\n     - RouterOS_File_Screening.rsc\n     - RouterOS_Renew_License.rsc\n     - RouterOS_Script_Fetch.rsc - Update \n     - RouterOS_Auto_Upgrade.rsc - Update/Clean ups   \n\n   - 10/1/2019\n     - RouterOS_Auto_Upgrade.rsc\n       - Fixed missing auto check for updates to get variables values at first\n\n   - 8/21/2019\n     - RouterOS_Script_Fetch.rsc\n       - Fetches script from git to RouterOS directory \n\n   - 8/14/2019\n     - RouterOS_Auto_Upgrade.rsc\n       - Upgrades RouterOS if new package found when run \n\n   - 8/3/2019\n      - RouterOS_String_Generator.rsc\n        - Generates 6 char string based on dictionary \n      - RouterOS_Reset_Interface.rsc\n        - Resets interface if particular IP does not respond \n\n   - 7/29/2019 \n      - RouterOS_Modulo.rsc\n        - Modulo operation\n      - RouterOS_Load_Script.rsc\n        - Loads RouterOS script to environment. If file is missing adds log entry \n\n   - 7/19/2019 \n      - FTP_Backup_Template.rsc\n        - Schedules generation of *.backup* and *.rsc* file on RouterOS. Create FTP user dedicated for automatic backups. More on automatic RouterOS\n      backups can be found under dedicated project: :link: [Backup_mt by gbudny93](https://github.com/gbudny93/Backup_mt)\n     - RouterOS_Auto_Upgrade.rsc\n       - in progress\n     - RouterOS_Create_Directory.rsc\n       - Creates directory with specific name in RouterOS\n     - RouterOS_Log_Filtering.rsc\n       - Filters logs based on specified criteria: time or message and put in desired output\n     - RouterOS_Log_To_Alert.rsc\n       - Sends an email alert based on log message match\n     - RouterOS_Send_Email.rsc\n       - Sends email via SMTP server with common email parameters as function parameters\n     - RouterOS_File_Logging.rsc\n       - Adds log entry if file was added or removed \n     - RouterOS_LCD_Change.rsc (Applies only to physical devices with LCD)\n       - Changes LCD mode from dark to light and vice versa based on schedule set up\n     - RouterOS_Low_Disk_Space.rsc\n       - Sends email alert if disk space is under specified treshhold\n     - RouterOS_File_Screening.rsc\n       - in progress\n     - RouterOS_Eth_Errors_Handling.rsc\n       - in progress\n     - RouterOS_Config_Check.rsc\n       - in progress\n\n  - 6/14/2019 first release\n    - FTP_Backup_Template.rsc\n      - Schedules generation of *.backup* and *.rsc* file on RouterOS. Create FTP user dedicated for automatic backups. More on automatic RouterOS\n      backups can be found under dedicated project: :link: [Backup_mt by gbudny93](https://github.com/gbudny93/Backup_mt)\n    - RouterOS_Auto_Upgrade.rsc\n      - in progress\n    - RouterOS_Create_Directory.rsc\n      - Function that creates directory with specific name in RouterOS\n    - RouterOS_Log_Filtering.rsc\n      - in progress\n    - RouterOS_Log_To_Alert.rsc\n      - in progress\n    - RouterOS_Send_Email.rsc\n      - Fucntion sending email via SMTP server with common email parameters as function parameters\n    \n### Prerequisites\n\n  -  :white_check_mark: RouterOS v6.40 or higher\n  -  :white_check_mark: MikroTik CRS or CCR with LCD for RouterOS_LCD_Change.rsc\n  \n### How to use\n\u003e Use the following scripts to make your RouterOS management easier or use them in various larger scripts or projects \n:+1: \n\n#### FTP_Backup_Template.rsc\n\u003e This script creates two files via RouterOS scheduler as well creates FTP user and group: \n  - *.backup* file \n  - *.rsc* file \n  \nScript is a part of  :link: [Backup_mt by gbudny93](https://github.com/gbudny93/Backup_mt) project.\n\n#### RouterOS_All_Software_Download.rsc\n\u003e Automated download of all latest RouterOS standard packages. Tool recommended for CAPsMANs and DUDE servers\n\n### RouterOS_Array_Append.rsc \n\u003e Wrapper to append array elements\n\n#### RouterOS_Auto_Firmware_Upgrade.rsc\n\u003e Checks if latest firmware is available. Installs it and sends email notification \n\n**Example**\n```\n$AutoFirmwareUpgrade smtpServer=smtpServer smtpPort=smtpPort domain=example.com \\\nrecipient=recipient@example.com;\n```\n\n#### RouterOS_Auto_Software_Upgrade.rsc\n\u003e Checks if latest package is available. Downloads it, installs and sends email notification \n\n**Example** \n```\n$PackageAutoDownload userName=userName password=password packagePath=path \\\nsmtpServer=ipAddress smtpPort=poty domain=@example.com \\\nrecipient=recipient@example.com;\n```\n\n#### RouterOS_Cloud_Backup.rsc\n\u003e Creates new backup file and uploads it to MikroTik Cloud\n\n**Example**\n```\n$CloudBackup password=password;\n```\n\n#### RouterOS_Create_Directory.rsc\n\u003e RouterOS function that creates directory with defined name in the system. Can be used just to create directory or be a part of larger project. \n\n**Example**\n ```\n $CreateDirecotry userName=UserName password=Password directoryName=DirectoryName;\n```\n\n#### RouterOS_Dual_WAN_Failover.rsc\n\u003e Simple setup for DUAL WAN failover. Main WAN must be commented as WAN1. Secondary WAN must be commented as WAN2\n\n#### RouterOS_Log_Filtering.rsc\n\u003e RouterOS function for log messages filtering based on message or time match stored in chosen output. \n\n**Example**\n```\n$LogFilter;\n```\n\n#### RouterOS_Log_To_Alert.rsc\n \u003e RouterOS function sending mail alert if log entry matches message criteria.\n\n**Example**\n ```\n $LogToAlert message=\"message\" fileName=\"fileName\" smtpServer=smtpServer smtpPort=smtpPort domain=\"@example.com\" \\ \nrecipient=\"recipient@example.com\";\n ```\n\n#### RouterOS_Send_Email.rsc\n\u003e RouterOS function to send email via SMTP server. Function contains all common email fields like *to*, *cc*, *subject*, *body* and more. Function can be called itself in RouterOS or by other script.\n\n**Example**\n```\n$SendEmail smtpServer=SMTPServer smtpPort=SMTPPort from=From to=To subject=Subject body=Body;\n```\n\n#### RouterOS_File_Logging.rsc\n\u003e RouterOS function adding log entry if file was added or removed.\n\n**Example**\n```\n$FileToLog;\n```\n\n#### RouterOS_LCD_Change.rsc\n\u003e RouterOS function changing LCD mode from dark to light and vice versa based on schedule setup.\n\n**Example**\n```\n$ChangeLcd lightModeStartTime=\"08:00:00\" darkModeStartTime=\"17:00:00\";\n```\n\n#### RouterOS_Low_Disk_Space.rsc\n\u003e RouterOS function generating mail alert if disk space is below defined treshhold.\n\n**Example**\n```\n$LowDiskSpace treshhold=free_disk_space_in_%;\n```\n\n#### RouterOS_Mail_Backup.rsc\n\u003e Creates RouterOS backup and config file and sends them via email\n\n**Example**\n```\n$MailBackup configName=configName backupName=backupName smtpServer=smtpServer smtpPort=smtpPort domain=@example.com \\\nrecipient=recipient@example.com;\n```\n\n#### RouterOS_File_Screening.rsc\n\u003e Removes files by specific name or file extansion \n\n**Example**\n```\n$FileScreening keyWord=\".txt\";\n```\n\n#### RouterOS_Format_Drive.rsc\n\u003e Formats RouterOS additional drive\n\n**Example**\n```\n$FormatDrive drive=0 fileSystem=ext3 label=data; \n```\n\n#### RouterOS_Modulo.rsc\n\u003eModulo function.\n\n**Example**\n```\n$Modulo number=number_to_be_devided modulo=modulo_value;\n```\n\n#### RouterOS_Port_Knock.rsc\n\u003e Port Knock from RouterOS\n\n**Example**\n```\n:global knockBase {\"sourceIP1\"=\"port23\"; \\\n                   \"sourceIP2\"=\"port22\"  \\\n                  };\n\n$PortKnock base=$knockBase destinationAddress=destinationIP;\n```\n\n#### RouterOS_R_ARP.rsc\n\u003e ARP/RARP Function (shortange syntax) \n\n**Example**\n```\n$R_ARP mode=mode;\n```\n\n#### RouterOS_Radius_Monitor.rsc\n\u003e Sends Radius statistics via email\n\n**Example**\n```\n$RadiusMonitor smtpServer=smtpServer smtpPort=smtpPort domain=\"@example.com\" recipient=\"recipient@example.com\";\n```\n\n#### RouterOS_Renew_License.rsc\n\u003e Renews RouterOS License \n\n**Example**\n```\n$RenewLicense account=account password=password level=level;\n```\n\n#### RouterOS_Load_Script.rsc\n\u003e Loads function to RouterOS environment\n\n**Example**\n```\n$LoadScript scriptName=scriptName.rsc;\n```\n\n#### RouterOS_String_Generator.rsc\n\u003e Generates 6 char string based on dictionary \n\n**Example**\n```\n$GenerateString;\n```\n\n#### RouterOS_Reset_Interface.rsc\n\u003e Resets interface if particular IP does not respond \n\n**Example**\n```\n$ResetInterface ipAddress=ipAddress_To_Monitor interfaceName=interface_name;\n```\n\n#### RouterOS_Script_Fetch.rsc\n\u003e Fetches script from git to RouterOS directory\n\n**Example**\n```\n$FetchScript url=\"https://example.repo.com\" destinationPath=\"FolderName\" destinationFileName=\"ScriptName\" \n\n$FetchScript url=\"https://example.repo.com\" destinationPath=\"FolderName\" destinationFileName=\"ScriptName\" isRun=true\n\n$FetchScript url=\"https://example.repo.com\" destinationPath=\"FolderName\" destinationFileName=\"ScriptName\" isSchedule=true\\\ninterval=\"24\" taskName=\"TaskName\" startTime=\"startup\"\n```\n\n#### RouterOS_Substring_Variable.rsc\n\u003e Substrings variable \n\n**Example**\n```\n$Substring findMode=true string=\"string\" signA=\"A\" signB \"b\";\n```\n\n#### RouterOS_User_alert.rsc\n\u003e After defined number of logon failure attempts in 1 hour sends email alert and blocks source IP on firewall\n\n**Example**\n```\n$UserAlert message=\"message\" treshhold=3 fileName=\"fileName\" smtpServer=smtpServer smtpPort=smtpPort domain=\"@example.com\" \\ \nrecipient=\"recipient@example.com\";\n```\n\n#### RouterOS_FTP_Backup.rsc\n\u003e Creates backup files and sends them via FTP to FTP server\n\n**Example**\n```\n$FTPBackup configName=configName backupName=backupName smtpServer=smtpServer smtpPort=smtpPort domain=@example.com \\\nrecipient=recipient@example.com destPath=destPath ftpUser=user ftpPassword=password ftpServer=ftpserver;\n```\n\n#### RouterOS_Function_Template.rsc\n\u003e Function template that I use\n\n#### RouterOS_PPP_Disconnect_Active_Sessions.rsc\n\u003e Disconnects all PPP active sessions at once\n\n**Example**\n```\n$DisconnectPPPActveSessions;\n```\n\n#### RouterOS_Recreate_Bridge.rsc\n\u003e Recreates bridge if broken or misconfigured \n\n#### More scripts comming soon :) \n\n### Authors\n\n  - Grzegorz Budny","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgbudny93%2FRouterOS_Useful_Scripts","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgbudny93%2FRouterOS_Useful_Scripts","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgbudny93%2FRouterOS_Useful_Scripts/lists"}