#!/bin/sh
IPTABLES=/usr/sbin/iptables
/sbin/modprobe ip_conntrack
/sbin/modprobe ip_conntrack_ftp
#reset
$IPTABLES -F
$IPTABLES -X
$IPTABLES -Z
$IPTABLES -P INPUT DROP
$IPTABLES -P FORWARD DROP
$IPTABLES -POUTPUT ACCEPT
#bestehende verbindungen
$IPTABLES -I INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
#interne verbindungen
$IPTABLES -A INPUT -i lo -j ACCEPT
#DNS
#$IPTABLES -A INPUT -m state --state NEW -p udp --dport 53 -j ACCEPT
#$IPTABLES -A INPUT -m state --state NEW -p tcp --dport 53 -j ACCEPT
#HTTP EMAIL
$IPTABLES -A INPUT -m state --state NEW -p tcp --dport 80 -j ACCEPT
$IPTABLES -A INPUT -m state --state NEW -p tcp --dport 143 -j ACCEPT
$IPTABLES -A INPUT -m state --state NEW -p tcp --dport 25 -j ACCEPT
$IPTABLES -A INPUT -m state --state NEW -p tcp --dport 110 -j ACCEPT
$IPTABLES -A INPUT -m state --state NEW -p tcp --dport 443 -j ACCEPT
$IPTABLES -A INPUT -m state --state NEW -p tcp --dport 22 -j ACCEPT
$IPTABLES -A INPUT -m state --state NEW -p tcp --dport 21 -j ACCEPT
$IPTABLES -A INPUT -m state --state NEW -p tcp --dport 10024 -j ACCEPT
$IPTABLES -A INPUT -m state --state NEW -p tcp --dport 10024 -j ACCEPT
#portscann blocken
$IPTABLES -A INPUT -m state --state NEW -p tcp --tcp-flags ALL ALL -j DROP
$IPTABLES -A INPUT -m state --state NEW -p tcp --tcp-flags ALL NONE -j DROP
#ping überschwemmung blocken
$IPTABLES -A INPUT -m state --state NEW -m limit -p ICMP -s 0/0 --limit 3/s --limit-burst 8 --icmp-type 8 -j ACCEPT
$IPTABLES -A INPUT -m limit -p ICMP -s 0/0 --limit 3/s --limit-burst 8 --icmp-type 11 -j ACCEPT
#1paket pro sek (max) loggen
$IPTABLES -A INPUT -j LOG -m limit --limit 1/s --limit-burst 8
#alles restliche blocken und fehlermeldung schicken
$IPTABLES -A INPUT -p TCP -j REJECT --reject-with tcp-reset
$IPTABLES -A INPUT -m state --state NEW -p tcp --tcp-flags ALL ALL -j DROP
$IPTABLES -A INPUT -j REJECT
„If there’s more than one possible outcome of a job or task, and one
of those outcomes will result in disaster or an undesirable consequence,
then somebody will do it that way.“ -- Edward Aloysius Murphy Jr.