Linux下简单限制网卡的带宽

 原贴:http://www.kuqin.com/linux/20081204/29414.html

Linux下限制网卡的带宽,可用来模拟服务器带宽耗尽,从而测试服务器在此时的访问效果。

  1、安装iproute
yum -y install iproute


  2、限制eth0网卡的带宽为50kbit:
/sbin/tc qdisc add dev eth0 root tbf rate 50kbit latency 50ms burst 1000


  3、限制带宽为50kbit后,在百兆局域网中wget下载一个大文件:
[root@localhost ~]# wget http://192.168.1.7/test.zip
--19:40:27--  http://192.168.1.7/test.zip
Connecting to 192.168.1.7:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 23862312 (23M) [application/zip]
Saving to: `test.zip'

37% [=======>   ] 8,994,816    457K/s  eta 27s

  下载速度为457K/s,限制效果达到。

  4、解除eth0网卡的带宽限制:
/sbin/tc qdisc del dev eth0 root tbf


  5、对比:未作带宽限制情况下,在百兆局域网中wget下载一个大文件:
[root@localhost ~]# wget http://192.168.1.7/test.zip    
--19:44:33--  http://192.168.1.7/test.zip
Connecting to 192.168.1.7:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 23862312 (23M) [application/zip]
Saving to: `test.zip'

100%[==========>] 23,862,312  6.14M/s   in 3.7s  

19:44:36 (6.16 MB/s) - `test.zip' saved [23862312/23862312]

  下载速度为6.16MB/s。
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值