ansible/roles/tc_ratelimit/templates/tc-ratelimit.sh.j2
Sascha bc765668a6 sync: Inventory-Realabgleich + neue host_vars/roles/playbooks
Nachgezogener Arbeitsstand des Homelabs:
- neue host_vars (k3s-*, gluster-*, docmost, paperless, kometa, thelounge, satisfactory, wolfstack-vm)
- neue Rollen/Playbooks (net_watchdog, patchmon-agent, tc_ratelimit, sops-age, rotate-ssh-key, dns-doh, remove-postfix, checkrr-deploy)
- diverse Rollen-Updates (base, borg, dns_resolver, frp_client, hawser, nvidia)

Ausgeklammert (bleiben uncommittet): host_vars/docmost/vars.yml (Klartext-Token -> sollte vault-konform via vault_* referenziert werden).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-15 21:27:23 +02:00

26 lines
923 B
Django/Jinja
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
# tc per-flow rate limit deployed via Ansible
# Jede TCP-Connection bekommt max {{ tc_flow_limit }}
IFACE="{{ tc_iface }}"
FLOW_LIMIT="{{ tc_flow_limit }}"
TOTAL_LIMIT="{{ tc_total_limit }}"
BURST="{{ tc_burst }}"
case "${1}" in
start)
tc qdisc del dev "${IFACE}" root 2>/dev/null
tc qdisc add dev "${IFACE}" root handle 1: htb default 10
tc class add dev "${IFACE}" parent 1: classid 1:1 htb rate "${TOTAL_LIMIT}" burst "${BURST}"
tc class add dev "${IFACE}" parent 1:1 classid 1:10 htb rate "${TOTAL_LIMIT}" burst "${BURST}"
tc qdisc add dev "${IFACE}" parent 1:10 handle 10: fq maxrate "${FLOW_LIMIT}" flow_limit 200
echo "tc: ${FLOW_LIMIT}/flow on ${IFACE}"
;;
stop)
tc qdisc del dev "${IFACE}" root 2>/dev/null
;;
status)
tc -s qdisc show dev "${IFACE}"
tc -s class show dev "${IFACE}"
;;
*) echo "Usage: $0 {start|stop|status}"; exit 1 ;;
esac