Skip to content

Instantly share code, notes, and snippets.

@nolash
Created April 24, 2018 08:24
Show Gist options
  • Save nolash/3a0294d7722cb89120757c473f2be026 to your computer and use it in GitHub Desktop.
Save nolash/3a0294d7722cb89120757c473f2be026 to your computer and use it in GitHub Desktop.
swarm throttling with iptables + tc
#!/bin/bash
UID=$1
iptables -A OUTPUT -t mangle -m owner --uid-owner $UID -j MARK --set-mark 6
tc qdisc add dev enp2s0 root handle 1: htb default 30
tc class add dev enp2s0 parent 1: classid 1:1 htb rate 6mbit burst 15k
tc class add dev enp2s0 parent 1: classid 1:2 htb rate 1mbit burst 15k
tc filter add dev enp2s0 protocol ip parent 1:0 prio 1 handle 6 fw flowid 1:2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment