{"id":263,"date":"2025-06-02T12:40:06","date_gmt":"2025-06-02T06:40:06","guid":{"rendered":"https:\/\/bytegeeks.net\/blog\/?p=263"},"modified":"2025-07-08T17:06:20","modified_gmt":"2025-07-08T11:06:20","slug":"mikrotik-dhcp-script-to-add-simple-queue-automatically","status":"publish","type":"post","link":"https:\/\/bytegeeks.net\/blog\/mikrotik-dhcp-script-to-add-simple-queue-automatically\/","title":{"rendered":"Mikrotik DHCP script to add simple queue automatically"},"content":{"rendered":"\n<p>Having hundreds of static queues that are dormant often takes up your CPU cycles and slows down the router. To better handle this, it is often ideal to add simple queues dynamically only for active leases. To achieve this, use the following <a href=\"https:\/\/bytegeeks.net\/blog\/category\/mikrotik\/\" target=\"_blank\" rel=\"noreferrer noopener\">mikrotik<\/a> DHCP script to add simple queues automatically. This reduces the clutter in queues as well as helps reduce CPU load and process bandwidth management efficiently.<\/p>\n\n\n\n<p>Add the script in <code>IP&gt;DHCP Server&gt;DHCP&gt;server 1&gt;Scripts<\/code>. The same is highlighted in the screen capture below, steps 1 &#8211; 4<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"550\" src=\"https:\/\/bytegeeks.net\/blog\/wp-content\/uploads\/2025\/06\/DHCP-script-to-add-static-queues-1-1024x550.png\" alt=\"DHCP script to add static queues\" class=\"wp-image-266\" srcset=\"https:\/\/bytegeeks.net\/blog\/wp-content\/uploads\/2025\/06\/DHCP-script-to-add-static-queues-1-1024x550.png 1024w, https:\/\/bytegeeks.net\/blog\/wp-content\/uploads\/2025\/06\/DHCP-script-to-add-static-queues-1-300x161.png 300w, https:\/\/bytegeeks.net\/blog\/wp-content\/uploads\/2025\/06\/DHCP-script-to-add-static-queues-1-768x413.png 768w, https:\/\/bytegeeks.net\/blog\/wp-content\/uploads\/2025\/06\/DHCP-script-to-add-static-queues-1-1536x826.png 1536w, https:\/\/bytegeeks.net\/blog\/wp-content\/uploads\/2025\/06\/DHCP-script-to-add-static-queues-1.png 1920w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption class=\"wp-element-caption\">DHCP script to add static queues<\/figcaption><\/figure><\/div>\n\n\n<p>The script<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-plain\"><code>:local qname (&quot;queue-&quot; . $leaseActMAC)\n:local ip $leaseActIP\n\n:log info &quot;LEASE EVENT: leaseBound=$leaseBound, IP=$ip, MAC=$leaseActMAC&quot;\n\n:if ($leaseBound = &quot;1&quot;) do={\n\n    :if (($ip != &quot;&quot;) and ($leaseActMAC != &quot;&quot;)) do={\n\n        :if ([\/queue simple find name=$qname] = &quot;&quot;) do={\n\n            \/queue simple add name=$qname target=($ip . &quot;\/32&quot;) max-limit=2M\/2M comment=&quot;Auto queue for $leaseActMAC&quot;\n            :log info &quot;Queue ADDED: $qname for $ip&quot;\n\n        } else={\n            :log info &quot;Queue ALREADY EXISTS: $qname&quot;\n        }\n\n    } else={\n        :log warning &quot;Missing IP or MAC \u2014 queue not created.&quot;\n    }\n\n} else={\n\n    :if ([\/queue simple find name=$qname] != &quot;&quot;) do={\n        \/queue simple remove [find name=$qname]\n        :log info &quot;Queue REMOVED: $qname&quot;\n    } else={\n        :log info &quot;Queue NOT FOUND to remove: $qname&quot;\n    }\n\n}\n<\/code><\/pre><\/div>\n\n\n\n<p>You can change the bandwidth limit on line 12 as per your requirement. Thank you for reading till the end and staying with bytegeeks.net<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Having hundreds of static queues that are dormant often takes up your CPU cycles and slows down the router. To better handle this, it is often ideal to add simple queues dynamically only for active leases. To achieve this, use the following mikrotik DHCP script to add simple queues automatically. This reduces the clutter in [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[4],"tags":[23,14],"class_list":["post-263","post","type-post","status-publish","format-standard","hentry","category-mikrotik","tag-automation","tag-how-to"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v25.4 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Mikrotik DHCP script to add simple queue automatically - ByteGeeks<\/title>\n<meta name=\"description\" content=\"Mikrotik DHCP script to add simple queues automatically with each new lease and enhancing the efficiency of your routers CPU by reducing load\/\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/bytegeeks.net\/blog\/mikrotik-dhcp-script-to-add-simple-queue-automatically\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Mikrotik DHCP script to add simple queue automatically - ByteGeeks\" \/>\n<meta property=\"og:description\" content=\"Mikrotik DHCP script to add simple queues automatically with each new lease and enhancing the efficiency of your routers CPU by reducing load\/\" \/>\n<meta property=\"og:url\" content=\"https:\/\/bytegeeks.net\/blog\/mikrotik-dhcp-script-to-add-simple-queue-automatically\/\" \/>\n<meta property=\"og:site_name\" content=\"ByteGeeks\" \/>\n<meta property=\"article:published_time\" content=\"2025-06-02T06:40:06+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-07-08T11:06:20+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/bytegeeks.net\/blog\/wp-content\/uploads\/2025\/06\/DHCP-script-to-add-static-queues-1.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1920\" \/>\n\t<meta property=\"og:image:height\" content=\"1032\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Redwan\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Redwan\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/bytegeeks.net\/blog\/mikrotik-dhcp-script-to-add-simple-queue-automatically\/\",\"url\":\"https:\/\/bytegeeks.net\/blog\/mikrotik-dhcp-script-to-add-simple-queue-automatically\/\",\"name\":\"Mikrotik DHCP script to add simple queue automatically - ByteGeeks\",\"isPartOf\":{\"@id\":\"https:\/\/bytegeeks.net\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/bytegeeks.net\/blog\/mikrotik-dhcp-script-to-add-simple-queue-automatically\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/bytegeeks.net\/blog\/mikrotik-dhcp-script-to-add-simple-queue-automatically\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/bytegeeks.net\/blog\/wp-content\/uploads\/2025\/06\/DHCP-script-to-add-static-queues-1-1024x550.png\",\"datePublished\":\"2025-06-02T06:40:06+00:00\",\"dateModified\":\"2025-07-08T11:06:20+00:00\",\"author\":{\"@id\":\"https:\/\/bytegeeks.net\/blog\/#\/schema\/person\/419ede240aa968b3bf8202cf9e94e792\"},\"description\":\"Mikrotik DHCP script to add simple queues automatically with each new lease and enhancing the efficiency of your routers CPU by reducing load\/\",\"breadcrumb\":{\"@id\":\"https:\/\/bytegeeks.net\/blog\/mikrotik-dhcp-script-to-add-simple-queue-automatically\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/bytegeeks.net\/blog\/mikrotik-dhcp-script-to-add-simple-queue-automatically\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/bytegeeks.net\/blog\/mikrotik-dhcp-script-to-add-simple-queue-automatically\/#primaryimage\",\"url\":\"https:\/\/bytegeeks.net\/blog\/wp-content\/uploads\/2025\/06\/DHCP-script-to-add-static-queues-1.png\",\"contentUrl\":\"https:\/\/bytegeeks.net\/blog\/wp-content\/uploads\/2025\/06\/DHCP-script-to-add-static-queues-1.png\",\"width\":1920,\"height\":1032,\"caption\":\"DHCP script to add static queues\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/bytegeeks.net\/blog\/mikrotik-dhcp-script-to-add-simple-queue-automatically\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/bytegeeks.net\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Mikrotik DHCP script to add simple queue automatically\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/bytegeeks.net\/blog\/#website\",\"url\":\"https:\/\/bytegeeks.net\/blog\/\",\"name\":\"ByteGeeks\",\"description\":\"Your one-stop shop for everything IT\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/bytegeeks.net\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/bytegeeks.net\/blog\/#\/schema\/person\/419ede240aa968b3bf8202cf9e94e792\",\"name\":\"Redwan\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/bytegeeks.net\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/785ee4165b07a924d3e8538e8fd845bbd1d22e2680c18ebb16aa54890455e008?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/785ee4165b07a924d3e8538e8fd845bbd1d22e2680c18ebb16aa54890455e008?s=96&d=mm&r=g\",\"caption\":\"Redwan\"},\"description\":\"Just your average IT guy talking about IT stuff.\",\"sameAs\":[\"https:\/\/bytegeeks.net\/blog\"],\"url\":\"https:\/\/bytegeeks.net\/blog\/author\/redmin\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Mikrotik DHCP script to add simple queue automatically - ByteGeeks","description":"Mikrotik DHCP script to add simple queues automatically with each new lease and enhancing the efficiency of your routers CPU by reducing load\/","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/bytegeeks.net\/blog\/mikrotik-dhcp-script-to-add-simple-queue-automatically\/","og_locale":"en_US","og_type":"article","og_title":"Mikrotik DHCP script to add simple queue automatically - ByteGeeks","og_description":"Mikrotik DHCP script to add simple queues automatically with each new lease and enhancing the efficiency of your routers CPU by reducing load\/","og_url":"https:\/\/bytegeeks.net\/blog\/mikrotik-dhcp-script-to-add-simple-queue-automatically\/","og_site_name":"ByteGeeks","article_published_time":"2025-06-02T06:40:06+00:00","article_modified_time":"2025-07-08T11:06:20+00:00","og_image":[{"width":1920,"height":1032,"url":"https:\/\/bytegeeks.net\/blog\/wp-content\/uploads\/2025\/06\/DHCP-script-to-add-static-queues-1.png","type":"image\/png"}],"author":"Redwan","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Redwan","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/bytegeeks.net\/blog\/mikrotik-dhcp-script-to-add-simple-queue-automatically\/","url":"https:\/\/bytegeeks.net\/blog\/mikrotik-dhcp-script-to-add-simple-queue-automatically\/","name":"Mikrotik DHCP script to add simple queue automatically - ByteGeeks","isPartOf":{"@id":"https:\/\/bytegeeks.net\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/bytegeeks.net\/blog\/mikrotik-dhcp-script-to-add-simple-queue-automatically\/#primaryimage"},"image":{"@id":"https:\/\/bytegeeks.net\/blog\/mikrotik-dhcp-script-to-add-simple-queue-automatically\/#primaryimage"},"thumbnailUrl":"https:\/\/bytegeeks.net\/blog\/wp-content\/uploads\/2025\/06\/DHCP-script-to-add-static-queues-1-1024x550.png","datePublished":"2025-06-02T06:40:06+00:00","dateModified":"2025-07-08T11:06:20+00:00","author":{"@id":"https:\/\/bytegeeks.net\/blog\/#\/schema\/person\/419ede240aa968b3bf8202cf9e94e792"},"description":"Mikrotik DHCP script to add simple queues automatically with each new lease and enhancing the efficiency of your routers CPU by reducing load\/","breadcrumb":{"@id":"https:\/\/bytegeeks.net\/blog\/mikrotik-dhcp-script-to-add-simple-queue-automatically\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/bytegeeks.net\/blog\/mikrotik-dhcp-script-to-add-simple-queue-automatically\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/bytegeeks.net\/blog\/mikrotik-dhcp-script-to-add-simple-queue-automatically\/#primaryimage","url":"https:\/\/bytegeeks.net\/blog\/wp-content\/uploads\/2025\/06\/DHCP-script-to-add-static-queues-1.png","contentUrl":"https:\/\/bytegeeks.net\/blog\/wp-content\/uploads\/2025\/06\/DHCP-script-to-add-static-queues-1.png","width":1920,"height":1032,"caption":"DHCP script to add static queues"},{"@type":"BreadcrumbList","@id":"https:\/\/bytegeeks.net\/blog\/mikrotik-dhcp-script-to-add-simple-queue-automatically\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/bytegeeks.net\/blog\/"},{"@type":"ListItem","position":2,"name":"Mikrotik DHCP script to add simple queue automatically"}]},{"@type":"WebSite","@id":"https:\/\/bytegeeks.net\/blog\/#website","url":"https:\/\/bytegeeks.net\/blog\/","name":"ByteGeeks","description":"Your one-stop shop for everything IT","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/bytegeeks.net\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/bytegeeks.net\/blog\/#\/schema\/person\/419ede240aa968b3bf8202cf9e94e792","name":"Redwan","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/bytegeeks.net\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/785ee4165b07a924d3e8538e8fd845bbd1d22e2680c18ebb16aa54890455e008?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/785ee4165b07a924d3e8538e8fd845bbd1d22e2680c18ebb16aa54890455e008?s=96&d=mm&r=g","caption":"Redwan"},"description":"Just your average IT guy talking about IT stuff.","sameAs":["https:\/\/bytegeeks.net\/blog"],"url":"https:\/\/bytegeeks.net\/blog\/author\/redmin\/"}]}},"jetpack_featured_media_url":"","jetpack-related-posts":[],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/bytegeeks.net\/blog\/wp-json\/wp\/v2\/posts\/263","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/bytegeeks.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/bytegeeks.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/bytegeeks.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/bytegeeks.net\/blog\/wp-json\/wp\/v2\/comments?post=263"}],"version-history":[{"count":7,"href":"https:\/\/bytegeeks.net\/blog\/wp-json\/wp\/v2\/posts\/263\/revisions"}],"predecessor-version":[{"id":274,"href":"https:\/\/bytegeeks.net\/blog\/wp-json\/wp\/v2\/posts\/263\/revisions\/274"}],"wp:attachment":[{"href":"https:\/\/bytegeeks.net\/blog\/wp-json\/wp\/v2\/media?parent=263"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/bytegeeks.net\/blog\/wp-json\/wp\/v2\/categories?post=263"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/bytegeeks.net\/blog\/wp-json\/wp\/v2\/tags?post=263"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}