iptables 模組 recent 防字典(Brute force)與port scan等攻擊
作者:cross 日期:2010-03-16 12:11
recent 是 iptables 的一個模組,可以用來作一段時間阻擋某些連線,
recent 所搭配的參數有
--name XXX # 記錄資訊的檔案名稱,它會存在 /proc/net/ipt_recent/XXX,以下簡稱資料庫
--set # 指定符合條件的,加入或更新於XXX內
--rcheck #與資料庫比對,但不會修改更新
--update #與資料庫比對,會作修改更新
--remove # 與資料庫比對,存在就刪,不存在則否
--seconds X # 比對小於這個秒數的記錄才作動作,看是要更新還是刪除
--hitcount X # 重覆發生幾次連線
來個範例:
iptables 的 limit 模組使用
作者:cross 日期:2010-03-15 15:30
設定
-m limit 就是代表要使用 limit 這個功能iptables -A INPUT -p icmp --icmp-type 8 -m limit --limit 6/m --limit-burst 10 -j ACCEPT
iptables -A INPUT -p icmp --icmp-type 8 -j DROP
--limit 6/m 代表每分鐘只允許6個icmp
--limit-burst 10 代表每分鐘只允許10個icmp
是不是覺得很怪,到底是只允許6個還是10個 ??
實際舉例
PING 10.10.10.168 (10.10.10.168) 56(84) bytes of data.
64 bytes from 10.10.10.168: icmp_seq=0 ttl=64 time=4.10 ms
64 bytes from 10.10.10.168: icmp_seq=1 ttl=64 time=0.286 ms
64 bytes from 10.10.10.168: icmp_seq=2 ttl=64 time=0.281 ms
64 bytes from 10.10.10.168: icmp_seq=3 ttl=64 time=0.261 ms
iptables.sh + Bridge mode
作者:cross 日期:2007-01-03 22:02
#!/bin/bash
# 2006/10/18 Author cross@ssorc.tw
set -x
exif="eth0"
inif="eth1"
exip="210.17.16.68"
inip="10.1.1.1"
exnet="210.17.16.64/255.255.255.224" # -> 210.17.16.64/27
innet="10.1.1.0/24"
iptables -F
iptables -F -t nat
iptables -F -t mangle
iptables.sh + NAT
作者:cross 日期:2007-01-03 21:49
iptables.sh + 單機
作者:cross 日期:2006-12-28 15:10
iptables + 限制連入頻率
作者:cross 日期:2006-11-14 15:10
引用:
iptables -N ratelimit
iptables -A ratelimit -p tcp -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A ratelimit -p tcp --syn -m limit --limit 1/m --limit-burst 1 -j ACCEPT
iptables -A ratelimit -p tcp -j LOG --log-level "NOTICE" --log-prefix "[ratelimit]"
iptables -A ratelimit -p tcp -j DROP
iptables -A INPUT -p tcp --dport 22 -j ratelimit
--limit 1/s - 每秒一次--limit-burst 1 - 允許觸發limit限制的最大次數
iptables + 配對 MAC網卡卡號限制內部對外連線
作者:cross 日期:2006-11-14 15:10
在所有 tables上作限制皆有效用,但方便管理的話就統一用以下設定的吧
iptables -t filter -A FORWARD -m mac --mac-source 00:13:d3:a9:fc:ff -j DROP
等於
iptables -A FORWARD -m mac --mac-source 00:13:d3:a9:fc:ff -j DROP



