Community discussions

MikroTik App
 
timd93
just joined
Topic Author
Posts: 10
Joined: Sun Feb 22, 2015 7:18 pm

Creating dhcp client after new interface seems to fail.

Wed Jan 18, 2017 3:55 pm

Hi

I've been working on a script that does the following:
1) create a new virtual interface
2) create a new ip dhcp client for that interface.

Now, my script works up until the point of creating the dhcp client.
For some reason it is not being created, I think it has to do with the fact that I create the dhcp client to fast after creating the interface.

Anyone have a possible solution for this issue?

Thanks!

:global SSID "Test";
:global AmountOfClients 5;
:global SecurityProfile "TNDefault";
:global MasterInterface "wlan1";
:global VirtualClientPrefix ("virt-" . $MasterInterface . "-");
#ONLY CHANGE VARIABLES ABOVE THIS LINE
:for i from=1 to=$AmountOfClients step=1 do={
	#create new 2.4GHz virtual client
	/interface wireless add master-interface=$MasterInterface mode=station security-profile=$SecurityProfile ssid=$SSID name=($VirtualClientPrefix . $i);
	#create DHCP client for virtual client
	/ip dhcp-client add interface=($VirtualClientPrefix . $i) disabled=no;
}
 
gustavomam
Trainer
Trainer
Posts: 287
Joined: Tue Jul 23, 2013 6:29 pm
Location: Spain
Contact:

Re: Creating dhcp client after new interface seems to fail.

Wed Jan 18, 2017 5:11 pm

Hello.

You could put a delay timer between rules, maybe routerOS need a second to realize the new interface.