A
A
Ashot Aslanyan2020-02-12 16:36:30
Mikrotik
Ashot Aslanyan, 2020-02-12 16:36:30

How to generate the following list in dhcp-server -> networks?

How to generate the following list in dhcp-server -> networks?

How can the script generate all subnets of ip addresses from /ip addresses to /ip dhcp-server network ?

there are a lot of lists of addresses in /ip addresses, so I want them to get into /ip dhcp-server network with one command for further organization of dhcp.

An example in the picture is how it should look.

5e43ff4ce9bc8654177383.jpeg

Answer the question

In order to leave comments, you need to log in

2 answer(s)
X
xBrowser, 2020-02-12
@xBrowser

Mikrotik has a well-developed scripting language .
Accordingly, any configuration manipulations are easy to perform with its help.
We take a list of addresses and subnets, or we drive it into an array or in a loop working with each line.
The second way is below:

{
:local addr; 
:local net; 
:foreach v in=[/ip add find] do={ 
   :set addr [/ip add get $v address]; 
   :set net [/ip add get $v network]; 
   :put ("$addr $net");
   }
}

From an array or variable, we add dhcp-server networks in a loop, if necessary, adding checks for existing subnets.

W
Wexter, 2020-02-12
@Wexter

/ip address export

edit the output under /ip dhcp-server networks in some editor and upload it back

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question