Created
October 26, 2018 19:05
-
-
Save pfactum/4b27c49a7f9b4d775e2e38ba23d3f13c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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