2 wan Qos script first try need guide for correction in this script

Hi,

2 wan qos script in which i need help to correct this script can anyone help me if there is something wrong with this script, pardon me for my mistake because thats my first try ever.

thankyou

/ip firewall mangle

WAN1 DNS

add chain=prerouting action=mark-connection connection-state=new new-connection-mark=DNS1 port=53 protocol=udp passthrough=yes comment="DNS1"
add chain=prerouting action=mark-packet connection-mark=DNS1 new-packet-mark=DNS passthrough=no
add chain=postrouting action=mark-connection connection-state=new new-connection-mark=DNS1 port=53 protocol=udp passthrough=yes
add action=mark-packet chain=prerouting connection-mark=DNS1 in-interface=WAN1 new-packet-mark=DNS1-WAN1-In passthrough=no
add action=mark-packet chain=postrouting connection-mark=DNS1 new-packet-mark=DNS1-WAN1-Out out-interface=WAN1 passthrough=no

WAN2 DNS

add chain=prerouting action=mark-connection connection-state=new new-connection-mark=DNS2 port=53 protocol=udp passthrough=yes comment="DNS2"
add chain=prerouting action=mark-packet connection-mark=DNS2 new-packet-mark=DNS2 passthrough=no
add chain=postrouting action=mark-connection connection-state=new new-connection-mark=DNS2 port=53 protocol=udp passthrough=yes
add action=mark-packet chain=prerouting connection-mark=DNS2 in-interface=WAN2 new-packet-mark=DNS2-WAN2-In passthrough=no
add action=mark-packet chain=postrouting connection-mark=DNS2 new-packet-mark=DNS2-WAN21-Out out-interface=WAN2 passthrough=no

WAN1 VoIP

add chain=prerouting action=mark-connection new-connection-mark=VOIP1 port=5060-5062,10000-20000 protocol=udp passthrough=yes comment="VOIP1"
add action=mark-packet chain=prerouting connection-mark=VOIP1 in-interface=WAN1 new-packet-mark=VOIP1-WAN1-In passthrough=no
add action=mark-packet chain=postrouting connection-mark=VOIP1 new-packet-mark=VOIP1-WAN1-Out out-interface=WAN1 passthrough=no

WAN2 VoIP

add chain=prerouting action=mark-connection new-connection-mark=VOIP2 port=5060-5062,10000-20000 protocol=udp passthrough=yes comment="VOIP2"
add action=mark-packet chain=prerouting connection-mark=VOIP2 in-interface=WAN2 new-packet-mark=VOIP2-WAN2-In passthrough=no
add action=mark-packet chain=postrouting connection-mark=VOIP2 new-packet-mark=VOIP2-WAN2-Out out-interface=WAN2 passthrough=no

WAN1 HTTP/3 and Google's QUIC

add chain=prerouting action=mark-connection connection-state=new new-connection-mark=QUIC1 port=80,443 protocol=udp passthrough=yes comment="QUIC1"
add action=mark-packet chain=prerouting connection-mark=QUIC1 in-interface=WAN1 new-packet-mark=QUIC1-WAN1-In passthrough=no
add action=mark-packet chain=postrouting connection-mark=QUIC1 new-packet-mark=QUIC1-WAN1-Out out-interface=WAN1 passthrough=no

WAN2 HTTP/3 and Google's QUIC

add chain=prerouting action=mark-connection connection-state=new new-connection-mark=QUIC2 port=80,443 protocol=udp passthrough=yes comment="QUIC2"
add action=mark-packet chain=prerouting connection-mark=QUIC2 in-interface=WAN2 new-packet-mark=QUIC2-WAN2-In passthrough=no
add action=mark-packet chain=postrouting connection-mark=QUIC2 new-packet-mark=QUIC2-WAN2-Out out-interface=WAN2 passthrough=no

\

WAN1 UPD

add chain=prerouting action=mark-connection connection-state=new new-connection-mark=UDP1 protocol=udp passthrough=yes comment="UDP1"
add action=mark-packet chain=prerouting connection-mark=UDP1 in-interface=WAN2 new-packet-mark=UDP1-WAN2-In passthrough=no
add action=mark-packet chain=postrouting connection-mark=UDP1 new-packet-mark=UDP1-WAN2-Out out-interface=WAN2 passthrough=no

WAN2 UPD

add chain=prerouting action=mark-connection connection-state=new new-connection-mark=UDP2 protocol=udp passthrough=yes comment="UDP2"
add action=mark-packet chain=prerouting connection-mark=UDP2 in-interface=WAN2 new-packet-mark=UDP2-WAN2-In passthrough=no
add action=mark-packet chain=postrouting connection-mark=UDP2 new-packet-mark=UDP2-WAN2-Out out-interface=WAN2 passthrough=no

\

WAN1 ICMP/PING

add chain=prerouting action=mark-connection connection-state=new new-connection-mark=ICMP1 protocol=icmp passthrough=yes comment="ICMP1"
add chain=prerouting action=mark-packet connection-mark=ICMP1 new-packet-mark=ICMP1 passthrough=no
add chain=postrouting action=mark-connection connection-state=new new-connection-mark=ICMP1 protocol=icmp1 passthrough=yes
add action=mark-packet chain=prerouting connection-mark=ICMP1 in-interface=WAN1 new-packet-mark=ICMP1-WAN1-In passthrough=no
add action=mark-packet chain=postrouting connection-mark=ICMP1 new-packet-mark=ICMP1-WAN1-Out out-interface=WAN1 passthrough=no

WAN2 ICMP/PING

add chain=prerouting action=mark-connection connection-state=new new-connection-mark=ICMP2 protocol=icmp2 passthrough=yes comment="ICMP2"
add chain=prerouting action=mark-packet connection-mark=ICMP2 new-packet-mark=ICMP2 passthrough=no
add chain=postrouting action=mark-connection connection-state=new new-connection-mark=ICMP2 protocol=icmp passthrough=yes
add action=mark-packet chain=prerouting connection-mark=ICMP2 in-interface=WAN2 new-packet-mark=ICMP2-WAN2-In passthrough=no
add action=mark-packet chain=postrouting connection-mark=ICMP2 new-packet-mark=ICMP2-WAN2-Out out-interface=WAN2 passthrough=no

\

WAN1 ACK

add chain=postrouting action=mark-packet new-packet-mark=ACK1 packet-size=0-123 protocol=tcp tcp-flags=ack1 passthrough=no comment="ACK1"
add chain=prerouting action=mark-packet new-packet-mark=ACK1 packet-size=0-123 protocol=tcp tcp-flags=ack1 passthrough=no
add action=mark-packet chain=prerouting connection-mark=ACK1 in-interface=WAN1 new-packet-mark=ACK1-WAN1-In passthrough=no
add action=mark-packet chain=postrouting connection-mark=ACK1 new-packet-mark=ACK1-WAN1-Out out-interface=WAN1 passthrough=no

WAN2 ACK

add chain=postrouting action=mark-packet new-packet-mark=ACK2 packet-size=0-123 protocol=tcp tcp-flags=ack2 passthrough=no comment="ACK2"
add chain=prerouting action=mark-packet new-packet-mark=ACK2 packet-size=0-123 protocol=tcp tcp-flags=ack2 passthrough=no
add action=mark-packet chain=prerouting connection-mark=ACK2 in-interface=WAN2 new-packet-mark=ACK2-WAN2-In passthrough=no
add action=mark-packet chain=postrouting connection-mark=ACK2 new-packet-mark=ACK2-WAN2-Out out-interface=WAN2 passthrough=no

\

WAN1 HTTP

add chain=prerouting action=mark-connection connection-mark=no-mark connection-state=new new-connection-mark=HTTP1 port=80,443 protocol=tcp passthrough=yes comment="HTTP1"
add chain=prerouting action=mark-connection connection-bytes=5M-0 connection-mark=HTTP1 connection-rate=2M-100M new-connection-mark=HTTP_BIG1 protocol=tcp passthrough=yes
add chain=prerouting action=mark-packet connection-mark=HTTP_BIG1 new-packet-mark=HTTP_BIG1 passthrough=no
add action=mark-packet chain=prerouting connection-mark=HTTP_BIG1 in-interface=WAN1 new-packet-mark=HTTP_BIG1-WAN1-In passthrough=no
add action=mark-packet chain=postrouting connection-mark=HTTP_BIG1 new-packet-mark=HTTP_BIG1-WAN1-Out out-interface=WAN1 passthrough=no

WAN2 HTTP

add chain=prerouting action=mark-connection connection-mark=no-mark connection-state=new new-connection-mark=HTTP2 port=80,443 protocol=tcp passthrough=yes comment="HTTP2"
add chain=prerouting action=mark-connection connection-bytes=5M-0 connection-mark=HTTP2 connection-rate=2M-100M new-connection-mark=HTTP_BIG2 protocol=tcp passthrough=yes
add chain=prerouting action=mark-packet connection-mark=HTTP_BIG2 new-packet-mark=HTTP_BIG2 passthrough=no
add action=mark-packet chain=prerouting connection-mark=HTTP_BIG2 in-interface=WAN2 new-packet-mark=HTTP_BIG-WAN2-In passthrough=no
add action=mark-packet chain=postrouting connection-mark=HTTP_BIG2 new-packet-mark=HTTP_BIG2-WAN2-Out out-interface=WAN2 passthrough=no

WAN1 POP

add chain=prerouting action=mark-connection connection-state=new new-connection-mark=POP31 port=995,465,587 protocol=tcp passthrough=yes comment="OTHER1"
add action=mark-packet chain=prerouting connection-mark=POP31 in-interface=WAN1 new-packet-mark=POP31-WAN1-In passthrough=no
add action=mark-packet chain=postrouting connection-mark=POP31 new-packet-mark=POP31-WAN1-Out out-interface=WAN1 passthrough=no

WAN2 POP

add chain=prerouting action=mark-connection connection-state=new new-connection-mark=POP32 port=995,465,587 protocol=tcp passthrough=yes comment="OTHER2"
add action=mark-packet chain=prerouting connection-mark=POP32 in-interface=WAN2 new-packet-mark=POP32-WAN2-In passthrough=no
add action=mark-packet chain=postrouting connection-mark=POP32 new-packet-mark=POP32-WAN2-Out out-interface=WAN2 passthrough=no

\

WAN1 Others

add chain=prerouting action=mark-connection connection-mark=no-mark new-connection-mark=OTHER1 passthrough=yes
add action=mark-packet chain=prerouting connection-mark=OTHER1 in-interface=WAN1 new-packet-mark=OTHER1-WAN1-In passthrough=no
add action=mark-packet chain=postrouting connection-mark=OTHER1 new-packet-mark=OTHER1-WAN1-Out out-interface=WAN1 passthrough=no

WAN2 Others

add chain=prerouting action=mark-connection connection-mark=no-mark new-connection-mark=OTHER2 passthrough=yes
add action=mark-packet chain=prerouting connection-mark=OTHER2 in-interface=WAN2 new-packet-mark=OTHER2-WAN2-In passthrough=no
add action=mark-packet chain=postrouting connection-mark=OTHER2 new-packet-mark=OTHER2-WAN2-Out out-interface=WAN2 passthrough=no


/queue tree

DOWN1

add name=DOWN max-limit=50M parent=LAN bucket-size=0.01 queue=default
add name="1. VOIP1" packet-mark=VOIP parent=DOWN priority=1 queue=default
add name="2. DNS1" packet-mark=DNS parent=DOWN priority=2 queue=default
add name="3. ACK1" packet-mark=ACK parent=DOWN priority=3 queue=default
add name="4. UDP1" packet-mark=UDP parent=DOWN priority=3 queue=default
add name="5. ICMP1" packet-mark=ICMP parent=DOWN priority=4 queue=default
add name="6. HTTP1" packet-mark=HTTP parent=DOWN priority=5 queue=default
add name="7. HTTP_BIG1" packet-mark=HTTP_BIG parent=DOWN priority=6 queue=default
add name="8. QUIC1" packet-mark=QUIC parent=DOWN priority=7 queue=default
add name="9. OTHER1" packet-mark=OTHER parent=DOWN priority=8 queue=default

UP1

add name=UP max-limit=10M parent=WAN1 bucket-size=0.01 queue=default
add name="1. VOIP1" packet-mark=VOIP parent=UP priority=1 queue=default
add name="2. DNS1" packet-mark=DNS parent=UP priority=2 queue=default
add name="3. ACK1" packet-mark=ACK parent=UP priority=3 queue=default
add name="4. UDP1" packet-mark=UDP parent=UP priority=3 queue=default
add name="5. ICMP1" packet-mark=ICMP parent=UP priority=4 queue=default
add name="6. HTTP1" packet-mark=HTTP parent=UP priority=5 queue=default
add name="7. HTTP_BIG1" packet-mark=HTTP_BIG parent=UP priority=6 queue=default
add name="8. QUIC1" packet-mark=QUIC parent=UP priority=7 queue=default
add name="9. OTHER1" packet-mark=OTHER parent=UP priority=8 queue=default


/queue tree

DOWN2

add name=DOWN max-limit=50M parent=LAN bucket-size=0.01 queue=default
add name="1. VOIP2" packet-mark=VOIP parent=DOWN priority=1 queue=default
add name="2. DNS2" packet-mark=DNS parent=DOWN priority=2 queue=default
add name="3. ACK2" packet-mark=ACK parent=DOWN priority=3 queue=default
add name="4. UDP2" packet-mark=UDP parent=DOWN priority=3 queue=default
add name="5. ICMP2" packet-mark=ICMP parent=DOWN priority=4 queue=default
add name="6. HTTP2" packet-mark=HTTP parent=DOWN priority=5 queue=default
add name="7. HTTP_BIG2" packet-mark=HTTP_BIG parent=DOWN priority=6 queue=default
add name="8. QUIC2" packet-mark=QUIC parent=DOWN priority=7 queue=default
add name="9. OTHER2" packet-mark=OTHER parent=DOWN priority=8 queue=default

UP2

add name=UP max-limit=70M parent=WAN2 bucket-size=0.01 queue=default
add name="1. VOIP2" packet-mark=VOIP parent=UP priority=1 queue=default
add name="2. DNS2" packet-mark=DNS parent=UP priority=2 queue=default
add name="3. ACK2" packet-mark=ACK parent=UP priority=3 queue=default
add name="4. UDP2" packet-mark=UDP parent=UP priority=3 queue=default
add name="5. ICMP2" packet-mark=ICMP parent=UP priority=4 queue=default
add name="6. HTTP2" packet-mark=HTTP parent=UP priority=5 queue=default
add name="7. HTTP_BIG2" packet-mark=HTTP_BIG parent=UP priority=6 queue=default
add name="8. QUIC2" packet-mark=QUIC parent=UP priority=7 queue=default
add name="9. OTHER2" packet-mark=OTHER parent=UP priority=8 queue=default

anybody?

Briefly running through it, you have a lot of duplicate assignment of connection marks, with no criteria distinguishing traffic of one WAN from the traffic of the other WAN. So it seems to me like a blind copy-paste without diving into the purpose of the individual rules, but I may be wrong.

In my view of the world, the traffic classes (VoIP, DNS, ACK etc.) are the same for both WANs, only the shaping limits need to be different for traffic running through each WAN. And you need to shape the download (WAN->LAN) traffic depending on the ingress WAN interface, so you need one separate queue for the VoIP class from WAN1 to a given LAN and another one for the VoIP class from WAN2 to the same LAN.

So you can use only a single common set of rules to assign the connection marks, but you need to translate the connection marks to packet marks individually at least for the WAN->LAN direction. You also seem to assign packet marks in both prerouting and postrouting, which I don’t understand - can you link the original setup you build upon?

I’d suggest you to read my post in a similar recent topic, and continue posting here if it that post is not sufficient to clean things up. E.g. if you use some more sophisticated strategy of load distribution among WANs, which involves use of connection marks, you’ll have to use “aggregated” connection marks due to the limitation of the RouterOS implementation which allows only one connection-mark per connection.