Block hostname changing their mac address

Block hostname changing their mac address


and will this script work on v6.X
:local hosts [/ip dhcp-server lease find]
:local pcname ""
:local pcnum 0
:global hacklist ""

To log the value of $hacklist each hour, make debug 1 (if $hacklist is blank, nothing will be logged)

:local debug 1

:foreach h1 in=$hosts do={
:local host [/ip dhcp-server lease get $h1 host-name]
:if ([:len $host] >0) do {
:set pcname ($pcname . "," . $host)
:set pcnum ($pcnum + 1)
}
}

:local pcnameArr [:toarray $pcname];

:foreach h2 in=$pcnameArr do={
:local hh 0
:if (!([:find $hacklist $h2]>=0)) do={
:foreach k in=$pcnameArr do={ :if ($k=$h2) do={:set hh ($hh + 1) } }
:if ($hh>2) do={
:if ([:len $hacklist] >0) do {:set hacklist ($hacklist . "," . $h2)} else={:set hacklist $h2}
}
}
}

monitor results in logfile once an hour

:local timer [:pick [/system clock get time] 3 5]
:if (($debug > 0) || ($timer >= "58")) do={
:if ([:len $hacklist] >0) do={
:log warning ("New Hacklist: " . $hacklist)
}
}

:local host
:local ipnum
:local unum
:local usr
:local i
:global hacklist

:foreach host in=$hacklist do={
:foreach i in= [/ip dhcp-server lease find host-name=$host] do={
:set ipnum [/ip dhcp-server lease get $i address]
:set unum [/ip hotspot active find address=$ipnum]
:if ([:len $unum] >0) do {
:set usr [/ip hotspot active get $unum user]
:log warning ($host . " " . $ipnum . " " . $usr)
/ip hotspot active remove $unum
}
}
}

Hey this could be really useful! Will test in a reall world enviroment soon. Thank you :smiley:

I tested in 6.35 its not working