linux – 多个用户之间的公平带宽重新分配
发布时间:2020-12-13 17:07:11 所属栏目:Linux 来源:网络整理
导读:我在家里使用个人网络连接(50 mbps以上)有一台debian服务器.我已经使用OpenSSH设置了一个简单的SFTP服务,与多个用户共享大文件(10 Gb). 这是我的问题:关于带宽重新分配,它是丛林.我有用户使用标准ADSL连接,其他用户使用光纤连接等.每个用户都有不同的下载速
我在家里使用个人网络连接(50 mbps以上)有一台debian服务器.我已经使用OpenSSH设置了一个简单的SFTP服务,与多个用户共享大文件(10 Gb).
这是我的问题:关于带宽重新分配,它是丛林.我有用户使用标准ADSL连接,其他用户使用光纤连接等.每个用户都有不同的下载速度,通常最大的下载带宽获胜. 我想知道是否可以在用户之间“几乎同等地”划分我的上传带宽. 理想情况下,每个用户都能够下载高达50 / n mbps的文件(其中n是连接的用户数). 非常感谢您的帮助. 解决方法
由于您使用的是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用于预留. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- linux – 帮助我从ABS指南中了解bash中这个简单的io重定向
- linux – 使用quote作为键的Bash hashmap
- active-directory – Samba可以支持完整的Windows-ACL吗?
- linux – 在这种情况下,在fstab中配置UUID会有问题
- linux内核源代码中的“current”是什么?
- linux – 为什么当我删除虚拟机中的大文件时,主机上的磁盘映
- 如何在Linux上限制每个用户的“驻留集大小”
- linux – 使用Wget的Shell脚本 – 如果else嵌套在for循环中
- linux – 如何在QEMU上的GDB中单步执行ARM程序集?
- 详解Linux下swig 3.0.12的手动安装过程