歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> Linux服務器 >> Linux下簡單限制網卡的帶寬

Linux下簡單限制網卡的帶寬

日期:2017/3/2 16:42:36   编辑:Linux服務器

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。

http://blog.s135.com/post/380.htma

Copyright © Linux教程網 All Rights Reserved