#!/bin/bash
IPTABLES="/sbin/iptables"
WLANDEV="eth1"
# Verwerfe erstmal alles, indem
# die Default-Policy auf REJECT gesetzt wird
$IPTABLES -P INPUT REJECT
$IPTABLES -P OUTPUT REJECT
$IPTABLES -P FORWARD REJECT
$IPTABLES -t nat -F
$IPTABLES -A OUTPUT -m state --state NEW -j ACCEPT
$IPTABLES -A OUTPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
$IPTABLES -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
#!/bin/bash
IPTABLES="/sbin/iptables"
WLANDEV="eth1"
# Verwerfe erstmal alles
$IPTABLES -P INPUT DROP
$IPTABLES -P OUTPUT DROP
$IPTABLES -P FORWARD DROP
#Die Regeln alle Löschen
$IPTABLES -F INPUT
$IPTABLES -F OUTPUT
$IPTABLES -F FORWARD
#alle ausgehende Verbindungen, neue, bestehende, antworten, zulassen
$IPTABLES -A OUTPUT -m state --state NEW, ESTABLISHED,RELATED -j ACCEPT
#Fehlermeldungen und Antwortpakete zulassen
$IPTABLES -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
#Erlaube SSH-Verbindungen von außen
$IPTABLES -A INPUT -p tcp --dport 22 -m state --state NEW -j ACCEPT
#Erlaube FTP-Verbindungen von außen
$IPTABLES -A INPUT -p tcp --dport 20 -m state --state NEW -j ACCEPT
# Regelketten leeren
iptables -F
iptables -F -t nat
iptables -X
#----------------------------------------------------------------------------
# INPUT-Regeln erstellen
#Akzeptiere etablierte und verwandte Verbindungen
iptables -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
#Akzeptierte Kommunikation ber die Loopback-Schnittstelle
iptables -A INPUT -s 127.0.0.0/255.255.255.0 -j ACCEPT
#Akzeptiere Pakete aus dem lokalen Netz
iptables -A INPUT -s 192.168.0.0/255.255.255.0 -j ACCEPT
# http-Antworten von berall erlauben
iptables -A INPUT -p tcp --sport 80 --dport 1024: -j ACCEPT
# eigenen http-Server freigeben
iptables -A INPUT -p tcp --sport 1024: --dport 80 -j ACCEPT
#Aufbau der Verbindung
iptables -A INPUT -p tcp --dport 1024: --sport 21 ! --syn -j ACCEPT
#Aktives FTP
iptables -A INPUT -p tcp --dport 1024: --sport 20 -j ACCEPT
#Passives FTP
iptables -A INPUT -p tcp --dport 1024: --sport 1024: ! --syn -j ACCEPT
#ssh freigabe fr TCP und UDP
iptables -A INPUT -p tcp --dport 22 -j ACCEPT
iptables -A INPUT -p tcp --sport 22 -j ACCEPT
#iptables -A INPUT -p udp --dport 22 -j ACCEPT
#iptables -A INPUT -p udp --sport 22 -j ACCEPT
#DNS Freigabe
iptables -A INPUT -p udp -s 192.168.0.200 --dport 53 --sport 1024:65335 -j ACCEPT
iptables -A INPUT -p tcp -s 192.168.0.200 --sport 53 --dport 1024:65335 -j ACCEPT
#Default-Policy �dern
iptables -P INPUT DROP
#---------------------------------------------------------------------------------------------
# OUTPUT-Regeln erstellen
#Akzeptiere etablierte und verwandte Verbindungen
iptables -A OUTPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
#Akzeptierte Kommunikation ber die Loopback-Schnittstelle
iptables -A OUTPUT -d 127.0.0.0/255.255.255.0 -j ACCEPT
#Akzeptiere alle Pakete aus dem lokalen Netz
iptables -A OUTPUT -d 192.168.0.0/255.255.255.0 -j ACCEPT
# http nach berall erlauben
iptables -A OUTPUT -p tcp --sport 1024: --dport 80 -j ACCEPT
# eigenen http-Server feigeben
iptables -A OUTPUT -p tcp --sport 80 --dport 1024: -j ACCEPT
#Kontrollverbindung
iptables -A OUTPUT -p tcp --sport 1024: --dport 21 -j ACCEPT
#Aktives FTP
iptables -A OUTPUT -p tcp --sport 1024: --dport 20 -j ACCEPT
#Passices FTP
iptables -A OUTPUT -p tcp --sport 1024: --dport 1024 -j ACCEPT
#ssh freigabe fr tcp und udp
iptables -A OUTPUT -p tcp --dport 22 -j ACCEPT
iptables -A OUTPUT -p tcp --sport 22 -j ACCEPT
#iptables -A OUTPUT -p udp --dport 22 -j ACCEPT
#iptables -A OUTPUT -p udp --sport 22 -j ACCEPT
#DNS Freigabe
iptables -A OUTPUT -p udp --sport 53 --dport 1024:65335 -j ACCEPT
iptables -A OUTPUT -p tcp --dport 53 --sport 1024:65335 -j ACCEPT
#Default-Policy �dern
iptables -P OUTPUT DROP
# nicht behandelte Ketten droppen
iptables -P FORWARD DROP
#----------------------------------------------------------------------------------