Page 1 of 1

Simplified DSCP/QoS Setup Script

Posted: Sun Sep 18, 2016 9:09 pm
by IntrusDave
Here is a simplified (8 queue instead of 64 queue) script to setup basic DSCP and QoS.
Simply set your WAN interface name, and your WAN UPLOAD speed. It will generate the queue tree and mangle rules to get you started.
#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")
}

Re: Simplified DSCP/QoS Setup Script

Posted: Mon Jun 19, 2017 1:32 pm
by amt
what will happen after this ? what will be the benefits ?

Re: Simplified DSCP/QoS Setup Script

Posted: Mon Jun 19, 2017 5:55 pm
by IntrusDave
Your router will honor the QOS tagging in the packets

Re: Simplified DSCP/QoS Setup Script

Posted: Tue Jun 20, 2017 8:02 am
by amt
Hi Dave,
I would like to make videos faster for the customer then voip can i use QoS for this option ?

Re: Simplified DSCP/QoS Setup Script

Posted: Tue Jun 20, 2017 9:18 am
by IntrusDave
Yes, you would need to mangle rules to mark the packets with the priority that you want them to have.

Re: Simplified DSCP/QoS Setup Script

Posted: Tue Jun 20, 2017 9:36 am
by amt
Hi dave,
What about your rules ? how they worked ?

Thanks

Re: Simplified DSCP/QoS Setup Script

Posted: Tue Jun 20, 2017 9:48 am
by IntrusDave
The mangle rules created by the script only mark the packets for DSCP. You will need to create new rules to set the DSCP for the video packets. Keep in mind that QoS only works for your outbound traffic. Unless you are using an MPLS for your WAN, you can not control your inbound QoS.

Re: Simplified DSCP/QoS Setup Script

Posted: Tue Jun 20, 2017 10:06 am
by amt
thanks for your help...

Re: Simplified DSCP/QoS Setup Script

Posted: Fri Feb 01, 2019 4:46 pm
by neutronlaser
Script fails and says 'ambiguous value of parent, more than one possible value matches input'

Re: Simplified DSCP/QoS Setup Script

Posted: Sun Mar 10, 2019 1:03 am
by neutronlaser
What a crock, just put some QoS in quickset already.

Re: Simplified DSCP/QoS Setup Script

Posted: Mon Apr 15, 2019 9:45 pm
by c400
Hello,
Will this work, if i add it next line after "Set Pri 8 on packets with no tag at all"?
/ip firewall mangle add action=set-priority chain=postrouting new-priority=5 passthrough=yes protocol=tcp port=22
thx for a great script!

Re: Simplified DSCP/QoS Setup Script

Posted: Tue Apr 16, 2019 5:21 am
by IntrusDave
that should work just fine, but place it before the Priority 8 line.

Re: Simplified DSCP/QoS Setup Script

Posted: Wed Jun 12, 2019 6:48 pm
by prozak
Hello.
I have a Question,
Does this script really honor and prioritizes VoIP instead of bulk traffic like web downloads?
Isn't there any need to set limit-at to guarantee critical dscp tagging enough bandwidth?
I mean in case there's a link saturation by bulk traffic so to avoid any VoIP jitters?

Also another sort of irrelevant question
If your VoIP service is through a VPN, are the packets tagged? or are they masked through VPN with no tag?

Any comments will be appreciated

Re: Simplified DSCP/QoS Setup Script

Posted: Sun Aug 18, 2019 9:37 am
by c400
Trying to prioritize traffic over LTE, found that outgoing speed can vary from 10mbits to 25mbits. Should i set
:local interfaceBandwidth
to minimum value? Or it will be harmful for maximum bandwidth?
thx!