A
A
Ashot Aslanyan2020-02-13 10:31:44
Mikrotik
Ashot Aslanyan, 2020-02-13 10:31:44

How can I turn this line 192.168.0.1/24 into this 192.168.0.0/24 with a command?

Hello. help me please.

:local addr1;

:foreach i in=[/ip address find] do={
:set addr1 [/ip address get $i address];

:log info "$addr1";
}

now so. what is written in the logs is what is in / ip address
, for example, 192.168.0.1/24.
and I need that in addition to the fact that we have entered all the addresses in the $addr1 variable with the help of :foreach i in=....
I also need to change the IP of the address to their network in the variable.
For example. if the grid is in the variable 192.168.0.1/24, then make the following :set command so that it turns out like this
192.168.0.0/24. eventually go from any grid in the $addr1 variable from the end minus 3 characters, these three characters are a mask and a slash, and then do minus -1. as?

192.168.0.1/24 to get 192.168.0.0/24

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Drill, 2020-02-13
@fellliche

:local IPprefix 192.168.0.1/24;
:local IP [:pick $IPprefix 0 [:find $IPprefix "/"]];
:local NETprefix ([:tostr ([:toip $IP] - 1)] . "/24");
:local NETprefix ();

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question