Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to limit the bandwidth of Network Card in Linux

2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

It is believed that many inexperienced people have no idea about how to limit the bandwidth of the network card in Linux. Therefore, this paper summarizes the causes and solutions of the problem. Through this article, I hope you can solve this problem.

1. Install iproute

The code is as follows:

Yum-y install iproute

2. Limit the bandwidth of eth0 Nic to 50kbit:

The code is as follows:

/ sbin/tc qdisc add dev eth0 root tbf rate 50kbit latency 50ms burst 1000

3. After the bandwidth is limited to 50kbit, wget downloads a large file in the 100-megabyte LAN:

The code is as follows:

[root@localhost ~] # wget http://192.168.1.7/test.zip

-- 19, 40, 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% [= >] 8994816 457K/s eta 27s

The download speed is 457K/s, and the limit effect is achieved.

4. Remove the bandwidth limit of the eth0 network card:

The code is as follows:

/ sbin/tc qdisc del dev eth0 root tbf

5. Comparison: without bandwidth restriction, wget downloads a large file in a 100-megabyte LAN:

The code is as follows:

[root@localhost ~] # wget http://192.168.1.7/test.zip

-- 19PUR 44PUR 33 FLU-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'

23862312 6.14M/s in 3.7s

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

The download speed is 6.16MB/s.

Netizens asked: after limiting the bandwidth to 50kbit, why did the download speed reach 457K/s?

Reply: the Linux kernel relies on rough timing information for fixed bandwidth. In a long period of time, a good accuracy can be maintained, but in the time period measured in seconds, the results are very inaccurate.

Therefore, the actual bandwidth used needs to be based on the download speed of wget to adjust the bandwidth limit of tc.

After reading the above, have you mastered the method of how to limit the bandwidth of the network card in Linux? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report