对LINUX服务器网卡进行带宽限制的办法:
1、安装iproute
yum -y install iproute
2、限制eth0网卡的带宽为500kbit:
/sbin/tc qdisc add dev eth0 root tbf rate 500kbit latency 50ms burst 15kb
TBF Example(限制带宽为1mbit)
To attach a TBF with a sustained maximum rate of 1mbit/s, a peakrate of 2.0mbit/s, a 10kilobyte buffer, with a pre-bucket queue size limit calculated so the TBF causes at most 70ms of latency, with perfect peakrate behavior, enter:
# tc qdisc add dev eth0 root tbf rate 1mbit burst 10kb latency 70ms peakrate 2mbit minburst 1540
3、解除eth0网卡的带宽限制:
/sbin/tc qdisc del dev eth0 root
4、列出已有的策略:
tc -s qdisc ls dev eth0
5、启动时自动加载带宽限制策略:
vim /etc/rc.local
加入: /sbin/tc qdisc add dev eth0 root tbf rate 500kbit latency 50ms burst 15kb
server004:所使用的命令 sudo tc qdisc add dev em1 root tbf rate 200mbit burst 10kb latency 70ms
实际速度在47M/s左右。
指南:使用Trickle限制应用程序带宽占用:http://www.linuxdiyf.com/linux/12360.html
Ubuntu终端下Nethogs命令查看网络带宽:http://www.linuxdiyf.com/linux/10969.html
怎样在Linux中限制网络带宽使用:http://www.linuxdiyf.com/linux/10147.html
Linux终端:speedtest_cli检测你的实时带宽速度:http://www.linuxdiyf.com/linux/2529.html