tc 流量控制 上传下载设置

 tc_download.sh 下载设置用于内网网卡

#!/bin/sh

device=$1

/sbin/tc qdisc del dev $device root

/sbin/tc qdisc add dev $device root handle 1: htb default 11

/sbin/tc class add dev $device parent 1: classid 1:1 htb rate 1024mbit

/sbin/tc class add dev $device parent 1:1 classid 1:10  htb rate 1024mbit ceil 1024mbit

/sbin/tc class add dev $device parent 1:1 classid 1:11  htb rate 100mbit ceil 10mbit

/sbin/tc filter add dev $device protocol ip parent 1:0 prio 1 u32 match ip src 10.0.0.0/8 flowid 1:10

/sbin/tc filter add dev $device protocol ip parent 1:0 prio 1 u32 match ip src 192.168.0.0/16 flowid 1:11

/sbin/tc filter add dev $device protocol ip parent 1:0 prio 1 u32 match ip src 212.100.197.0/24 flowid 1:10

/sbin/tc qdisc add dev $device parent 1:10 handle 10: sfq

/sbin/tc qdisc add dev $device parent 1:11 handle 11: sfq

 

tc_upload.sh 上传速度限制 用于外网网卡

#!/bin/sh

device=$1

/sbin/tc qdisc del dev $device root

/sbin/tc qdisc add dev $device root handle 1: htb default 12

/sbin/tc class add dev $device parent 1: classid 1:1 htb rate 1024mbit

/sbin/tc class add dev $device parent 1:1 classid 1:10  htb rate 1024mbit ceil 1024mbit

/sbin/tc class add dev $device parent 1:1 classid 1:11  htb rate 10mbit ceil 10mbit

/sbin/tc class add dev $device parent 1:1 classid 1:12  htb rate 5mbit ceil 5mbit

/sbin/tc filter add dev $device protocol ip parent 1:0 prio 1 u32 match ip dst 10.1.12.76 flowid 1:10

/sbin/tc filter add dev $device protocol ip parent 1:0 prio 1 u32 match ip dst 10.1.11.7 flowid 1:10

/sbin/tc filter add dev $device protocol ip parent 1:0 prio 1 u32 match ip dst 10.1.11.225 flowid 1:10

/sbin/tc filter add dev $device protocol ip parent 1:0 prio 1 u32 match ip dst 10.1.11.226 flowid 1:10

/sbin/tc filter add dev $device protocol ip parent 1:0 prio 1 u32 match ip src 192.168.5.1 flowid 1:10

/sbin/tc filter add dev $device protocol ip parent 1:0 prio 1 u32 match ip dst 10.1.4.57 flowid 1:10

/sbin/tc filter add dev $device protocol ip parent 1:0 prio 1 u32 match ip dst 10.1.4.58 flowid 1:10

/sbin/tc filter add dev $device protocol ip parent 1:0 prio 1 u32 match ip dst 10.1.11.207 flowid 1:10

/sbin/tc filter add dev $device protocol ip parent 1:0 prio 1 u32 match ip dst 212.100.197.13 flowid 1:10

/sbin/tc filter add dev $device protocol ip parent 1:0 prio 1 u32 match ip dst 10.0.0.0/8 flowid 1:11

/sbin/tc qdisc add dev $device parent 1:10 handle 10: sfq

/sbin/tc qdisc add dev $device parent 1:11 handle 11: sfq

/sbin/tc qdisc add dev $device parent 1:12 handle 12: sfq

 

启动脚本 网卡eth1绑定多ip,用于双路

#!/bin/sh

/etc/tc_download.sh eth0

/etc/tc_upload.sh eth1

/etc/tc_upload.sh eth1.1

/etc/tc_upload.sh eth1.2

你可能感兴趣的:(职场,流量控制,休闲,tc,上传下载设置)