How to Create an Automatic Queue on Mikrotik

To create automatic queues in MikroTik, you can use scripts to simplify the process, especially when managing multiple devices or IPs. Here's a general approach:
 

1. Using DHCP Lease Script

Go to IP > DHCP Server.
Select your DHCP server and add a script in the "Lease Script" section.

Example script:

:if ($leaseBound = 1) do={ /queue simple add name="$leaseActMAC" target="$leaseActIP" max-limit=2M/2M }

This script automatically creates a queue for each device that connects to the DHCP server.

2. Batch Queue Creation with a Script

Navigate to System > Scripts and create a new script.

Example script:

:for i from=2 to=254 do={ /queue simple add name="User_$i" target="192.168.1.$i" max-limit=1M/1M }

This script generates queues for a range of IP addresses.

3. Testing and Monitoring

Check the Queues section to ensure the rules are applied correctly.
Adjust bandwidth limits (max-limit) as needed.

a simple configuration example is as follows:

# Queue script with burst speed :local queueName "Client- $leaseActMAC"; :if ($leaseBound = "1") do={ /queue simple add name=$queueName target=($leaseActIP . "/32") parent=interface-name max-limit=1152k/1152k burst-threshold=1280k/1280k burst-limit=1532k/1532k burst-time=40/40 comment=[/ip dhcp-server lease get [find where active-mac-address=$leaseActMAC && active-address=$leaseActIP] host-name]; } else={ /queue simple remove $queueName } }
Scroll to top
Code Copied!