Page 1 of 1

Script for Mangle and Queue Tree

Posted: Sun Aug 14, 2011 8:24 am
by furuka
Hi,

I looking for a script to add new mangle rule (SRC. Address and New Packet mark) and create a queue with upload and download in Queue Tree for each customer. It would be great to load a .rsc file from linux to mikrotik by ssh.

Thanks.

Re: Script for Mangle and Queue Tree

Posted: Mon Aug 15, 2011 4:28 pm
by janisk
look up following keywords - QoS, PCQ, bandwidth limitation. to get more insight into what it is and what options are good at what moment. if you have just some customers, you can use queue for each customer, but then you do not need the script to create 10 or 30 queues. if you have a lot of customers, look for PCQ and what features it provides for you.

Re: Script for Mangle and Queue Tree

Posted: Thu Aug 18, 2011 5:42 pm
by furuka
Hi Jasnik,

I've got more than 500 customers loaded in Queue Tree and each of them are loaded in mangle, I do this one by one. So I'm looking for some kind o script o whatever to do that job.
In another server a use Simple Queue and I load my customers in a simple text file (.rsc) and send it to mikrotik by ftp. But it do not use mangle rules. That file only creates groups of 1mb for 4 users of each.

thanks.

Re: Script for Mangle and Queue Tree

Posted: Thu Aug 18, 2011 5:45 pm
by fewi
Read up on PCQ on the wiki. PCQ keeps you from having to create one queue per customer at all. You don't need a script to make it easier to create queues, you need to use the right queue type for the job.

http://wiki.mikrotik.com/wiki/Manual:Queues_-_PCQ

Your goal is to make queue administration easier. You think that the right solution is a script to create many queues for you. That isn't the right solution. The right solution is to use PCQ.
http://catb.org/~esr/faqs/smart-questions.html#goal

Re: Script for Mangle and Queue Tree

Posted: Mon Aug 22, 2011 3:45 am
by furuka
fewi,

Maybe you did not understand my post or you did not read it well.

I always use Queue Tree, and PCQ scheme in it, so I know how it works.

What I'm trying to say is that I need a tool to make my work more efficient and faster.

Thanks for your help.

Javier.

Re: Script for Mangle and Queue Tree

Posted: Mon Aug 22, 2011 3:53 am
by fewi
Can you post your configuration so far? "/ip address print detail", "/interface print detail", "/ip firewall mangle export", "/queue type export", and "/queue tree export".

I just don't understand what kind of tool you're looking for. If you can show what you have right now and what you're trying to get a script to generate for you things will become clearer. Your posts sort of indicate that you have mangle rules and queues for every user, which just isn't necessary with PCQ.

Re: Script for Mangle and Queue Tree

Posted: Fri Aug 26, 2011 11:40 pm
by dboillot
furuka, There is a totally easier way for that. Here's how we have ours set up.

The following steps we do everytime we add a user.
we assign a static IP address to everyone via DHCP (wont go in to detail on this)
We then add each IP to an address list based on what package they use.

The following steps we've done once.
we have a Queue tree setup using PCQ that limits users download and uploads speeds. (one queue for upload and one for download)
we then setup a few mangle rules to look at the lists, and then mark the packet based on the list.


you set the Queue's up once, and just add the IP addresses to the list and everything is done for you automagically.


here's a sample of my code,
[color=#008000]### Here's the mangle rules for the "basic" users. First one is for download, the second one is for the upload they both look at the address-list called Basic and act accordingly[/color]
/ip firewall mangle
add action=mark-packet chain=forward comment="User Basic Download" disabled=\
    no dst-address-list=Basic new-packet-mark=Basic passthrough=no


add action=mark-packet chain=forward comment="User Basic Upload" disabled=no \
    new-packet-mark=128u passthrough=no src-address-list=Basic


[color=#008000]###Here is the queue tree, we have a parent tree we set the Max Limit that all of the Queue's can use (we use our total bandwidth -10%, we use 2 here, one for download, and one for upload[/color]
/queue tree
add burst-limit=0 burst-threshold=0 burst-time=0s disabled=no limit-at=0 \
    max-limit=60M name=Download-All priority=8

add burst-limit=0 burst-threshold=0 burst-time=0s disabled=no limit-at=0 \
    max-limit=3M name=Upload-All parent=global-out priority=8

add burst-limit=0 burst-threshold=0 burst-time=0s disabled=no limit-at=0 \
    max-limit=3M name="1 User Basic" packet-mark=Basic parent=Download-All \
    priority=5 queue="PCQ_1 Basic"

add burst-limit=0 burst-threshold=0 burst-time=0s disabled=no limit-at=0 \
    max-limit=0 name=User128u packet-mark=128u parent=Upload-All priority=6 \
    queue="PCQ_U 128"


[color=#008000]###Here's the Queue type, here's where we set the limit on the connections, you can see here we have the download set at 384k, and the upload at 128k. neither one has bursting enabled[/color]
/queue type
add kind=pcq name="PCQ_1 Basic" pcq-burst-rate=0 pcq-burst-threshold=0 \
    pcq-burst-time=10s pcq-classifier=dst-address pcq-dst-address-mask=32 \
    pcq-dst-address6-mask=128 pcq-limit=50 pcq-rate=384k \
    pcq-src-address-mask=32 pcq-src-address6-mask=128 pcq-total-limit=2000

add kind=pcq name="PCQ_U 128" pcq-burst-rate=0 pcq-burst-threshold=0 \
    pcq-burst-time=10s pcq-classifier=src-address pcq-dst-address-mask=32 \
    pcq-dst-address6-mask=128 pcq-limit=50 pcq-rate=128k \
    pcq-src-address-mask=32 pcq-src-address6-mask=128 pcq-total-limit=2000
I'm not saying this is the absolute best way to do this, or the best way to use the PCQ but it is a lot easier then what you are doing. we currently have about 220 customers.

if you want more info let me know.