A simple method to restrict the bandwidth of network cards under Linux

Source: Internet
Author: User
Tags http request zip

1. Installation Iproute

The code is as follows:

Yum-y Install Iproute

2, limit the bandwidth of the Eth0 network card to 50kbit

The code is as follows:

/SBIN/TC qdisc add dev eth0 root TBF rate 50kbit Latency 50ms Burst 1000

3, limit the bandwidth of 50kbit, in the Hundred Gigabit lan wget download a large file:

The code is as follows:

[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 ... OK

length:23862312 (23M) [Application/zip]

Saving to: ' Test.zip '

37% [=======>] 8,994,816 457k/s ETA 27s

Download speed is 457k/s, limit effect reach.

4, the ETH0 network card to remove the bandwidth limit:

The code is as follows:

/SBIN/TC Qdisc del Dev eth0 root TBF

5, Contrast: No bandwidth restrictions, in the Hundred Gigabit lan wget download a large file:

The code is as follows:

[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 ... 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]

Download speed is 6.16mb/s.

User questions: Limit bandwidth of 50kbit, why download speed to reach 457k/s?

Reply: The Linux kernel relies on rough timing information for bandwidth retention. In a longer period of time, good precision can be maintained, but the result is very inaccurate in the time period measured in seconds.

Therefore, the actual use of bandwidth needs to be wget download speed, to adjust the TC bandwidth limit.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.