linux 带宽分配,linux – 多个用户之间的公平带宽重新分配

由于您使用的是Debian

Linux,因此您可以非常简单地完成它.您可以使用此脚本在带宽上进行“公平”重新分区:

#Put here your Internet-interface instead of eth1

ext_iface=eth1

eiface_addr=192.169.158.150

###############Remove shaper rules###############################3

iptables -t mangle --flush

tc qdisc del dev $ext_iface root 2> /dev/null > /dev/null

iptables -t mangle -D POSTROUTING -o $ext_iface -j shape-in 2> /dev/null > /dev/null

iptables -t mangle -F shape-in 2> /dev/null > /dev/null

iptables -t mangle -X shape-in 2> /dev/null > /dev/null

##############Adding shaper rules###################################

tc qdisc add dev $ext_iface root handle 1:0 htb default 10

tc class add dev $ext_iface parent 1:0 classid 1:1 htb rate 100mbit ceil 100mbit

tc class add dev $ext_iface parent 1:1 classid 1:5 htb rate 100mbit ceil 100mbit prio 0

tc class add dev $ext_iface parent 1:1 classid 1:10 htb rate 48mbit ceil 48mbit prio 0

tc qdisc add dev $ext_iface parent 1:5 handle 5: pfifo limit 5

tc qdisc add dev $ext_iface parent 1:10 handle 10: pfifo limit 10

iptables -t mangle -N shape-in

iptables -t mangle -I POSTROUTING -o $ext_iface -j shape-in

#Priority for pings

iptables -t mangle -A shape-in -p icmp -j MARK --set-mark 5

#Priority for Server Access

iptables -t mangle -A shape-in -s $eiface_addr -j MARK --set-mark 5

#Othet packets (user\'s internet traffic)

iptables -t mangle -A shape-in -m mark --mark 0 -j MARK --set-mark 10

tc filter add dev $ext_iface parent 1:0 prio 0 protocol ip handle 5 fw flowid 1:5

tc filter add dev $ext_iface parent 1:0 prio 1 protocol ip handle 10 fw flowid 1:10

请注意,用户将获得48 / n频道,并且剩余两个Mbs用于预留.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值