Community discussions

MikroTik App
 
thaplaya
just joined
Topic Author
Posts: 6
Joined: Fri Jul 31, 2009 12:48 am

Script for MAC Authentication???

Mon Aug 10, 2009 2:56 am

I need a script for automaticaly check and uncheck tha Radius MAC Authentication box by time limit. For example to uncheck in 9 AM and check in 4 PM.
 
dssmiktik
Forum Veteran
Forum Veteran
Posts: 732
Joined: Fri Aug 17, 2007 8:42 am

Re: Script for MAC Authentication???

Wed Aug 12, 2009 11:15 am

just parse /system clock time and run appropriate command to change radius mac auth setting.
 
thaplaya
just joined
Topic Author
Posts: 6
Joined: Fri Jul 31, 2009 12:48 am

Re: Script for MAC Authentication???

Thu Aug 13, 2009 6:32 pm

Sorry I don't know what you mean? :(
 
dssmiktik
Forum Veteran
Forum Veteran
Posts: 732
Joined: Fri Aug 17, 2007 8:42 am

Re: Script for MAC Authentication???

Thu Aug 13, 2009 10:44 pm

# Get numeric time
# Ex. if clock time is 12:31, time = 1231
# Ex. if clock time is 09:23, time = 923

:local time ""
:set time [/system clock get time]
:set time ([:pick $time 0 2] . [:pick $time 3 5])

# remove leading zeros from time
:local loop 1
:local index 0
:while ($loop = 1 && $index < [:len $time]) do={
  :if ([:pick $time $index ($index + 1)] != "0") do={
    :set time [:pick $time $index [:len $time]]
    :set loop 0
  }
  :set index ($index + 1)
}

# between 9 AM and 4 PM
:if ($time > 900 && $time < 1600) do={
  :put "It's between 9 AM and 4 PM"
  /interface wireless security-profiles set 0 radius-mac-authentication=no
}

# after 4 PM or before 9 AM
:if ($time > 1600 || $time < 900) do={
  :put "It's between 4 PM and 9 AM"
  /interface wireless security-profiles set 0 radius-mac-authentication=yes
}

:put $time
 
fewi
Forum Guru
Forum Guru
Posts: 7717
Joined: Tue Aug 11, 2009 3:19 am

Re: Script for MAC Authentication???

Fri Aug 14, 2009 8:09 pm

Maybe I'm missing something here, but wouldn't it be easiest to do this via the scheduler?

First, create one script to disable the property, and then another one to enable it:
/system script add name="DisableRADIUSMAC" source="/interface wireless security-profiles set 0 radius-mac-authentication=no"
/system script add name="EnableRADIUSMAC" source="/interface wireless security-profiles set 0 radius-mac-authentication=yes"
And then add two scheduled jobs running at 9am and 4pm, firing the scripts:
/system scheduler add start-date=aug/14/2009 start-time=09:00:00 interval=1d on-event=DisableRADIUSMAC
/system scheduler add start-date=aug/14/2009 start-time=16:00:00 interval=1d on-event=EnableRADIUSMAC
Hope that helps,
Felix
 
dssmiktik
Forum Veteran
Forum Veteran
Posts: 732
Joined: Fri Aug 17, 2007 8:42 am

Re: Script for MAC Authentication???

Sat Aug 15, 2009 12:09 am

fewi,

that sounds like a better idea since we're dealing with a time related task
 
thaplaya
just joined
Topic Author
Posts: 6
Joined: Fri Jul 31, 2009 12:48 am

Re: Script for MAC Authentication???

Sun Aug 16, 2009 6:35 pm

Tnx this help me a lot. And it works well :)

Who is online

Users browsing this forum: No registered users and 25 guests