R
R
Ruslan-Strannik2020-07-26 14:21:09
Command line
Ruslan-Strannik, 2020-07-26 14:21:09

How to change Mikrotik script?

good afternoon.
There are scripts on several Mikrotik routers. There was a need to change the IP address in the script.
How can this be done with a command in the terminal?
I'm not strong in scripts yet. I reviewed a bunch of examples, but did not find how to replace the desired value in the script.
Tell me, please.

Added.
in the body of the script, you need to change one value. the script itself is pretty simple. by netwatch changes ip address in pptp connection.

script
/system script
add name=ISP1 policy=ftp,reboot,read,write,policy,test,password,sniff,sensitive source=\
"/interface pptp-client set pptp-out1 connect-to=1.1.1.1"
add name=ISP2 policy=ftp,reboot,read,write,policy,test,password,sniff,sensitive source=\
"/interface pptp-client set pptp-out1 connect-to=2.2.2.2"
/tool netwatch
add down-script=ISP2 host=2.2.2.2 up-script=ISP1

here is the address 2.2.2.2 needs to be changed.

recently implemented a mechanism for mass connection to Mikrotik via ssh and executing the necessary commands.
Here is the problem)) I do not know how to express the command.

For now, delete the script and create an updated one. and in netwatch it's easier
/tool ​​netwatch set [find host=2.2.2.2] host=3.3.3.3

Answer the question

In order to leave comments, you need to log in

2 answer(s)
P
poisons, 2020-07-26
@Ruslan-Strannik

If the script is stored on Mikrotik, then there is no way to change only part of it. It must be read by an external system in its entirety, changed the desired part and uploaded back.
In your situation, you can specify a domain name, even a non-existent one, and add a static entry to the DNS with the desired ip. By changing the ip you will solve your problem.

K
kprohorow, 2020-07-26
@kprohorow

If 1.1.1.1 and 2.2.2.2 in your case are the external addresses of the main pptp server running RouterOS, then you can use the built-in dyndns function.
And do without scripts at all.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question