Skip to content

Instantly share code, notes, and snippets.

@pfactum
Created October 26, 2018 19:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pfactum/4b27c49a7f9b4d775e2e38ba23d3f13c to your computer and use it in GitHub Desktop.
Save pfactum/4b27c49a7f9b4d775e2e38ba23d3f13c to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
# Examples:
# bufferbloat start eth0 20 20
# bufferbloat stop eth0
self="$(basename $(/usr/bin/realpath ${0}))"
isp_uplink="${2}"
isp_downlink="ifb0"
max_download="${3}"
max_upload="${4}"
case "$1" in
start)
## downlink
ip link add name ${isp_downlink} type ifb
ip link set dev ${isp_downlink} up
tc qdisc add dev ${isp_uplink} handle ffff: ingress
tc qdisc add dev ${isp_downlink} root cake bandwidth ${max_download}mbit besteffort wash
tc filter add dev ${isp_uplink} parent ffff: protocol ip u32 match u32 0 0 action mirred egress redirect dev ${isp_downlink}
## uplink
tc qdisc add dev ${isp_uplink} root cake bandwidth ${max_upload}mbit
;;
stop)
tc qdisc del dev ${isp_uplink} handle ffff: ingress
tc qdisc del dev ${isp_uplink} root
tc qdisc del dev ${isp_downlink} root
ip link del name ${isp_downlink}
;;
*)
echo "Usage: ${self} <start|stop> <external interface> <downlink mbps> <uplink mbps>"
exit 1
;;
esac
# vim: set tabstop=4:softtabstop=4:shiftwidth=4:noexpandtab
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment