Skip to content

Instantly share code, notes, and snippets.

@mlomeli
Forked from beardicus/edgerouter-qos
Last active September 30, 2016 13:17
Show Gist options
  • Select an option

  • Save mlomeli/991961d3f9064f027ae0 to your computer and use it in GitHub Desktop.

Select an option

Save mlomeli/991961d3f9064f027ae0 to your computer and use it in GitHub Desktop.

Revisions

  1. mlomeli revised this gist May 26, 2015. 1 changed file with 0 additions and 46 deletions.
    46 changes: 0 additions & 46 deletions edgerouter-qos
    Original file line number Diff line number Diff line change
    @@ -12,52 +12,6 @@ rule | portgroup



    # Code

    //download is typically 5 and change. everything can burst to 100%
    //of bandwidth, priority rules keep the garbage in check

    set traffic-policy shaper download
    set traffic-policy shaper download bandwidth 5Mbit

    # set default download priority
    set traffic-policy shaper download default bandwidth 70%
    set traffic-policy shaper download default ceiling 100%
    set traffic-policy shaper download default priority 2
    set traffic-policy shaper download default queue-type fair-queue

    # megasuper priority dns and ssh and icmp
    set traffic-policy shaper download class 10 bandwidth 10%
    set traffic-policy shaper download class 10 ceiling 100%
    set traffic-policy shaper download class 10 priority 5
    set traffic-policy shaper download class 10 queue-type fair-queue
    set traffic-policy shaper download class 10 match icmp ip protocol icmp
    set traffic-policy shaper download class 10 match superssh mark 1

    #gaming
    set traffic-policy shaper download class 20 bandwidth 10%
    set traffic-policy shaper download class 20 ceiling 100%
    set traffic-policy shaper download class 20 priority 4
    set traffic-policy shaper download class 20 queue-type fair-queue
    set traffic-policy shaper download class 20 match gaming mark 2

    # semipriority http and https
    set traffic-policy shaper download class 30 bandwidth 10%
    set traffic-policy shaper download class 30 ceiling 100%
    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 30 match http ip source port 80
    set traffic-policy shaper download class 30 match https ip source port 443

    # garbage downloads
    set traffic-policy shaper download class 40 bandwidth 10%
    set traffic-policy shaper download class 40 ceiling 100%
    set traffic-policy shaper download class 40 priority 1
    set traffic-policy shaper download class 40 queue-type fair-queue
    set traffic-policy shaper download class 40 match downloading mark 3

    set interfaces ethernet eth1 traffic-policy out download


    # upload is typically 5.5-ish. should be clamped at less than 100%
    # of advertised bandwidth to avoid buffer bloat and lag
  2. mlomeli revised this gist May 26, 2015. 1 changed file with 1 addition and 7 deletions.
    8 changes: 1 addition & 7 deletions edgerouter-qos
    Original file line number Diff line number Diff line change
    @@ -9,20 +9,14 @@ rule | portgroup
    1 | super ssh dns
    2 | gaming
    3 | downloading
    4 | default allow
    5 | default deny



    # Code

    //download is typically 5 and change. everything can burst to 100%
    //of bandwidth, priority rules keep the garbage in check


    set firewall modify WAN_IN rule 1 modify mark 1
    set firewall modify WAN_IN rule 2 modify mark 2
    set firewall modify WAN_IN rule 3 modify mark 3

    set traffic-policy shaper download
    set traffic-policy shaper download bandwidth 5Mbit

  3. mlomeli revised this gist May 26, 2015. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion edgerouter-qos
    Original file line number Diff line number Diff line change
    @@ -109,4 +109,4 @@ set traffic-policy shaper upload class 20 priority 1
    set traffic-policy shaper upload class 20 queue-type fair-queue
    set traffic-policy shaper upload class 20 match downloading mark 3

    set interfaces ethernet eth0 traffic-policy out upload
    set interfaces ethernet eth1 traffic-policy out upload
  4. mlomeli revised this gist May 26, 2015. 1 changed file with 34 additions and 35 deletions.
    69 changes: 34 additions & 35 deletions edgerouter-qos
    Original file line number Diff line number Diff line change
    @@ -13,19 +13,23 @@ rule | portgroup
    5 | default deny


    # Code

    //download is typically 5 and change. everything can burst to 100%
    //of bandwidth, priority rules keep the garbage in check

    # download is typically 4 and change. everything can burst to 100%
    # of bandwidth, priority rules keep the garbage in check

    set firewall modify WAN_IN rule 1 modify mark 1
    set firewall modify WAN_IN rule 2 modify mark 2
    set firewall modify WAN_IN rule 3 modify mark 3

    set traffic-policy shaper download
    set traffic-policy shaper download bandwidth 5Mbit

    # set default download priority
    set traffic-policy shaper download default bandwidth 70%
    set traffic-policy shaper download default ceiling 100%
    set traffic-policy shaper download default priority 3
    set traffic-policy shaper download default priority 2
    set traffic-policy shaper download default queue-type fair-queue

    # megasuper priority dns and ssh and icmp
    @@ -34,34 +38,29 @@ set traffic-policy shaper download class 10 ceiling 100%
    set traffic-policy shaper download class 10 priority 5
    set traffic-policy shaper download class 10 queue-type fair-queue
    set traffic-policy shaper download class 10 match icmp ip protocol icmp
    set traffic-policy shaper download class 10 match ssh ip source port 22
    set traffic-policy shaper download class 10 match dns ip source port 53
    set traffic-policy shaper download class 10 match superssh mark 1

    #gaming
    set traffic-policy shaper download class 20 bandwidth 10%
    set traffic-policy shaper download class 20 ceiling 100%
    set traffic-policy shaper download class 20 priority 4
    set traffic-policy shaper download class 20 queue-type fair-queue
    set traffic-policy shaper download class 20 match diablo31 ip source port 1119
    set traffic-policy shaper download class 20 match hearthstone ip source port 3724
    set traffic-policy shaper download class 20 match gaming mark 2

    # semipriority http and https
    set traffic-policy shaper download class 20 bandwidth 10%
    set traffic-policy shaper download class 20 ceiling 100%
    set traffic-policy shaper download class 20 priority 4
    set traffic-policy shaper download class 20 queue-type fair-queue
    set traffic-policy shaper download class 20 match http ip source port 80
    set traffic-policy shaper download class 20 match https ip source port 443

    # garbage bittorrent
    set traffic-policy shaper download class 30 bandwidth 10%
    set traffic-policy shaper download class 30 ceiling 100%
    set traffic-policy shaper download class 30 priority 1
    set traffic-policy shaper download class 30 priority 3
    set traffic-policy shaper download class 30 queue-type fair-queue
    # FIXME: no port ranges in QOS rules.
    # instead, mark packets in a firewall rule and match on that
    #set traffic-policy shaper download class 30 match bittorrent ip source port 6881-6889
    set traffic-policy shaper download class 30 match transmission ip source port 51413
    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

    # garbage downloads
    set traffic-policy shaper download class 40 bandwidth 10%
    set traffic-policy shaper download class 40 ceiling 100%
    set traffic-policy shaper download class 40 priority 1
    set traffic-policy shaper download class 40 queue-type fair-queue
    set traffic-policy shaper download class 40 match downloading mark 3

    set interfaces ethernet eth1 traffic-policy out download

    @@ -70,7 +69,7 @@ set interfaces ethernet eth1 traffic-policy out download
    # of advertised bandwidth to avoid buffer bloat and lag

    set traffic-policy shaper upload
    set traffic-policy shaper upload bandwidth 5Mbit
    set traffic-policy shaper upload bandwidth 500Kbit

    # high priority, interactive, ssh, dns, icmp
    set traffic-policy shaper upload class 2 bandwidth 10%
    @@ -79,35 +78,35 @@ set traffic-policy shaper upload class 2 priority 5
    set traffic-policy shaper upload class 2 queue-type fair-queue
    set traffic-policy shaper upload class 2 queue-limit 16
    set traffic-policy shaper upload class 2 match icmp ip protocol icmp
    set traffic-policy shaper upload class 2 match ssh ip destination port 22
    set traffic-policy shaper upload class 2 match dns ip destination port 53
    set traffic-policy shaper upload class 2 match superssh mark 1

    # high priority but not quite so much, http, https
    # high priority but not quite so much
    set traffic-policy shaper upload class 5 bandwidth 10%
    set traffic-policy shaper upload class 5 ceiling 100%
    set traffic-policy shaper upload class 5 priority 4
    set traffic-policy shaper upload class 5 queue-type fair-queue
    set traffic-policy shaper upload class 5 match http ip destination port 80
    set traffic-policy shaper upload class 5 match https ip destination port 443
    set traffic-policy shaper upload class 5 match gaming mark 2

    # high priority but not quite so much, http, https
    set traffic-policy shaper upload class 6 bandwidth 10%
    set traffic-policy shaper upload class 6 ceiling 100%
    set traffic-policy shaper upload class 6 priority 3
    set traffic-policy shaper upload class 6 queue-type fair-queue
    set traffic-policy shaper upload class 6 match http ip destination port 80
    set traffic-policy shaper upload class 6 match https ip destination port 443

    # everything else is middle-of-the-road priority
    set traffic-policy shaper upload default bandwidth 60%
    set traffic-policy shaper upload default ceiling 100%
    set traffic-policy shaper upload default priority 3
    set traffic-policy shaper upload default priority 2
    set traffic-policy shaper upload default queue-type fair-queue

    # crashplan traffic only, set DSCP to 32 in crashplan, matches 8 here (?)
    set traffic-policy shaper upload class 10 bandwidth 10%
    set traffic-policy shaper upload class 10 ceiling 100%
    set traffic-policy shaper upload class 10 priority 2
    set traffic-policy shaper upload class 10 queue-type fair-queue
    set traffic-policy shaper upload class 10 match crashplan ip dscp 8

    # bulk, bittorrent from transmission client on default port
    # torrent & usenet
    set traffic-policy shaper upload class 20 bandwidth 10%
    set traffic-policy shaper upload class 20 ceiling 100%
    set traffic-policy shaper upload class 20 priority 1
    set traffic-policy shaper upload class 20 queue-type fair-queue
    set traffic-policy shaper upload class 20 match bittorrent ip source port 51413
    set traffic-policy shaper upload class 20 match downloading mark 3

    set interfaces ethernet eth0 traffic-policy out upload
  5. mlomeli revised this gist May 26, 2015. 1 changed file with 12 additions and 10 deletions.
    22 changes: 12 additions & 10 deletions edgerouter-qos
    Original file line number Diff line number Diff line change
    @@ -1,14 +1,16 @@
    #
    ## QOS GAMING EDGEROUTER ##
    # 1. Prerequisites
    # 1.1 define port-groups (eg. gaming browsing downloading(usenet,torrent))
    # 1.2. define an accept rule for each port-group src dest
    # rule | portgroup
    # 1 | super ssh dns
    # 2 | gaming
    # 3 | downloading
    # 4 | default allow
    # 5 | default deny
    # QOS GAMING EDGEROUTER
    ## 1. Prerequisites
    ### 1.1 define port-groups
    (eg. gaming browsing downloading(usenet,torrent))
    ### 1.2. define an accept rule for each port-group src dest
    rule | portgroup
    -----| -----------
    1 | super ssh dns
    2 | gaming
    3 | downloading
    4 | default allow
    5 | default deny



  6. mlomeli revised this gist May 26, 2015. 1 changed file with 24 additions and 5 deletions.
    29 changes: 24 additions & 5 deletions edgerouter-qos
    Original file line number Diff line number Diff line change
    @@ -1,13 +1,24 @@

    #
    # fair-queue based settings for EdgeRouter Lite traffic shaping
    #
    ## QOS GAMING EDGEROUTER ##
    # 1. Prerequisites
    # 1.1 define port-groups (eg. gaming browsing downloading(usenet,torrent))
    # 1.2. define an accept rule for each port-group src dest
    # rule | portgroup
    # 1 | super ssh dns
    # 2 | gaming
    # 3 | downloading
    # 4 | default allow
    # 5 | default deny


    # download is typically 30 and change. everything can burst to 100%


    # download is typically 4 and change. everything can burst to 100%
    # of bandwidth, priority rules keep the garbage in check


    set traffic-policy shaper download
    set traffic-policy shaper download bandwidth 30Mbit
    set traffic-policy shaper download bandwidth 5Mbit

    # set default download priority
    set traffic-policy shaper download default bandwidth 70%
    @@ -24,6 +35,14 @@ set traffic-policy shaper download class 10 match icmp ip protocol icmp
    set traffic-policy shaper download class 10 match ssh ip source port 22
    set traffic-policy shaper download class 10 match dns ip source port 53

    #gaming
    set traffic-policy shaper download class 20 bandwidth 10%
    set traffic-policy shaper download class 20 ceiling 100%
    set traffic-policy shaper download class 20 priority 4
    set traffic-policy shaper download class 20 queue-type fair-queue
    set traffic-policy shaper download class 20 match diablo31 ip source port 1119
    set traffic-policy shaper download class 20 match hearthstone ip source port 3724

    # semipriority http and https
    set traffic-policy shaper download class 20 bandwidth 10%
    set traffic-policy shaper download class 20 ceiling 100%
  7. @beardicus beardicus revised this gist Jan 20, 2015. 1 changed file with 0 additions and 1 deletion.
    1 change: 0 additions & 1 deletion edgerouter-qos
    Original file line number Diff line number Diff line change
    @@ -51,7 +51,6 @@ set interfaces ethernet eth1 traffic-policy out download
    set traffic-policy shaper upload
    set traffic-policy shaper upload bandwidth 5Mbit


    # high priority, interactive, ssh, dns, icmp
    set traffic-policy shaper upload class 2 bandwidth 10%
    set traffic-policy shaper upload class 2 ceiling 100%
  8. @beardicus beardicus revised this gist Jan 20, 2015. 1 changed file with 70 additions and 9 deletions.
    79 changes: 70 additions & 9 deletions edgerouter-qos
    Original file line number Diff line number Diff line change
    @@ -1,32 +1,93 @@

    #
    # fair-queue based settings for EdgeRouter Lite traffic shaping
    #

    # download is typically 30 and change. everything is “default” right
    # now, so this isn’t doing much
    # download is typically 30 and change. everything can burst to 100%
    # of bandwidth, priority rules keep the garbage in check

    set traffic-policy shaper download
    set traffic-policy shaper download bandwidth 30Mbit
    set traffic-policy shaper download default bandwidth 100%

    # set default download priority
    set traffic-policy shaper download default bandwidth 70%
    set traffic-policy shaper download default ceiling 100%
    set traffic-policy shaper download default priority 3
    set traffic-policy shaper download default queue-type fair-queue

    # megasuper priority dns and ssh and icmp
    set traffic-policy shaper download class 10 bandwidth 10%
    set traffic-policy shaper download class 10 ceiling 100%
    set traffic-policy shaper download class 10 priority 5
    set traffic-policy shaper download class 10 queue-type fair-queue
    set traffic-policy shaper download class 10 match icmp ip protocol icmp
    set traffic-policy shaper download class 10 match ssh ip source port 22
    set traffic-policy shaper download class 10 match dns ip source port 53

    # semipriority http and https
    set traffic-policy shaper download class 20 bandwidth 10%
    set traffic-policy shaper download class 20 ceiling 100%
    set traffic-policy shaper download class 20 priority 4
    set traffic-policy shaper download class 20 queue-type fair-queue
    set traffic-policy shaper download class 20 match http ip source port 80
    set traffic-policy shaper download class 20 match https ip source port 443

    # garbage bittorrent
    set traffic-policy shaper download class 30 bandwidth 10%
    set traffic-policy shaper download class 30 ceiling 100%
    set traffic-policy shaper download class 30 priority 1
    set traffic-policy shaper download class 30 queue-type fair-queue
    # FIXME: no port ranges in QOS rules.
    # instead, mark packets in a firewall rule and match on that
    #set traffic-policy shaper download class 30 match bittorrent ip source port 6881-6889
    set traffic-policy shaper download class 30 match transmission ip source port 51413

    set interfaces ethernet eth1 traffic-policy out download


    # upload is typically 5.5-ish. should be clamped at less than 100%
    # of advertised bandwidth to avoid buffer bloat and lag

    set traffic-policy shaper upload
    set traffic-policy shaper upload bandwidth 5Mbit

    # guarantee default traffic at least 50% of bandwidth
    set traffic-policy shaper upload default bandwidth 50%

    # high priority, interactive, ssh, dns, icmp
    set traffic-policy shaper upload class 2 bandwidth 10%
    set traffic-policy shaper upload class 2 ceiling 100%
    set traffic-policy shaper upload class 2 priority 5
    set traffic-policy shaper upload class 2 queue-type fair-queue
    set traffic-policy shaper upload class 2 queue-limit 16
    set traffic-policy shaper upload class 2 match icmp ip protocol icmp
    set traffic-policy shaper upload class 2 match ssh ip destination port 22
    set traffic-policy shaper upload class 2 match dns ip destination port 53

    # high priority but not quite so much, http, https
    set traffic-policy shaper upload class 5 bandwidth 10%
    set traffic-policy shaper upload class 5 ceiling 100%
    set traffic-policy shaper upload class 5 priority 4
    set traffic-policy shaper upload class 5 queue-type fair-queue
    set traffic-policy shaper upload class 5 match http ip destination port 80
    set traffic-policy shaper upload class 5 match https ip destination port 443

    # everything else is middle-of-the-road priority
    set traffic-policy shaper upload default bandwidth 60%
    set traffic-policy shaper upload default ceiling 100%
    set traffic-policy shaper upload default priority 3
    set traffic-policy shaper upload default queue-type fair-queue

    # crashplan traffic only guaranteed 10%
    # crashplan traffic only, set DSCP to 32 in crashplan, matches 8 here (?)
    set traffic-policy shaper upload class 10 bandwidth 10%
    set traffic-policy shaper upload class 10 ceiling 90%
    set traffic-policy shaper upload class 10 match crashplan ip dscp 8
    set traffic-policy shaper upload class 10 ceiling 100%
    set traffic-policy shaper upload class 10 priority 2
    set traffic-policy shaper upload class 10 queue-type fair-queue
    set traffic-policy shaper upload class 10 match crashplan ip dscp 8

    # bulk, bittorrent from transmission client on default port
    set traffic-policy shaper upload class 20 bandwidth 10%
    set traffic-policy shaper upload class 20 ceiling 100%
    set traffic-policy shaper upload class 20 priority 1
    set traffic-policy shaper upload class 20 queue-type fair-queue
    set traffic-policy shaper upload class 20 match bittorrent ip source port 51413

    set interfaces ethernet eth0 traffic-policy out upload
    set interfaces ethernet eth0 traffic-policy out upload
  9. @beardicus beardicus created this gist Dec 19, 2014.
    32 changes: 32 additions & 0 deletions edgerouter-qos
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,32 @@
    #
    # fair-queue based settings for EdgeRouter Lite traffic shaping
    #

    # download is typically 30 and change. everything is “default” right
    # now, so this isn’t doing much
    set traffic-policy shaper download
    set traffic-policy shaper download bandwidth 30Mbit
    set traffic-policy shaper download default bandwidth 100%
    set traffic-policy shaper download default ceiling 100%
    set traffic-policy shaper download default queue-type fair-queue

    set interfaces ethernet eth1 traffic-policy out download


    # upload is typically 5.5-ish. should be clamped at less than 100%
    # of advertised bandwidth to avoid buffer bloat and lag
    set traffic-policy shaper upload
    set traffic-policy shaper upload bandwidth 5Mbit

    # guarantee default traffic at least 50% of bandwidth
    set traffic-policy shaper upload default bandwidth 50%
    set traffic-policy shaper upload default ceiling 100%
    set traffic-policy shaper upload default queue-type fair-queue

    # crashplan traffic only guaranteed 10%
    set traffic-policy shaper upload class 10 bandwidth 10%
    set traffic-policy shaper upload class 10 ceiling 90%
    set traffic-policy shaper upload class 10 match crashplan ip dscp 8
    set traffic-policy shaper upload class 10 queue-type fair-queue

    set interfaces ethernet eth0 traffic-policy out upload