Wrote a script for traffic shaping for one machine on the local network, eth0-looks in the LAN, eth1 to the ISP. Tell me why it is not working shaper?
The script code
shaper.sh:
# show
if [ "$1" = "show" ]; then
/sbin/tc -s qdisc show dev eth0
/sbin/tc-s class show dev eth0
/sbin/tc-s filter show dev eth0
/sbin/tc-s filter show dev eth0 parent 12:
exit;
fi
if [ "$1" = "stop" ]; then
echo "Stopped."
# clean
/sbin/tc qdisc del dev eth0 root 2>/dev/null
/sbin/tc qdisc del dev eth1 root 2>/dev/null
/sbin/tc qdisc del dev eth0 ingress 2> /dev/null
exit
fi
if [ "$1" = "start" ]; then
echo "Started."
/sbin/tc qdisc add dev eth0 root handle 1: prio bands 3
/sbin/tc qdisc add dev eth0 parent 1:1 handle 10: pfifo
/sbin/tc qdisc add dev eth0 parent 1:2 handle 11: pfifo
/sbin/tc qdisc add dev eth0 parent 1:3 handle 12: htb default 0
/sbin/tc filter add dev eth0 parent 12: prio 3 handle 1: protocol ip u32 divisor 256
/sbin/tc filter add dev eth0 protocol ip parent 12: prio 3 u32 match ip dst 172.16.0.0/24 hashkey mask 0x000000ff at 16 link 1:
/sbin/tc class add dev eth0 parent 12: classid 12:101 htb rate 1024Kbit ceil 1024Kbit quantum 1514 mtu 16500
/sbin/tc qdisc add dev eth0 parent 12:101 handle 101: sfq perturb 5
/sbin/tc filter add dev eth0 protocol ip parent 12: prio 7 u32 ht 1:65: match ip dst 172.16.0.2 flowid 12:101
/sbin/tc filter add dev eth0 parent 1:0 protocol ip prio 4 u32 match ip dst 172.16.0.0/24 flowid 1:3
exit
fi
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
list)
list
;;
stats)
list-s
;;
*)
echo "Usage: $0 {start|stop|restart|list|stats}"
exit 1
esac
The output of
tc-s class show dev eth0:
root@promeline://# tc-s class show dev eth0
class prio 1:1 parent 1: leaf 10:
Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0)
backlog 0b 0p requeues 0
class prio 1:2 parent 1: leaf 11:
Sent 84 bytes 2 pkt (dropped 0, overlimits 0 requeues 0)
backlog 0b 0p requeues 0
class prio 1:3 parent 1: leaf 12:
1287381 Sent 1545 bytes pkt (dropped 0, overlimits 0 requeues 0)
backlog 0b 0p requeues 0
class htb 12:101 root leaf 101: prio 0 rate 1024Kbit ceil 1024Kbit burst cburst 16499b 16499b
Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0)
rate 0bit 0pps backlog 0b 0p requeues 0
lended: 0 borrowed: 0 giants: 0
tokens: ctokens 2014156: 2014156
class htb 12:102 root leaf 102: prio 0 rate 1024Kbit ceil 1024Kbit burst cburst 16499b 16499b
Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0)
rate 0bit 0pps backlog 0b 0p requeues 0
lended: 0 borrowed: 0 giants: 0
tokens: ctokens 2014156: 2014156