Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#!/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
You can’t perform that action at this time.