Skip to content

Instantly share code, notes, and snippets.

@rraallvv
Created November 10, 2018 21:23
Show Gist options
  • Save rraallvv/bd4a0390586f0c9c076b72fb818fb4be to your computer and use it in GitHub Desktop.
Save rraallvv/bd4a0390586f0c9c076b72fb818fb4be to your computer and use it in GitHub Desktop.

Revisions

  1. rraallvv created this gist Nov 10, 2018.
    10 changes: 10 additions & 0 deletions traffic-controller-limit.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,10 @@
    # clear limit
    sudo tc qdisc del dev eth0 root

    # add limit
    cgcreate -g net_cls:slow
    echo 0x10001 > /sys/fs/cgroup/net_cls/slow/net_cls.classid
    cgclassify -g net_cls:slow <pid of the process you want to limit>
    tc qdisc add dev eth0 root handle 1: htb
    tc filter add dev eth0 parent 1: handle 1: cgroup
    tc class add dev eth0 parent 1: classid 1:1 htb rate 1mbps