Skip to content

Instantly share code, notes, and snippets.

Created November 2, 2011 19:05
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
# SSH class: for outgoing connections to
# avoid lag when somebody else is downloading
# however, an SSH connection cannot fill up
# the connection to more than 70%
echo "#---ssh - id 300 - rate 160 kbit ceil 1120 kbit"
/sbin/tc class add dev eth0 parent 1:1 classid 1:300 htb \
rate 160kbit ceil 1120kbit burst 15k prio 3
# SFQ will mix the packets if there are several
# SSH connections in parallel
# and ensure that none has the priority
echo "#--- ~ sub ssh: sfq"
/sbin/tc qdisc add dev eth0 parent 1:300 handle 1300: \
sfq perturb 10 limit 32
echo "#--- ~ ssh filter"
/sbin/tc filter add dev eth0 parent 1:0 protocol ip \
prio 3 handle 300 fw flowid 1:300
echo "#--- ~ netfilter rule - SSH at 300"
/sbin/iptables -t mangle -A POSTROUTING -o eth0 -p tcp
--tcp-flags SYN SYN -dport 22 -j CONNMARK \
--set-mark 300
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment