iptables 常用配置收藏

iptables 配置收藏

-A INPUT -s 10.0.0.1 -p tcp --dport 8000 -m comment --comment "源ip-->目标:端口" -j ACCEPT             
-A INPUT -p tcp -m multiport --dports 8080:8090 -m comment --comment "添加连续多端口" -j ACCEPT      
-A INPUT -p tcp -m multiport --dports 22,80,443 -m comment --comment "添加非连续多端口" -j ACCEPT     
-A INPUT -m iprange --src-range 122.10.27.100-122.10.27.200 -p udp --dport 7087 -m comment --comment "添加连续IP" -j ACCEPT  
-A INPUT -p tcp -m time --timestart 02:00--timestop 03:00  -m comment --comment "凌晨 2 点到 3 点之间拒绝所有的 TCP访问" -j DROP
-A INPUT -p udp -m time --timestart 02:00--timestop 03:00  -m comment --comment "凌晨 2 点到 3 点之间拒绝所有的 UDP 访问" -j DROP
-A INPUT -p tcp -syn -m multiport -dport http,https -m connlimit --connlimit-above 20 -m comment --comment "限制单个IP地址到服务器创建连接的数量为20,防止DOS攻击" -j REJECT --reject-with-tcp-reset
-A OUTPUT  -p tcp  -m multiport  --dport http,https  -i eth0  -o eth1  -m time --timestart 12:00  -timestop 13:00  -d 31.13.64.0/18 -m comment --comment "在12点到13点之间允许到 31.13.64.0/18的 http和https的访问" -j ACCEPT
-A INPUT -p tcp -m tcp --tcp-flags SYN,ACK SYN,ACK -m state --state NEW -m comment --comment "拒绝TCP标记为SYN/ACK但连接状态为NEW的数据包,防止ACK欺骗" -j REJECT --reject-with tcp-reset
-A INPUT -p tcp -m tcp ! --tcp-flags FIN,SYN,RST,ACK SYN -m state --state NEW -m comment --comment "拒绝TCP除了标记为FIN,SYN,RST,ACK SYN之外的,但连接状态为NEW的数据包,防止接口堵塞"-j REJECT --reject-with tcp-reset 

posted @ 2018-12-14 17:02  Carry00  阅读(3743)  评论(0编辑  收藏  举报