iptables 做mail防火墙脚本

#!/bin/bash
iptables -F
iptables -F -t nat
iptables -X
iptables -P INPUT DROP
iptables -P OUTPUT ACCEPT
iptables -P FORWARD ACCEPT
#load connection-tracking modules
modprobe iptable_nat
modprobe ip_conntrack_ftp
modprobe ip_nat_ftp
iptables -A INPUT -i lo -j ACCEPT
iptables -A OUTPUT -o lo -j ACCEPT
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A INPUT -s 122.70.121.XXX -j ACCEPT
iptables -A INPUT -s 122.70.121.XXX -j ACCEPT
iptables -A INPUT -s 122.70.121.XXX -j ACCEPT
iptables -N synflood
iptables -A synflood -m limit --limit 10/s --limit-burst 100 -j RETURN
iptables -A synflood -p tcp -j REJECT --reject-with tcp-reset
iptables -A INPUT -p tcp -m state --state NEW -j synflood
iptables -A INPUT -p icmp --icmp-type echo-request -m limit --limit 1/s --limit-burst 5 -j ACCEPT
iptables -A INPUT -p icmp --icmp-type echo-request -j DROP
iptables -A INPUT -p tcp -m multiport --dport 80,22,8080,3306,5666,110,143,25,443 -j ACCEPT
测试:
端口扫描
nmap -P0 -sS 214.26.73.x


你可能感兴趣的:(防火墙,mail)