Community discussions

MikroTik App
 
reyaustine
just joined
Topic Author
Posts: 6
Joined: Mon Sep 21, 2020 5:02 am

DHCP Lease to IP Binding

Mon Sep 21, 2020 5:04 am

I need help to run my script
:foreach i in=[/ip dhcp-server lease find  host-name~"D-"] do={
     :local dynamicHOST [/ip dhcp-server lease get $i host-name];
     :local date [ /system clock get date ];
     :local mac [/ip dhcp-server lease get $i mac-address];
     
     /ip hotspot ip-binding add type=bypassed mac-address=$mac address=0.0.0.0 comment=$dynamicHOST
   :log info ($mac. "     ".$dynamicHOST." ".$date." Done");
}
 
reyaustine
just joined
Topic Author
Posts: 6
Joined: Mon Sep 21, 2020 5:02 am

Re: DHCP Lease to IP Binding

Mon Sep 21, 2020 12:51 pm

Just found the solution today
Basically the goal is to scan leases and making them static then adding some rate limit and putting them to IP binding as bypassed.
     :foreach i in=[/ip dhcp-server lease find  host-name~"D-"] do={
     :local host [/ip dhcp-server lease get $i host-name];
     :local ip [/ip dhcp-server lease get $i address];
     :local date [ /system clock get date ];
     :local mac [/ip dhcp-server lease get $i mac-address];
     :foreach binding in=[/ip hotspot ip-binding find address=$ip] do={
        /ip hotspot ip-binding remove $binding;
        }
    /ip hotspot ip-binding add type=bypassed mac-address=$mac address=$ip comment=$host;
      :log info ($mac. "     ".$dynamicHOST." ".$date." Done");
     }

/ip dhcp-server lease
:foreach i in=[/ip dhcp-server lease find  host-name~"D-"] do={
  make-static $i
  set $i rate-limit=10M/10M
  set $i comment=[/system clock get date]
}

Who is online

Users browsing this forum: No registered users and 3 guests