>Korrigiere: drei.  Erstmal Danke für die Skripte.  Was mir auffällt
>ist, dass so gut wie keine Kommentare dabei sind.  Oder Verweise auf
>die Policy (Meine ist: Outgoing ist alles erlaubt, eingehend das, was
>ich meine zu brauchen - http, ssh, talk und so).

Also dann nochmal als iptables und mit "Kommentar"
#!/bin/sh

# Ein paar "Abkuerzungen"
IPTABLES=/usr/sbin/iptables
localnet="192.168.0.0/24"
firewallhost="192.168.0.1/32"
Any="0.0.0.0/0"
localhost="127.0.0.1/32"
tkaefer_dyndns_org="192.168.0.1/32"

# Set the dafults
# INPUT und FORWARD auf ACCEPT setzen
# FORWARD auf die LOG-Chains setzen
$IPTABLES -P INPUT ACCEPT
$IPTABLES -P FORWARD DUMP
$IPTABLES -P OUTPUT ACCEPT
# Alle alten Regeln loeschen
$IPTABLES -F
$IPTABLES -t nat -F
# Alle benutzerdefinierten Chains loeschen
$IPTABLES -X
# Benutzerdefinierte Chains erstellen
# PPPIN:   Alles was auf ppp0 reinkommt
# SPOOF: Spoof-Protection, nicht dass sich jemnad fuer etwas ausgibt was er 
nicht ist!
# DUMP:   Alles "Angriffe" werden geloggt
$IPTABLES -N PPPIN
$IPTABLES -N SPOOF
$IPTABLES -N DUMP

# Set the masquerading stuff
# Alles was nicht zum lokalen Netz gehoert wird maskiert
$IPTABLES -A POSTROUTING -t nat -s $localnet -d '!' $localnet -j MASQUERADE

# Log the blocked packages with fwmon
# alles geblockten Pakete werden geloggt   (mit fwmon)
$IPTABLES -A DUMP  -o 4096
$IPTABLES -A DUMP  -j DROP

# Anti spoof protection
# Damit keiner von aussen mit einer lokalen Netzwerkadresse
# auf das LAN zugreifen kann
$IPTABLES -A SPOOF -i lo -s 192.168.0.1/32 -d 192.168.0.1/32  -j ACCEPT
$IPTABLES -A SPOOF -i lo -s 192.168.0.10/32 -d 192.168.0.10/32  -j ACCEPT
$IPTABLES -A SPOOF -i 'eth0:0' -s '!' $localnet -j DUMP
$IPTABLES -A SPOOF -i '!' 'eth0:0' -s $localnet -j DUMP
$IPTABLES -A SPOOF -s $Any -d $Any -j ACCEPT

# INPUT rules
# Alles was reinkommt wird gefiltert
# wenn es nicht aus dem lokalen Netz aber dennoch
# mit einer lokalen Adresse kommt geht es gleich auf die
# Spoofchain
$IPTABLES -A INPUT -i eth0 -s '!' $localnet -j SPOOF
$IPTABLES -A INPUT -i '!' eth0 -s $localnet -j SPOOF
$IPTABLES -A INPUT -i '!' lo -s $localhost -j DUMP
# Meine T-DSL Netzwerkkarte, von dort sollte keiner reinkommen!
$IPTABLES -A INPUT -i eth1 -j DUMP
# Jetzt erlaube ich lokalen Adressen der zugriff auf das LAN
# und den Server
$IPTABLES -A INPUT -s $localhost -d $localhost -i lo -j ACCEPT
$IPTABLES -A INPUT -s $localnet -d $localnet -i lo -j ACCEPT
$IPTABLES -A INPUT -s $localnet -d $localnet -i eth0 -j ACCEPT
$IPTABLES -A INPUT -s $localnet -d $localnet -i eth0:0 -j ACCEPT
# Alles was auf ppp0 reinkommt wird gefiltert
$IPTABLES -A INPUT -s $Any -d $Any -i ppp0 -j PPPIN

# FORWARD rules
$IPTABLES -A FORWARD -s $localnet -d $localnet -j ACCEPT
$IPTABLES -A FORWARD -s $localnet -d $localhost -j ACCEPT

# PPPIN rules
# MS-SQl rausfiltern
$IPTABLES -A PPPIN -p tcp --destination-port ms-sql-s -j DUMP
$IPTABLES -A PPPIN -p udp --destination-port ms-sql-s -j DUMP
# NFS rausfiltern
$IPTABLES -A PPPIN -p tcp --destination-port nfs -j DUMP
$IPTABLES -A PPPIN -p udp --destination-port nfs -j DUMP
# Trojaner rausfiltern
$IPTABLES -A PPPIN -p tcp --destination-port 5432 -j DUMP
$IPTABLES -A PPPIN -p udp --destination-port 5432 -j DUMP
# Windows-Freigabe (SMB) rausfiltern
$IPTABLES -A PPPIN -p tcp --destination-port 137:139 -j DUMP
$IPTABLES -A PPPIN -p udp --destination-port 137:139 -j DUMP
# Trojaner rausfiltern
$IPTABLES -A PPPIN -p tcp --destination-port 5999:6003 -j DUMP
$IPTABLES -A PPPIN -p udp --destination-port 5999:6003 -j DUMP
$IPTABLES -A PPPIN -p tcp --destination-port 31337 -j DUMP
$IPTABLES -A PPPIN -p udp --destination-port 31337 -j DUMP
$IPTABLES -A PPPIN -p tcp --destination-port 12345:12346 -j DUMP
$IPTABLES -A PPPIN -p udp --destination-port 12345:12346 -j DUMP
# Timer-Server rausfiltern
$IPTABLES -A PPPIN -p tcp --destination-port 37 -j DUMP
$IPTABLES -A PPPIN -p udp --destination-port 37 -j DUMP
# sunrpc rausfiltern
$IPTABLES -A PPPIN -p tcp --destination-port 111 -j DUMP
$IPTABLES -A PPPIN -p udp --destination-port 111 -j DUMP
# printer rausfiltern
$IPTABLES -A PPPIN -p tcp --destination-port 515 -j DUMP
$IPTABLES -A PPPIN -p udp --destination-port 515 -j DUMP
# Swat rausfiltern
$IPTABLES -A PPPIN -p tcp --destination-port 901 -j DUMP
$IPTABLES -A PPPIN -p udp --destination-port 901 -j DUMP
# SQUID rausfiltern
$IPTABLES -A PPPIN -p tcp --destination-port 3128 -j DUMP
$IPTABLES -A PPPIN -p udp --destination-port 3128 -j DUMP
# ident erlauben
$IPTABLES -A PPPIN -p tcp --destination-port ident -j ACCEPT
# xdmcp erlauben
$IPTABLES -A PPPIN -p tcp --destination-port 177 -j ACCEPT
$IPTABLES -A PPPIN -p udp --destination-port 177 -j ACCEPT
# 1023:65535 erlauben
$IPTABLES -A PPPIN -p tcp --destination-port 1023:65535 -j ACCEPT
$IPTABLES -A PPPIN -p udp --destination-port 1023:65535 -j ACCEPT
# alle icmp-Pakete erlauben
$IPTABLES -A PPPIN -p icmp -s $Any -d $Any -j ACCEPT
# SMTP erlauben
$IPTABLES -A PPPIN -p tcp --destination-port smtp -j ACCEPT
$IPTABLES -A PPPIN -p udp --destination-port smtp -j ACCEPT
# SSH erlauben
$IPTABLES -A PPPIN -p tcp --destination-port ssh -j ACCEPT
$IPTABLES -A PPPIN -p udp --destination-port ssh -j ACCEPT
# HTTP erlauben
$IPTABLES -A PPPIN -p tcp --destination-port http -j ACCEPT
$IPTABLES -A PPPIN -p udp --destination-port http -j ACCEPT
# FTP erlauben
$IPTABLES -A PPPIN -p tcp --destination-port ftp -j ACCEPT
$IPTABLES -A PPPIN -p tcp --destination-port ftp-data -j ACCEPT
$IPTABLES -A PPPIN -p udp --destination-port ftp-data -j ACCEPT
# POP3 erlauben
$IPTABLES -A PPPIN -p tcp --destination-port pop3 -j ACCEPT
$IPTABLES -A PPPIN -p udp --destination-port pop3 -j ACCEPT
$IPTABLES -A PPPIN -p tcp --destination-port pop3s -j ACCEPT
$IPTABLES -A PPPIN -p udp --destination-port pop3s -j ACCEPT
# Alles andere verbieten (falls ich noch etwas vergessen habe)
$IPTABLES -A PPPIN -s $Any -d $Any -j DUMP


Und wie sieht das aus?
Kann man nachvollziehen was ich da mache?
Gruss
Tobi

----------------------------------------------------------------------------
PUG - Penguin User Group Wiesbaden - http://www.pug.org

Antwort per Email an