Community discussions

MikroTik App
 
rayleenac
just joined
Topic Author
Posts: 1
Joined: Mon Mar 18, 2024 9:51 am

Automatic DHCP Queue script

Mon Mar 18, 2024 10:01 am

I am trying to create an automatic dhcp queue script for 3 groups of users, I am able to get the two groups for work, but for some reason the vipDevices are not working, it is not picking up the keywords and queuing them as vipDevices
/queue simple remove [/queue simple find]
:global mobileDevices "android|ANDROID|AppleWatch|BLACKBERRY|Galaxy|HTC|Huawei|iPad|iPhone|iphone|iPhne|Moto|SAMSUNG|Unknown|HUAWEI|Dalton|OPPO|A04|Xperia|Redmi|Nokia|Hisense|JLN|A13|A54|vivo|V2310"
:global mobileLimit "512k/512k"
:global pcLimit "2M/5M"
:global vipLimit "10M/10M"

:global vipDevices "W52P|SubPakstoor|Grant|ANIKA|Sub|VIPdesktops|VIPlaptops|VIPdevice|VIPservers|MikroTik|CapAC"
:global vipLimit "10M/10M"

/ip dhcp-server lease {
:foreach i in=[find (dynamic && status="bound")] do={
:local activeAddress [get $i active-address]
:local activeMacAddress [get $i active-mac-address]
:local macAddress [get $i mac-address]
:local hostname [get $i host-name]
:local ipAddr [get $i address]
:local queueName "Client - $macAddress"

:if ($hostname ~ $mobileDevices= true) do={
/queue simple add name="$queueName" comment="$hostname" target="$ipAddr" max-limit="$mobileLimit"
} else={
/queue simple add name="$queueName" comment="$hostname" target="$ipAddr" max-limit="$pcLimit"
}
}
}

/ip dhcp-server lease {
:foreach i in=[find (!dynamic && status="bound")] do={
:local activeAddress [get $i active-address]
:local activeMacAddress [get $i active-mac-address]
:local macAddress [get $i mac-address]
:local hostname [get $i host-name]
:local ipAddr [get $i address]
:local queueName "Client - $macAddress"

:if ($hostname ~ $vipDevices= true) do={
/queue simple add name="$queueName" comment="$hostname" target="$ipAddr" max-limit="$vipLimit"
} else={
/queue simple add name="$queueName" comment="$hostname" target="$ipAddr" max-limit="$pcLimit"
}
}
}

Who is online

Users browsing this forum: No registered users and 6 guests