That looks like LUA code! If you had a router that run it, you’d need to upgrade it ASAP anyway for security vulnerabilities.
They changed scripting languages at some point before my time (maybe V5). MT built there own scripting language to replace it, and that’s what’s been used for at 5+ years. But in V6 and V7 RouterOS, you can use use IP>Cloud to do DDNS, then your actual DNS domain add a CNAME to that.
Certainly it be possible to write a script to directly talk to your DDNS provider, but more complex solution. /ip/cloud with CNAME is pretty easy.
you need a source=“” around the around script to add it via CLI
it the lines need to be escaped…
a “command verb” like “add” and it’s arguments should be together (e.g. on the same line) too
It generally easier to use webfig or winbox to cut-and-paste a script into the “source” in the UI. At the command line, you need to deal with escaping and line continuations… And, if you cut-and-paste using UI, you can then do an “/system script export” via CLI which will show all the needed escaping to use elsewhere (e.g. what’s below).
So this:
/system script
add name=Netcup policy=read,write,test source=":global apikey \"KEY\"\r\
\n:global apipassword \"PASSWORD\"\r\
\n:global customerid \"CUSTOMERNR\"\r\
\n:global theinterface \"WAN1\"\r\
\n:global ddnshost \"subdomain.domain.de\"\r\
\n:global ipddns [:resolve \$ddnshost];\r\
\n:global ipfresh [ /ip address get [/ip address find interface=\$theinterface ] address ]\r\
\n:if ([ :typeof \$ipfresh ] = nil ) do={\r\
\n:log info (\"NetcupDDNS: No IP address on \$theinterface .\")\r\
\n} else={\r\
\n:for i from=( [:len \$ipfresh] - 1) to=0 do={\r\
\n:if ( [:pick \$ipfresh \$i] = \"/\") do={\r\
\n:set ipfresh [:pick \$ipfresh 0 \$i];\r\
\n}\r\
\n}\r\
\n:if (\$ipddns != \$ipfresh) do={\r\
\n:log info (\"NetcupDDNS: IP-Netcup = \$ipddns\")\r\
\n:log info (\"NetcupDDNS: IP-Fresh = \$ipfresh\")\r\
\n:log info \"NetcupDDNS: Update IP needed, Sending UPDATE...!\"\r\
\n:global jsonRequestBody \"{json request body with new IP and other necessary info}\"\r\
\n/tool fetch url=\"https://ccp.netcup.net/run/webservice/servers/endpoint.php\?JSON\" http-method=post http-data=\$jsonRequestBody mode=https dst-p\
ath=(\"/Netcup.\".\$ddnshost)\r\
\n:delay 1\r\
\n:global str [/file find name=\"Netcup.\$ddnshost\"];\r\
\n/file remove \$str\r\
\n:global ipddns \$ipfresh\r\
\n:log info \"NetcupDDNS: IP updated to \$ipfresh!\"\r\
\n} else={\r\
\n:log info \"NetcupDDNS: dont need changes\";\r\
\n} }"
:global jsonRequestBody "{json request body with new IP and other necessary info}"
That won’t work either. I don’t know where you got that script from, but perhaps there was some help on configuring it for your provider… as seem some specific details need to provided in the script.
I kinda think using the built-in /ip/cloud DDNS support be best. Then add a CNAME in your Netcup domain configuration, that points to the Mikrotik cloud DNS name (e.g. .mynetname.com).