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")
}
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.
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?
I am now bored waiting for fibre or even FTTC to arrive in my area so bought a LHG 4G kit (RBLHGR&R11e-4G). It is working pretty well and providing around 30-40Mbps down and around 10Mbps up (I know that’s not fast but compared to 10/1Mbps its a new world!).
It is set up as the main router, so providing DHCP server, firewall etc, with open ports set up for my NAS and CCTV. With working from home still going on we frequently have up to three Zoom/Teams calls going on and now that I can ditch my landline am looking at adding a SIP dual FXS adapter for VoIP, so I tried using this script and I am not sure that it is making any difference - but I notice that the queues use “ethernet-default” as the queue type in the script. If I use Winbox and look at the queue type for the lte1 interface it is set to “no queue”. Should I change the queue type for the lte1 interface to something else and change the script to match?
Any help would be great, and thanks for a great script - I wouldn’t have a clue how to have done this!