iptables限速 iptables限制流量
生活随笔
收集整理的這篇文章主要介紹了
iptables限速 iptables限制流量
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
iptables限速 iptables限制流量
Author:gaojinbo
Time:2010-9-12
?
http://www.gaojinbo.com/iptables%E9%99%90%E9%80%9F-iptables%E9%99%90%E5%88%B6%E6%B5%81%E9%87%8F.html
linux下通過iptables限制流量,簡單,實用。通過以下腳本即可實現(xiàn),首先需要將這臺機器配置成網(wǎng)關(guān)。
?
1.配置iptables轉(zhuǎn)發(fā)(略)
?
2.限速腳本
vi /root/xiansu.sh<br />#!/bin/bash<br />/sbin/iptables -F FORWARD<p>#限制網(wǎng)段 <br /><br />for ((i = 1; i < 253; i++))  <br />do<br /> /sbin/iptables -A FORWARD -s 192.168.2.$i -m limit \--limit 60/s -j ACCEPT <br />/sbin/iptables -A FORWARD -s 192.168.2.$i -j DROP </p><br />done <p>#限制單個ip <br />/sbin/iptables -A FORWARD -s 192.168.1.135/32 -m limit \--limit 60/s -j ACCEPT <br />/sbin/iptables -A FORWARD -s 192.168.1.135/32 -j DROP</p>?
?
2.增加執(zhí)行權(quán)限:
chmod+x /root/xiansu.sh
?
當(dāng)流量小于60/s的時候,iptables 接受并轉(zhuǎn)發(fā)。當(dāng)流量大于60/s 的時候,iptables丟棄數(shù)據(jù)包。
完成!
總結(jié)
以上是生活随笔為你收集整理的iptables限速 iptables限制流量的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 金山网盾3.6beta2新增下载安全防御
- 下一篇: 市场调研-全球与中国防破坏开关市场现状及