Community discussions

User avatar
Topic Author
Posts: 428
Joined: Fri May 28, 2004 6:14 pm
Location: Missouri, USA

creating dhcp leases (mac math)

Wed Sep 04, 2019 7:28 pm

I am trying to duplicate an issue reported by a customer. The specific issue is that he has about 4k static dhcp leases (written by a billing system) and he cannot export that list for backup. He can VIEW the list (all 4k), but on export, he only gets the first 1000 items in the list. SO...I am trying to create a list of 4k (or even 1001) mac addresses in a lease table and not sure how to easily do this. I thought perhaps I could do something like a loop like:
:local INITIALMAC "00:00:00:00:00:00"
:for i from=1 to=2000 do={
	:local NEWMAC [[$"INITIALMAC"] + $"i"]
	:put "NEWMAC is $"NEWMAC""
        /ip dhcp-server lease add mac-address="$"NEWMAC"" 
Any ideas how to either fix the issue in export OR how to do this mac-mathematics?
Butch Evans
Mikrotik Certified Trainer
Mikrotik Certified Consultant
User avatar
Member Candidate
Member Candidate
Posts: 148
Joined: Sun Jan 06, 2013 11:19 pm
Location: Poland

Re: creating dhcp leases (mac math)

Fri Sep 06, 2019 1:20 am

Maybe it's just standard limitation at variable feature. ... #Variables -> "Note: Variable value size is limited to 4096bytes"

You can use a build-in in MikroTik function to generate MacAddress (every new EoIP have it uniq).
interface eoip remove [find name=temp-temp]
for i from=1 to=5000 do={
put "***** $i *****"
interface eoip add name=temp-temp remote-address= tunnel-id=65535
ip dhcp-server lease add comment="test-test" mac-address=[/interface eoip get temp-temp mac-address ]
interface eoip remove [find name=temp-temp]
delay 15ms
~600 entry in 1 minute.
if break then re-run again.
Count current iterations: ip dhcp-server lease print count-only where comment=test-test
Works with 6394 lease entry's by: export file=test ; #test.rsc with 385.8 KiB

After testing clean-up by: ip dhcp-server lease remove [find comment=test-test]

Maybe they have a problem with: "backup,critical: error creating backup file: could not read all configuration files" who shows only at terminal echo log action and only netinstall can help.
Maybe they reach problem with "ending export in random place" who I know as "not completed export file" happens when you in one script generate and send by e-mail this export.
Maybe they can create a Supout.rif - anyone and you can check it content in account - you can check if supout.rif have got >4000 leases .
MTCNA + MTCRE + MTCINE | ~600 users at ~150 RouterBoards in EMEA | Telegram: @SiB_PL | WebChat: Tokonda

Who is online

Users browsing this forum: No registered users and 8 guests