Skip to content

Instantly share code, notes, and snippets.

@TotalLag
Last active June 20, 2020 12:14
Show Gist options
  • Save TotalLag/3f98444300c4117d74276624b4d526c1 to your computer and use it in GitHub Desktop.
Save TotalLag/3f98444300c4117d74276624b4d526c1 to your computer and use it in GitHub Desktop.
Prioritize via DPI and allow 100% bandwidth usage if network is idle
set firewall modify QoS description 'mark packets for QoS'
set firewall modify QoS rule 20 action modify
set firewall modify QoS rule 20 application category Voice-over-IP
set firewall modify QoS rule 20 description VoIP
set firewall modify QoS rule 20 modify mark 20
set firewall modify QoS rule 40 action modify
set firewall modify QoS rule 40 application category Games
set firewall modify QoS rule 40 description Games
set firewall modify QoS rule 40 modify mark 40
set firewall modify QoS rule 41 action modify
set firewall modify QoS rule 41 application custom-category Steam-Download
set firewall modify QoS rule 41 description 'Steam Download'
set firewall modify QoS rule 41 modify mark 41
set firewall modify QoS rule 50 action modify
set firewall modify QoS rule 50 application category P2P
set firewall modify QoS rule 50 description P2P
set firewall modify QoS rule 50 modify mark 50
set firewall modify QoS rule 51 action modify
set firewall modify QoS rule 51 application category File-Transfer
set firewall modify QoS rule 51 description 'File Transfer'
set firewall modify QoS rule 51 modify mark 51
set firewall modify QoS rule 52 action modify
set firewall modify QoS rule 52 application custom-category CrashPlan
set firewall modify QoS rule 52 description 'CrashPlan'
set firewall modify QoS rule 52 modify mark 52
set interfaces bridge br0 firewall out modify QoS
set interfaces ethernet eth0 firewall out modify QoS
set traffic-policy shaper download bandwidth 50Mbit
set traffic-policy shaper download class 10 bandwidth 5%
set traffic-policy shaper download class 10 burst 15k
set traffic-policy shaper download class 10 ceiling 100%
set traffic-policy shaper download class 10 description 'ICMP, SSH and DNS'
set traffic-policy shaper download class 10 match dns ip source port 53
set traffic-policy shaper download class 10 match icmp ip protocol icmp
set traffic-policy shaper download class 10 match ssh ip source port 2255
set traffic-policy shaper download class 10 priority 0
set traffic-policy shaper download class 10 queue-limit 10
set traffic-policy shaper download class 10 queue-type fair-queue
set traffic-policy shaper download class 20 bandwidth 20%
set traffic-policy shaper download class 20 burst 15k
set traffic-policy shaper download class 20 ceiling 100%
set traffic-policy shaper download class 20 description 'Ooma RTP+SIP'
set traffic-policy shaper download class 20 match DPI mark 20
set traffic-policy shaper download class 20 match GTM ip destination port 8200
set traffic-policy shaper download class 20 match GTM ip protocol udp
set traffic-policy shaper download class 20 match RTP ip dscp 46
set traffic-policy shaper download class 20 match SIP ip dscp 26
set traffic-policy shaper download class 20 priority 1
set traffic-policy shaper download class 20 queue-limit 10
set traffic-policy shaper download class 20 queue-type fair-queue
set traffic-policy shaper download class 30 bandwidth 10%
set traffic-policy shaper download class 30 burst 15k
set traffic-policy shaper download class 30 ceiling 100%
set traffic-policy shaper download class 30 description HTTP/HTTPS
set traffic-policy shaper download class 30 match http ip source port 80
set traffic-policy shaper download class 30 match https ip source port 443
set traffic-policy shaper download class 30 priority 3
set traffic-policy shaper download class 30 queue-type fair-queue
set traffic-policy shaper download class 40 bandwidth 25%
set traffic-policy shaper download class 40 burst 15k
set traffic-policy shaper download class 40 ceiling 100%
set traffic-policy shaper download class 40 description Gaming
set traffic-policy shaper download class 40 match DPI mark 40
set traffic-policy shaper download class 40 priority 2
set traffic-policy shaper download class 40 queue-type fair-queue
set traffic-policy shaper download class 50 bandwidth 5%
set traffic-policy shaper download class 50 burst 15k
set traffic-policy shaper download class 50 ceiling 100%
set traffic-policy shaper download class 50 description 'P2P+Torrent'
set traffic-policy shaper download class 50 match DPI mark 50
set traffic-policy shaper download class 50 match DPI2 mark 41
set traffic-policy shaper download class 50 match DPI3 mark 51
set traffic-policy shaper download class 50 match DPI4 mark 52
set traffic-policy shaper download class 50 priority 7
set traffic-policy shaper download class 50 queue-type fair-queue
set traffic-policy shaper download default bandwidth 35%
set traffic-policy shaper download default burst 15k
set traffic-policy shaper download default ceiling 100%
set traffic-policy shaper download default priority 6
set traffic-policy shaper download default queue-limit 32
set traffic-policy shaper download default queue-type fair-queue
set traffic-policy shaper upload bandwidth 6Mbit
set traffic-policy shaper upload class 10 bandwidth 5%
set traffic-policy shaper upload class 10 burst 15k
set traffic-policy shaper upload class 10 ceiling 100%
set traffic-policy shaper upload class 10 description 'ICMP, SSH and DNS'
set traffic-policy shaper upload class 10 match dns ip destination port 53
set traffic-policy shaper upload class 10 match icmp ip protocol icmp
set traffic-policy shaper upload class 10 match ssh ip destination port 2255
set traffic-policy shaper upload class 10 priority 0
set traffic-policy shaper upload class 10 queue-limit 10
set traffic-policy shaper upload class 10 queue-type fair-queue
set traffic-policy shaper upload class 20 bandwidth 20%
set traffic-policy shaper upload class 20 burst 15k
set traffic-policy shaper upload class 20 ceiling 100%
set traffic-policy shaper upload class 20 description 'Ooma RTP+SIP'
set traffic-policy shaper upload class 20 match DPI mark 20
set traffic-policy shaper upload class 20 match GTM ip destination port 8200
set traffic-policy shaper upload class 20 match GTM ip protocol udp
set traffic-policy shaper upload class 20 match RTP ip dscp 46
set traffic-policy shaper upload class 20 match SIP ip dscp 26
set traffic-policy shaper upload class 20 priority 1
set traffic-policy shaper upload class 20 queue-limit 10
set traffic-policy shaper upload class 20 queue-type fair-queue
set traffic-policy shaper upload class 30 bandwidth 10%
set traffic-policy shaper upload class 30 burst 15k
set traffic-policy shaper upload class 30 ceiling 100%
set traffic-policy shaper upload class 30 description HTTP/HTTPS
set traffic-policy shaper upload class 30 match http ip destination port 80
set traffic-policy shaper upload class 30 match https ip destination port 443
set traffic-policy shaper upload class 30 priority 3
set traffic-policy shaper upload class 30 queue-type fair-queue
set traffic-policy shaper upload class 40 bandwidth 25%
set traffic-policy shaper upload class 40 burst 15k
set traffic-policy shaper upload class 40 ceiling 100%
set traffic-policy shaper upload class 40 description 'Games'
set traffic-policy shaper upload class 40 match DPI mark 40
set traffic-policy shaper upload class 40 priority 2
set traffic-policy shaper upload class 40 queue-type fair-queue
set traffic-policy shaper upload class 50 bandwidth 5%
set traffic-policy shaper upload class 50 burst 15k
set traffic-policy shaper upload class 50 ceiling 100%
set traffic-policy shaper upload class 50 description 'P2P+Torrent'
set traffic-policy shaper upload class 50 match DPI mark 50
set traffic-policy shaper upload class 50 match DPI2 mark 41
set traffic-policy shaper upload class 50 match DPI3 mark 51
set traffic-policy shaper upload class 50 match DPI4 mark 52
set traffic-policy shaper upload class 50 priority 7
set traffic-policy shaper upload class 50 queue-type fair-queue
set traffic-policy shaper upload default bandwidth 35%
set traffic-policy shaper upload default burst 15k
set traffic-policy shaper upload default ceiling 100%
set traffic-policy shaper upload default priority 6
set traffic-policy shaper upload default queue-limit 32
set traffic-policy shaper upload default queue-type fair-queue
set interfaces bridge br0 traffic-policy out download
set interfaces ethernet eth0 traffic-policy out upload
@TotalLag
Copy link
Author

TotalLag commented Aug 3, 2016

shaper default priority:
The priority with which this traffic class should be allocated extra bandwidth. The range is 0 to 7, where the higher the number the lower the priority. The default is 0.

shaper class priority:
The priority with which this traffic class should be allocated extra bandwidth. The range is 0 to 7, where the lower the number the lower the priority. The default is 0.

@TotalLag
Copy link
Author

TotalLag commented Aug 3, 2016

"It is definitely ordered 0-7 with 0 being the highest priority, I have the queueing numbers to prove it. I have gaming traffic and ICMP in 3, voice traffic in 4, media streaming in 5 (I run a home plex server), default traffic (all other web browsing basically) in 6, and torrent traffic in 7.

Note that if you want to do a range of ports at all, you will need to use a firewall modify rule and mark traffic that way. Hope this clears it up."

@hansfett98
Copy link

Hi TotalLag,

any idea on this:

can you please help me settings up an unfair-queue, where Employee vlan50 should always have priority?

Guest vlan25
Employee vlan50

I have a EdgeRouter X SFP in switch mode. The Gateway is connected to port eth0.

I have implemented to following code:

download policies

set traffic-policy shaper DOWNLOAD bandwidth 5mbit
set traffic-policy shaper DOWNLOAD class 25 bandwidth 10%

set traffic-policy shaper DOWNLOAD class 25 ceiling 90%

set traffic-policy shaper DOWNLOAD class 25 priority 7

set traffic-policy shaper DOWNLOAD class 25 queue-type fair-queue
set traffic-policy shaper DOWNLOAD class 25 match ADDR ip source address 192.168.25.0/24

set traffic-policy shaper DOWNLOAD class 50 bandwidth 90%

set traffic-policy shaper DOWNLOAD class 50 ceiling 100%

set traffic-policy shaper DOWNLOAD class 50 priority 0

set traffic-policy shaper DOWNLOAD class 50 queue-type fair-queue
set traffic-policy shaper DOWNLOAD class 50 match ADDR ip source address 192.168.50.0/24

set traffic-policy shaper DOWNLOAD default bandwidth 60%

set traffic-policy shaper DOWNLOAD default ceiling 100%

set traffic-policy shaper DOWNLOAD default priority 7

set traffic-policy shaper DOWNLOAD default queue-type fair-queue

apply to SwitchPort interface eth0

set interfaces switch switch0 traffic-policy out DOWNLOAD

1.) now the funny thing is, that both of the vlans have exactly the same speed when doing a 1Gbyte download...
2.) when setting this Traffic-Policy to an eth0 interface:
set interfaces input ifb0 traffic-policy out DOWNLOAD

set interfaces ethernet eth0 redirect ifb0

then I have to reset the router because it doesn't come up after rebooting...(no ping or DHCP working)

I'm really struggling on this for nights..

thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment