都是自己記的筆記,分享給大家,點個關注啊。
通用匹配
-p 匹配協議 使用:-p tcp || udp || icmp || number
-s 匹配源IP地址 使用:-s 10.0.0.1 || 10.0.0.1/24
-d 匹配目的IP 使用:-d 10.0.0.1 || 10.0.0.1/24
-i 匹配進入的設備 使用:-i eth0 備: 只能用於INPUT,FORWARD和 PREROUTING鏈
-o 匹配出去的設備 使用:-o eth0
-f 匹配分片後的包
隱式匹配模塊
--sport 匹配源端口 使用:--sport 22 || 20:100 || :90 || !1024
--dport 匹配目的端口 使用:--dport 22 || 20:100 || :90 || !1024
--tcp-flags 匹配tcp標記 使用:--tcp-flags SYN,ACK,FIN SYN
--syn 匹配syn標記 使用:--syn
--tcp-option 匹配tcp選項 使用:--tcp-option 16
--icmp-type 匹配icmp類型 使用 :--icmp-type 8
這些匹配都是必須有 -p 選項才能使用的。
顯式匹配模塊
state 狀態匹配模塊 使用:
-m state --state NEW,ESTABLISHED,RELATED
iprange ip範圍匹配模塊 使用:
-m iprange --src-range || --dst-range 10.0.0.1-10.0.0.230
multiport 端口範圍匹配模塊 使用:
-m multiport --sourec-ports || --destination-ports || --port 3301,3394,3333
limit 速率匹配模塊 使用:
-m limit --limit 1000/3second/minute/hour /day
mac MAC地址匹配模塊:
-m mac --mac-source XX:XX:XX:XX:XX:XX 備:只能用在PREROUTING,FORWARD 和INPUT鏈
mark 標記匹配模塊:
-m mark --mark 1
owner ID匹配模塊:
-m owner --uid-owner || --pid-owner || --gid-owner || --sid-owner 100 備: 只能用在OUTPUT鏈
tos IP服務類型匹配模塊:
-m tos --tos 0x16
ttl 生存時間匹配模塊:
-m ttl --ttl 64
connlimit 連接限制模塊 :
-m connlimit --connlimit-above 5
time時間模塊:
-m time--timestart 09:40 --timestop 09:59 --weekdays Mon,Tue,Wed,Thu,Fri,Sat,Sun --kerneltz
webstr 網址過濾模塊:
-m webstr --url "qq.com"
string 字符匹配模塊:
-m string --string "sex" --algo bm