Last active
March 6, 2018 19:30
-
-
Save cwshu/6983d7b228a6abbd1526f497e6cf2fc0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# requirement: | |
# install libcgroup | |
# | |
# usage: | |
# $ ./tc_cgroup.sh | |
# $ cgexec -g net_cls:gdrive fish | |
USER=susu | |
CGROUP_NAME=gdrive | |
IFACE=eno1 | |
RATE=20mbit | |
sudo cgcreate -t $USER -a $USER -g net_cls:$CGROUP_NAME | |
echo 0x100001 > /sys/fs/cgroup/net_cls/$CGROUP_NAME/net_cls.classid | |
sudo tc qdisc add dev $IFACE root handle 10: htb | |
sudo tc class add dev $IFACE parent 10: classid 10:1 htb rate $RATE | |
sudo tc filter add dev $IFACE parent 10: protocol ip prio 10 handle 1: cgroup |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment