Simply set your WAN interface name, and your WAN UPLOAD speed. It will generate the queue tree and mangle rules to get you started.
Code: Select all
#Set interface here
:local outboundInterface "wan0"
#Set bandwidth of the interface (remember, this is for OUTGOING)
:local interfaceBandwidth 4M
#Set where in the chain the packets should be mangled
:local mangleChain postrouting
#Don't mess with these. They set the parameters for what is to follow
:local queueName ("QoS_" . $outboundInterface)
:local qosClasses [:toarray "Network Control,Internetwork Control,Critical,Flash Override,Flash,Immedate,Priority,Routine"]
/ip firewall mangle add action=set-priority \
chain=postrouting new-priority=from-dscp-high-3-bits \
passthrough=yes comment="Respect DSCP tagging"
/ip firewall mangle add action=set-priority \
chain=postrouting new-priority=2 packet-size=0-123 \
passthrough=yes protocol=tcp tcp-flags=ack comment="Prioritize ACKs"
/ip firewall mangle add action=set-priority \
chain=postrouting priority=0 dscp=0 new-priority=8 \
passthrough=yes comment="Set Pri 8 on packets with no tag at all"
:for indexA from 0 to 7 do={
/ip firewall mangle add action=mark-packet chain=$mangleChain comment=("pri_" . $indexA+1) \
disabled=no priority=($indexA+1) new-packet-mark=("priority_" . $indexA+1) passthrough=no
}
/queue tree add max-limit=$interfaceBandwidth name=$queueName parent=$outboundInterface priority=1
:for indexA from=0 to=7 do={
:local subClass ([:pick $qosClasses $indexA] )
/queue tree add \
name=($indexA+1 . ". " . $subClass . " - " . $outboundInterface ) \
parent=$queueName \
priority=($indexA+1) \
queue=ethernet-default \
packet-mark=("priority_" . $indexA+1) \
comment=("Priority " . $indexA+1 . " traffic")
}