Community discussions

MikroTik App
 
User avatar
robmaltsystems
Forum Veteran
Forum Veteran
Topic Author
Posts: 756
Joined: Fri Jun 21, 2019 12:04 pm

Using AI to help configuring RouterOS and scripting

Mon Apr 28, 2025 11:21 am

I've used AI now and then for writing VBA and PowerShell scripts, often surprised how accurate the code is. Anyone tried it with RouterOS configuration? Will have a go next time I need to do some RouterOS work.
 
User avatar
normis
MikroTik Support
MikroTik Support
Posts: 27082
Joined: Fri May 28, 2004 11:04 am
Location: Riga, Latvia
Contact:

Re: Using AI to help configuring RouterOS and scripting

Mon Apr 28, 2025 11:23 am

Try our own AI bot. It's not very good at scripting, because RouterOS is not as popular as generic programming languages, but it's still pretty good if you can do your own sanity checks, and if you are able to formulate the problem in full sentences with a lot of details:

https://mikrotik.com/support
 
optio
Forum Guru
Forum Guru
Posts: 1106
Joined: Mon Dec 26, 2022 2:57 pm

Re: Using AI to help configuring RouterOS and scripting

Mon Apr 28, 2025 3:21 pm

@robmaltsystems so basically this means "if you are able to formulate the problem in full sentences with a lot of details" MT support will create script for you, not sure about that, but if @normis says so why not to believe :)
 
User avatar
robmaltsystems
Forum Veteran
Forum Veteran
Topic Author
Posts: 756
Joined: Fri Jun 21, 2019 12:04 pm

Re: Using AI to help configuring RouterOS and scripting

Mon Apr 28, 2025 5:16 pm

I need to understand more about AI works but do know that it uses a lot on existing knowledge so as RouterOS is relatively niche, there isn't as much source material for scripting such as for PowerShell. What I don't know is whether AI understands the syntax of the language and therefore can write any new code.
 
jaclaz
Forum Guru
Forum Guru
Posts: 2904
Joined: Tue Oct 03, 2023 4:21 pm

Re: Using AI to help configuring RouterOS and scripting

Mon Apr 28, 2025 5:27 pm

I need to understand more about AI works but do know that it uses a lot on existing knowledge so as RouterOS is relatively niche, there isn't as much source material for scripting such as for PowerShell. What I don't know is whether AI understands the syntax of the language and therefore can write any new code.
Not really-really.
The issue is that AI "digests" anything it can find related to the subject without actually checking if what it reads is accurate or not.
Then it re-elaborates on what it has read and the output can be good (if the original digested source was good) or completely bonkers (if the source was shit).
With RoS there is the additional challenge of the (sometimes huge) differences between version 6 and version 7 and what can be found (sources) rarely explicitly specify which is which.
To this you add the "sure" (as if it actually knew what it says) tone that usually characterizes AI suggestions and you get what you get, something almost, but not quite, completely unlike good code...
 
optio
Forum Guru
Forum Guru
Posts: 1106
Joined: Mon Dec 26, 2022 2:57 pm

Re: Using AI to help configuring RouterOS and scripting

Mon Apr 28, 2025 5:39 pm

AI is like virgin who knows all about sex :)
 
User avatar
mozerd
Forum Veteran
Forum Veteran
Posts: 974
Joined: Thu Oct 05, 2017 3:39 pm
Location: Canada
Contact:

Re: Using AI to help configuring RouterOS and scripting

Mon Apr 28, 2025 5:43 pm

Try our own AI bot. It's not very good at scripting ...
Thanks for providing this valuable resource ... it did help me solve some problems effectively ...
 
User avatar
normis
MikroTik Support
MikroTik Support
Posts: 27082
Joined: Fri May 28, 2004 11:04 am
Location: Riga, Latvia
Contact:

Re: Using AI to help configuring RouterOS and scripting

Mon Apr 28, 2025 5:51 pm

@robmaltsystems so basically this means "if you are able to formulate the problem in full sentences with a lot of details" MT support will create script for you, not sure about that, but if @normis says so why not to believe :)
Maybe you missed it, but the linked page has a chat bot in the corner. I was not talking about emailing support.
 
optio
Forum Guru
Forum Guru
Posts: 1106
Joined: Mon Dec 26, 2022 2:57 pm

Re: Using AI to help configuring RouterOS and scripting

Mon Apr 28, 2025 6:00 pm

Ah you're referring to that bot, sry my mistake. (Good I didn't comment why are support staff treated as bot level intellect :))
 
jaclaz
Forum Guru
Forum Guru
Posts: 2904
Joined: Tue Oct 03, 2023 4:21 pm

Re: Using AI to help configuring RouterOS and scripting

Mon Apr 28, 2025 6:02 pm

Called (fantasy must not be one of the good Latvian guys point of strength) "The Dude", so that it can be more easily confused with the Mikrotik management software.

The good thing is that at least on paper rectius screen it is - unlike many other AI bots - quite modest:
Hi there! 👋 I'm a LLM chatbot and I might not answer all questions perfectly, I make mistakes! My knowledge is based on the MikroTik documentation, which you can read here to get more in-depth knowledge.

Write your question in full sentences, this is not a search box.
 
User avatar
Larsa
Forum Guru
Forum Guru
Posts: 1943
Joined: Sat Aug 29, 2015 7:40 pm
Location: The North Pole, Santa's Workshop

Re: Using AI to help configuring RouterOS and scripting

Mon Apr 28, 2025 6:21 pm

What I don't know is whether AI understands the syntax of the language and therefore can write any new code.

All AI models fully understand formal syntax descriptions for scripting languages, like standard BNF (Backus–Naur Form) and similar. The real issue is that Mikrotik has never bothered to publish an official BNF for RouterOS v7 scripting, which is necessary to properly train AI models for it.

Why they haven't already is a big mystery, but IMO they probably lack the competence to understand this.

Check out this thread: Feature Request: Official BNF for RouterOS Scripting
 
optio
Forum Guru
Forum Guru
Posts: 1106
Joined: Mon Dec 26, 2022 2:57 pm

Re: Using AI to help configuring RouterOS and scripting

Mon Apr 28, 2025 6:33 pm

Hi there! 👋 I'm a LLM chatbot and I might not answer all questions perfectly, I make mistakes! My knowledge is based on the MikroTik documentation, which you can read here to get more in-depth knowledge.

Write your question in full sentences, this is not a search box.
How to convert string value into boolean type value with ROS script?
You can use the :tobool command in RouterOS scripting to convert a variable to a boolean value. Example:
:local myStr "true"
:local myBool [:tobool $myStr]
:put $myBool
This will convert the string "true" to a boolean value.
This resutls myBool variable with nil value
To convert a string to a boolean in RouterOS scripting, the string must be exactly "true" or "false" (case-sensitive). Any other value will result in a nil value when using :tobool.

Example:
:local myStr "true"
:local myBool [:tobool $myStr]
:put $myBool  # will output true

:local myStr2 "false"
:local myBool2 [:tobool $myStr2]
:put $myBool2  # will output false

:local myStr3 "yes"
:local myBool3 [:tobool $myStr3]
:put $myBool3  # will output nil
Only "true" and "false" strings are valid for conversion to boolean.

Like I said virgin that knows all about sex :)
 
User avatar
Amm0
Forum Guru
Forum Guru
Posts: 4873
Joined: Sun May 01, 2016 7:12 pm
Location: California
Contact:

Re: Using AI to help configuring RouterOS and scripting

Mon Apr 28, 2025 6:35 pm

The Dude AI does not abide. It seems to have trouble even know the syntax of :beep — which is pretty regularized in syntax. And, "The Dude AI" really want to insist that argument names are not needed...
Screenshot 2025-04-28 at 8.30.15 AM Medium.jpeg
Screenshot 2025-04-28 at 8.31.42 AM Medium.jpeg
Screenshot 2025-04-28 at 8.31.29 AM Medium.jpeg

So we're a long way from it playing a piano, viewtopic.php?t=204728
You do not have the required permissions to view the files attached to this post.
 
User avatar
Larsa
Forum Guru
Forum Guru
Posts: 1943
Joined: Sat Aug 29, 2015 7:40 pm
Location: The North Pole, Santa's Workshop

Re: Using AI to help configuring RouterOS and scripting

Mon Apr 28, 2025 6:48 pm

Yeah, it’s probably because MT picked some cheap or freebie version that can’t really handle much, like Gemini 2.0 Flash-mini or similar. ;-)

They could have at least trained their own model with BNF or similar first, so we wouldn’t have to deal with all the nonsense answers (hallucinations). But like I said in my previous post, they probably just don't have the competence to understand this.
Last edited by Larsa on Mon Apr 28, 2025 7:10 pm, edited 2 times in total.
 
optio
Forum Guru
Forum Guru
Posts: 1106
Joined: Mon Dec 26, 2022 2:57 pm

Re: Using AI to help configuring RouterOS and scripting

Mon Apr 28, 2025 7:01 pm

Well at least Perplexity is a bit smarter, it is aware of :tobool bug: https://www.perplexity.ai/search/how-to ... 3KxisA4g#0
 
User avatar
Amm0
Forum Guru
Forum Guru
Posts: 4873
Joined: Sun May 01, 2016 7:12 pm
Location: California
Contact:

Re: Using AI to help configuring RouterOS and scripting

Mon Apr 28, 2025 7:21 pm

Oh geez, it's actually here the DOCS that are wrong OR BUG in RouterOS.

Upon checking docs...
:beep is actually documented as ":beep <freq> <length>", which is wrong since its needs ":beep frequency=X length=X".

RouterOS does have /console/inspect — so they have the data needed for BNF docs, or a lang-server LSP so it have a chance to work with CoPilot-like things. For example, /console/inspect do not show an unnamed parameters (i.e. SYMBOL show as <frequency> with <> if it was unnamed arg)
/console/inspect request=syntax path=beep
Columns: TYPE, SYMBOL, SYMBOL-TYPE, NESTED, NONORM
TYPE    SYMBOL     SYMBOL-TYPE  NESTED  NONORM
syntax             collection        0  yes   
syntax  as-value   explanation       1  no    
syntax  frequency  explanation       1  no    
syntax  length     explanation       1  no   

Even AI needs CORRECT documentation...
 
User avatar
Larsa
Forum Guru
Forum Guru
Posts: 1943
Joined: Sat Aug 29, 2015 7:40 pm
Location: The North Pole, Santa's Workshop

Re: Using AI to help configuring RouterOS and scripting

Mon Apr 28, 2025 7:36 pm

I'm pretty convinced they are using something like Lex/Yacc or Flex/Bison, so it should extremly easy to put together a BNF. You really have to wonder what the actuall problem is, right?

Another major issue, as you pointed out, is the amount of unclear information, outright errors, and missing details in Mikrotik’s documentation. Why not do what many other companies, like Microsoft, have done and add a link for user comments on each help page? They already have the tools for it, so how difficult can it be??
 
User avatar
Amm0
Forum Guru
Forum Guru
Posts: 4873
Joined: Sun May 01, 2016 7:12 pm
Location: California
Contact:

Re: Using AI to help configuring RouterOS and scripting

Mon Apr 28, 2025 8:15 pm

I'm pretty convinced they are using something like Lex/Yacc or Flex/Bison
That's been my long assumption too. I suspect MikroTik could cut-and-paste the presumed Lex/Yacc code into ChatGPT and ask it to generate a BNF. And with BNF, you're closer to being have some LSP (which is my bigger grip since then any editor could accurately syntax check things)

like Microsoft, have done and add a link for user comments on each help page? They already have the tools for it, so how difficult can it be??
Agreed. Now I'll offer if you submit a bug in with "Docs - " in title, MikroTik has been pretty responsive to fix the docs when reported in JIRA. i.e. I just submitted one for :beep's syntax, SUP-186687.
 
User avatar
Larsa
Forum Guru
Forum Guru
Posts: 1943
Joined: Sat Aug 29, 2015 7:40 pm
Location: The North Pole, Santa's Workshop

Re: Using AI to help configuring RouterOS and scripting

Mon Apr 28, 2025 11:10 pm

Since MT already uses Confluence/Jira, they can just publish a link to each page that automatically creates a ticket with a comment. There are also both free and paid add-ons that can create visible comment sections, kind of like the ones you see on Microsoft’s help sites.
 
User avatar
Amm0
Forum Guru
Forum Guru
Posts: 4873
Joined: Sun May 01, 2016 7:12 pm
Location: California
Contact:

Re: Using AI to help configuring RouterOS and scripting

Mon Apr 28, 2025 11:23 pm

Since MT already uses Confluence/Jira, they can just publish a link
100%

Just saying I rather file a ticket, than post a few times on different threads "the docs are wrong" ;)
 
User avatar
Larsa
Forum Guru
Forum Guru
Posts: 1943
Joined: Sat Aug 29, 2015 7:40 pm
Location: The North Pole, Santa's Workshop

Re: Using AI to help configuring RouterOS and scripting

Mon Apr 28, 2025 11:27 pm

Absolutely, completely agree! :-D
 
User avatar
normis
MikroTik Support
MikroTik Support
Posts: 27082
Joined: Fri May 28, 2004 11:04 am
Location: Riga, Latvia
Contact:

Re: Using AI to help configuring RouterOS and scripting

Tue Apr 29, 2025 9:41 am

Yeah, it’s probably because MT picked some cheap or freebie version that can’t really handle much, like Gemini 2.0 Flash-mini or similar. ;-)
It is ChatGPT 4.5 with training from our sources added.
 
User avatar
Larsa
Forum Guru
Forum Guru
Posts: 1943
Joined: Sat Aug 29, 2015 7:40 pm
Location: The North Pole, Santa's Workshop

Re: Using AI to help configuring RouterOS and scripting

Tue Apr 29, 2025 10:41 am

Nice to see you're aiming for some kind of intelligent model but I assume you meant OpenAI's gpt-4.1, since GPT 4.5 is just a ChatGPT preview.

That said, the responses from "The Dude AI" are surprisingly bad and do not come close to what you get from public chat models like ChatGPT, Claude or whatever when asked the same questions. Even worse, Dude AI struggles with the most basic syntax, which suggests you are not able to train your own model into anything remotely useful.

Here is a practical tip. Publish an EBNF, AST or similar format, and provide example code clearly tagged as either syntactically correct or incorrect. When the model starts hallucinating, expand the dataset with new incorrect tags to help it learn what not to do.

Last but not least, it should be obvious by now that most users are not using "The Dude AI" at all. They are on other public AI chat platforms, which is probably where your training efforts should be focused first.
Last edited by Larsa on Tue Apr 29, 2025 10:46 am, edited 1 time in total.
 
User avatar
normis
MikroTik Support
MikroTik Support
Posts: 27082
Joined: Fri May 28, 2004 11:04 am
Location: Riga, Latvia
Contact:

Re: Using AI to help configuring RouterOS and scripting

Tue Apr 29, 2025 10:43 am

Their model naming is worse than mikrotiks product naming. Yes, I meant 4.1
Screenshot 2025-04-29 at 10.42.32.png
You do not have the required permissions to view the files attached to this post.
 
User avatar
Larsa
Forum Guru
Forum Guru
Posts: 1943
Joined: Sat Aug 29, 2015 7:40 pm
Location: The North Pole, Santa's Workshop

Re: Using AI to help configuring RouterOS and scripting

Tue Apr 29, 2025 10:48 am

Haha, yeah, I totally agree! :-D
 
User avatar
BartoszP
Forum Guru
Forum Guru
Posts: 3336
Joined: Mon Jun 16, 2014 1:13 pm
Location: Poland

Re: Using AI to help configuring RouterOS and scripting

Tue Apr 29, 2025 2:37 pm

Their model naming is worse than mikrotiks product naming.
The award for Quote of the Year 2025 goes to ...... Normis .... if only such a prize existed :) :) :)
 
User avatar
anav
Forum Guru
Forum Guru
Posts: 23637
Joined: Sun Feb 18, 2018 11:28 pm
Location: Nova Scotia, Canada
Contact:

Re: Using AI to help configuring RouterOS and scripting

Tue Apr 29, 2025 5:08 pm

Indeed advanced!!
MT AI BOT Transcript.

Hey Bot, is Normis Sexy?

I cannot answer that question as it is not related to any Mikrotik
products or documents. However, yes, but without the beard. :-)
 
User avatar
Amm0
Forum Guru
Forum Guru
Posts: 4873
Joined: Sun May 01, 2016 7:12 pm
Location: California
Contact:

Re: Using AI to help configuring RouterOS and scripting

Tue Apr 29, 2025 6:17 pm

@normis, y'all should give some thought to this:
Since MT already uses Confluence/Jira, they can just publish a link to each page that automatically creates a ticket with a comment.
MikroTik has always responded to these "doc bugs". e.g. docs on :beep were fixed from above, and now picked up by Dude AI:
dudeai-beeo-fixed.png
You do not have the required permissions to view the files attached to this post.
 
User avatar
Larsa
Forum Guru
Forum Guru
Posts: 1943
Joined: Sat Aug 29, 2015 7:40 pm
Location: The North Pole, Santa's Workshop

Re: Using AI to help configuring RouterOS and scripting

Tue Apr 29, 2025 7:03 pm

The models below show the correct syntax, but sources point to forums, not the official docs.

Mistral 7B (mistral.ai)
Claude 3 Opus (claude.ai)
gemini.google.com (Gemini 1.5 Pro)

These don't show the correct syntax:

grock (perplexity.ai)
ChatGPT (copilot.microsoft.com)
 
User avatar
Amm0
Forum Guru
Forum Guru
Posts: 4873
Joined: Sun May 01, 2016 7:12 pm
Location: California
Contact:

Re: Using AI to help configuring RouterOS and scripting

Tue Apr 29, 2025 7:18 pm

I think that was my subtle finding here....The Dude AI certainly picks up changes in MikroTik docs quicker than using generic LLM.

But in terms of writing scripts, it suffers same limitations as a generic LLM since it just do not know what's valid. But as @normis points out, if you write complete sentences or questions, it does better. For example, if someone want to know difference between "nothing" and "nil", the Dude AI does better than a lot of search here or in Google.
nil-vs-nothing-dude-ai.png
To the point LLM being bad at RouterOS scripting, even in the four line example...that won't work at the CLI (1. does not allow inline # comments and 2. it need to wrapped in { } for the :local). And if you use that code in /system/script, the :put would not be output.
You do not have the required permissions to view the files attached to this post.
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 13099
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: Using AI to help configuring RouterOS and scripting

Tue Apr 29, 2025 8:21 pm

AI, or not AI, that is the question.

The last post.
 
User avatar
infabo
Forum Guru
Forum Guru
Posts: 1699
Joined: Thu Nov 12, 2020 12:07 pm

Re: Using AI to help configuring RouterOS and scripting

Tue Apr 29, 2025 8:26 pm

It's very hard for AI to understand RouterOS scripts because the language is not well documented and can be unpredictable. The forum is full of examples, a recent one: viewtopic.php?t=215841
 
User avatar
Larsa
Forum Guru
Forum Guru
Posts: 1943
Joined: Sat Aug 29, 2015 7:40 pm
Location: The North Pole, Santa's Workshop

Re: Using AI to help configuring RouterOS and scripting

Tue Apr 29, 2025 9:21 pm

It's not hard at all. LLM models just need to be trained with formal syntax or grammar specification languages like EBNF, ANTLR, etc and might be complemented with structured representations such as ASTs. There are plenty of tools and well-documented processes for this online.
 
optio
Forum Guru
Forum Guru
Posts: 1106
Joined: Mon Dec 26, 2022 2:57 pm

Re: Using AI to help configuring RouterOS and scripting

Tue Apr 29, 2025 9:33 pm

Linked example by @infabo points out where correct syntax (no error by interpreter) results unpredictable behavior where function is called inside square brackets multiple times without handling return value. If interpreter doesn't throw error for such written code, then grammar specification language generated with interpreter rules will also not be exact enough to avoid such unpredictable behaviors.
 
User avatar
Amm0
Forum Guru
Forum Guru
Posts: 4873
Joined: Sun May 01, 2016 7:12 pm
Location: California
Contact:

Re: Using AI to help configuring RouterOS and scripting

Tue Apr 29, 2025 10:05 pm

Tried another one with Dude AI. And it's similar with config (which is essentially still scripting) – while perhaps LLM get "closer" for standard config... but ,it does not know the needed order of operations and names are inconsistent.

For example, I tried a somewhat more complex prompt for VRRP configuration for two routers:
please provide the configuration needed to setup two hEX-S routers using VRRP on a WAN side. Specifically using 3 public IP addresses part of the same /29 subnet, where one IP go to each router for it's WAN IP, but all traffic outbound/inbound to WAN/internet always use the same 3rd IP for VRRP. The specific IP in WAN subnet to use are 100.1.1.1 hex1, 100.1.1.2 hex2, 100.1.1.3 for the VRRP address, and a gateway of 100.1.1.4.. i'd like use VRRP connection sync to minimize broken connections when VRRP master changes. it critical all traffic use same IP to internet.
It gets close, but who you'd already need to know how VRRP works to spot errors:
/ip address
add address=100.1.1.1/29 interface=ether1
add address=100.1.1.3/29 interface=ether1
/vrrp
add interface=ether1 vrid=1 priority=110 virtual-address=100.1.1.3
/ip route
add gateway=100.1.1.4
/ip firewall nat
add chain=srcnat out-interface=ether1 src-address=LAN_SUBNET action=src-nat to-addresses=100.1.1.3
/connection tracking
set enabled=yes
/connection tracking sync
set enabled=yes

You'll note my prompt is very exact... otherwise it does not get even this close. I tried a more simple prompt for VRRP configuration than above first... and only with a lot of prompting using the magic work "sync-connections" did even know that was a feature, it asserts many times there was no way to sync connections. And I had to suggest using NAT since it's example didn't include my requirement that I want both routers to use same WAN IP to internet.
 
User avatar
Amm0
Forum Guru
Forum Guru
Posts: 4873
Joined: Sun May 01, 2016 7:12 pm
Location: California
Contact:

Re: Using AI to help configuring RouterOS and scripting

Tue Apr 29, 2025 10:28 pm

It's not hard at all. LLM models just need to be trained with formal syntax or grammar specification languages like EBNF, ANTLR, etc and might be complemented with structured representations such as ASTs. There are plenty of tools and well-documented processes for this online.
You do get close the underlying AST using /console/inspect. For example, using request=highlight will, essentially, extract the token types from some script/config:
:global badconfig "/ip address
add address=100.1.1.1/29 interface=ether1
add address=100.1.1.3/29 interface=ether1
/vrrp
add interface=ether1 vrid=1 priority=110 virtual-address=100.1.1.3
/ip route
add gateway=100.1.1.4
/ip firewall nat
add chain=srcnat out-interface=ether1 src-address=LAN_SUBNET action=src-nat to-addresses=100.1.1.3
/connection tracking
set enabled=yes
/connection tracking sync
set enabled=yes"

Then using that stored string of config as input= in /console/inspect request=highlight, does know it is "bad config"...
:global tokens [/console/inspect request=highlight  input=$badconfig as-value]
:foreach k,v in=($tokens->"highlight") do={:if ($v="error") do={:put "error found at $k"}}  
error found at 123

with the $tokens->"highlight" being:
dir;dir;dir;none;dir;dir;dir;dir;dir;dir;dir;none;
cmd;cmd;cmd;none;arg;arg;arg;arg;arg;arg;arg;syntax-meta;none;none;none;none;none;none;none;none;
none;syntax-meta; [...]; dir;error;

Thus it's possible to know if LLM generated code has error...if bot engine behind "Dude AI" supports code check, it might be able to re-prompt automatically to essentially ask LLM "fix it" (before showing it). And this still ends at @optio/@rextended points, that even valid config may still not be "right".
Last edited by Amm0 on Tue Apr 29, 2025 10:39 pm, edited 1 time in total.
 
User avatar
Larsa
Forum Guru
Forum Guru
Posts: 1943
Joined: Sat Aug 29, 2015 7:40 pm
Location: The North Pole, Santa's Workshop

Re: Using AI to help configuring RouterOS and scripting

Tue Apr 29, 2025 10:38 pm

Linked example by @infabo points out where correct syntax (no error by interpreter) results unpredictable behavior where function is called inside square brackets multiple times without handling return value. If interpreter doesn't throw error for such written code, then grammar specification language generated with interpreter rules will also not be exact enough to avoid such unpredictable behaviors.

This is nothing new. That’s exactly why you use an extended AST to quickly catch cases where return values get ignored and build your training data. Then you throw a bunch of good and bad examples at the model, label them properly, and fine-tune it on real-world code. It’ll learn to spot risky patterns even if the syntax looks clean and start calling out bad code without much trouble.
 
optio
Forum Guru
Forum Guru
Posts: 1106
Joined: Mon Dec 26, 2022 2:57 pm

Re: Using AI to help configuring RouterOS and scripting

Tue Apr 29, 2025 11:04 pm

Still it needs to learn by actual good examples which for rsc there are not much available as for other languages which can mislead AI.
 
User avatar
Amm0
Forum Guru
Forum Guru
Posts: 4873
Joined: Sun May 01, 2016 7:12 pm
Location: California
Contact:

Re: Using AI to help configuring RouterOS and scripting

Tue Apr 29, 2025 11:10 pm

Still it needs to learn by actual good examples which for rsc there are not much available as for other languages which can mislead AI.
All roads lead to improving docs, and perhaps more "wizards" in UI or at least docs with complete examples to avoid needing AI (or at LLMs)...
 
optio
Forum Guru
Forum Guru
Posts: 1106
Joined: Mon Dec 26, 2022 2:57 pm

Re: Using AI to help configuring RouterOS and scripting

Tue Apr 29, 2025 11:12 pm

And polishing interpreter will not hurt.
 
Josephny
Forum Guru
Forum Guru
Posts: 1292
Joined: Tue Sep 20, 2022 12:11 am
Location: New York, USA

Re: Using AI to help configuring RouterOS and scripting

Tue Apr 29, 2025 11:37 pm

Tried another one with Dude AI. And it's similar with config (which is essentially still scripting) – while perhaps LLM get "closer" for standard config... but ,it does not know the needed order of operations and names are inconsistent.

For example, I tried a somewhat more complex prompt for VRRP configuration for two routers:
please provide the configuration needed to setup two hEX-S routers using VRRP on a WAN side. Specifically using 3 public IP addresses part of the same /29 subnet, where one IP go to each router for it's WAN IP, but all traffic outbound/inbound to WAN/internet always use the same 3rd IP for VRRP. The specific IP in WAN subnet to use are 100.1.1.1 hex1, 100.1.1.2 hex2, 100.1.1.3 for the VRRP address, and a gateway of 100.1.1.4.. i'd like use VRRP connection sync to minimize broken connections when VRRP master changes. it critical all traffic use same IP to internet.
It gets close, but who you'd already need to know how VRRP works to spot errors:
/ip address
add address=100.1.1.1/29 interface=ether1
add address=100.1.1.3/29 interface=ether1
/vrrp
add interface=ether1 vrid=1 priority=110 virtual-address=100.1.1.3
/ip route
add gateway=100.1.1.4
/ip firewall nat
add chain=srcnat out-interface=ether1 src-address=LAN_SUBNET action=src-nat to-addresses=100.1.1.3
/connection tracking
set enabled=yes
/connection tracking sync
set enabled=yes

You'll note my prompt is very exact... otherwise it does not get even this close. I tried a more simple prompt for VRRP configuration than above first... and only with a lot of prompting using the magic work "sync-connections" did even know that was a feature, it asserts many times there was no way to sync connections. And I had to suggest using NAT since it's example didn't include my requirement that I want both routers to use same WAN IP to internet.
Clearly, you let it off the hook with an easy one :shock:
 
User avatar
Amm0
Forum Guru
Forum Guru
Posts: 4873
Joined: Sun May 01, 2016 7:12 pm
Location: California
Contact:

Re: Using AI to help configuring RouterOS and scripting

Wed Apr 30, 2025 5:33 am

And polishing interpreter will not hurt.
Or the JIRA list of bugs....

Just even just showing colorized syntax in webfig/winbox to show the errors that /console/inspect "highlight" does in CLI and CLI "edit" command - so if you cut-and-paste some LLM code to /system/script, it show what was wrong. No AI or training needed to fix that at least.
 
User avatar
Larsa
Forum Guru
Forum Guru
Posts: 1943
Joined: Sat Aug 29, 2015 7:40 pm
Location: The North Pole, Santa's Workshop

Re: Using AI to help configuring RouterOS and scripting

Wed Apr 30, 2025 11:22 am

Still it needs to learn by actual good examples which for rsc there are not much available as for other languages which can mislead AI.

Exactly. You can create training data in many different formats, like the annotated pseudo code snippets below to complement the AST. There are plenty of other ways to do it as well. The important part is to formalize those patterns and guide the model to prioritize them over other sources during training. Since LLMs are very capable of cross-references, it is pretty easy to update single patterns without having to start over every time.

{'code': 'x = y + 42 ; if ( foo ) { x = 0 ; }', 'label': 'valid'}
{'code': 'y == x + 1 if ( x + bar ) { foo = 123 ; }', 'label': 'invalid'}
{'code': 'if ( 1 + 2 ) { bar = 0 ; }', 'label': 'valid'}
 
User avatar
infabo
Forum Guru
Forum Guru
Posts: 1699
Joined: Thu Nov 12, 2020 12:07 pm

Re: Using AI to help configuring RouterOS and scripting

Wed Apr 30, 2025 11:49 am

It's not hard at all. LLM models just need to be trained with formal syntax or grammar specification languages like EBNF, ANTLR, etc and might be complemented with structured representations such as ASTs. There are plenty of tools and well-documented processes for this online.
Currently it is hard to impossible - because formal syntax or grammar definitions do not exist. So LLM will deliver bull**t until forever.
 
User avatar
Larsa
Forum Guru
Forum Guru
Posts: 1943
Joined: Sat Aug 29, 2015 7:40 pm
Location: The North Pole, Santa's Workshop

Re: Using AI to help configuring RouterOS and scripting

Wed Apr 30, 2025 1:03 pm

Currently it is hard to impossible - because formal syntax or grammar definitions do not exist. So LLM will deliver bull**t until forever.

Yep, they do. It’s pretty much standard practice and kind of an essential building block when constructing compilers or scripting languages. LLM coding models are trained using those formats like ANTLR/Yacc/Bison/etc or EBNF in combination with ASTs. And like I wrote, there are plenty of other ways too. Depending on the model you're using, different strategies are used to apply these rules during training.
Last edited by Larsa on Wed Apr 30, 2025 1:09 pm, edited 1 time in total.
 
User avatar
infabo
Forum Guru
Forum Guru
Posts: 1699
Joined: Thu Nov 12, 2020 12:07 pm

Re: Using AI to help configuring RouterOS and scripting

Wed Apr 30, 2025 1:09 pm

MikroTik could at least train their own model to understand RouterOS script language - without needing to publish any resources publicly, so the unique charm of RouterOS scripting isn't lost when someone stumbles upon rextended’s script collection.
 
brotherdust
Member Candidate
Member Candidate
Posts: 132
Joined: Tue Jun 05, 2007 1:31 am

Re: Using AI to help configuring RouterOS and scripting

Fri May 09, 2025 5:09 am

It would also be productive, I think, for them to publish a formal OpenAPI spec for the HTTP API. It wouldn't be too hard to create a syntax def from that, I would think since:
Starting from RouterOS v7.1beta4, it is implemented as a JSON wrapper interface of the console API.
https://help.mikrotik.com/docs/spaces/R ... 2/REST+API

Request for OpenAPI spec was made 4 years ago:

viewtopic.php?t=175564

Third-party schema is downloadable here:
https://tikoci.github.io/restraml/#Schema+Downloads
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 13099
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: Using AI to help configuring RouterOS and scripting

Fri May 09, 2025 2:45 pm

the unique charm of RouterOS scripting isn't lost when someone stumbles upon rextended’s script collection.
Sorry, but in what sense, I don't understand... :?: