iptables ohne Effekt

Rund um die Sicherheit des Systems und die Applikationen
Post Reply
sonnenrot
Posts: 63
Joined: 2007-10-14 21:41
 

iptables ohne Effekt

Post by sonnenrot »

Hallo,

ich habe heute morgen meine Iptables Regeln ausprobiert und Sie waren auf meinem neuen System ohne Wirkung. Beispielsweise war das Pingen des Servers immer noch möglich.

Code: Select all

#!/bin/sh
echo "initialisiere Firewall"

# Firewallregeln löschen
iptables -F
iptables -X
iptables -P INPUT DROP
iptables -P OUTPUT DROP
iptables -P FORWARD DROP
iptables -Z 
#eigene Chains erstellen
iptables -N MYDROP
iptables -N MYACCEPT

#Loopback-Kommunikation
iptables -A INPUT -i venet0 -j ACCEPT
iptables -A OUTPUT -o venet0 -j ACCEPT

#Stateful Inspection
iptables -A INPUT -m state --state ESTABLISHED -j ACCEPT
iptables -A INPUT -m state --state INVALID -j MYDROP
iptables -A OUTPUT -m state --state ESTABLISHED -j ACCEPT

#eigene Chains MYDROP und MYACCEPT konfigurieren
iptables -A MYDROP -j LOG --log-prefix "FW-DROP: "
iptables -A MYDROP -j DROP
iptables -A MYACCEPT -j LOG --log-prefix "FW-ACCEPT: "
iptables -A MYACCEPT -j ACCEPT

#SSH
iptables -A INPUT -p tcp --dport 32421 -j MYACCEPT

#www
iptables -A INPUT -p tcp --dport  80 -j MYACCEPT
iptables -A OUTPUT -p tcp --dport 80 -j MYACCEPT

echo "iptables konfiguriert"
Bin das Script 3 mal durchgegangen und habe nichts gefunden. Seht ihr etwas, könntet ihr mir bitte bei der Fehlersuche helfen?

Gruß

sonnenrot
toberkel
Posts: 86
Joined: 2004-07-16 17:22
Location: Hamburg
Contact:
 

Re: iptables ohne Effekt

Post by toberkel »

Moin.

Es liegt an diesen Regeln:

Code: Select all

iptables -A INPUT -i venet0 -j ACCEPT
iptables -A OUTPUT -o venet0 -j ACCEPT 
Wenn ich das richtig verstehe, hast du einen Vserver und venet0 ist quasi dein eth0, richtig? Wenn ja, dann ist das keine Loopback Kommunikation. Damit erlaubst du wieder alles. Wenn du nur die Loopback Kommunikation willst, dann änder doch mal

Code: Select all

-i venet0
in

Code: Select all

-i lo
.

Aber vorsicht! So wirst du dich erstmal aussperren. Deine SSH-Allow Regel greift IMHO nicht. Änder doch bitte

Code: Select all

iptables -A INPUT -m state --state ESTABLISHED -j ACCEPT
in folgendes

Code: Select all

iptables -A INPUT -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
Damit lässt du auch neue Verbindungen zu. Den Rest kriegste dann hin ;)

MfG,

toberkel
sonnenrot
Posts: 63
Joined: 2007-10-14 21:41
 

Re: iptables ohne Effekt

Post by sonnenrot »

@toberkel danke.
-i lo
funktioniert - was ich bloss nicht ganz verstehe, mein vorheriges Script, welches mit diesem Identisch war funktionierte venet0

Code: Select all

venet0    Protokoll:UNSPEC  Hardware Adresse 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  
inet Adresse:127.0.0.1  P-z-P:127.0.0.1  Bcast:0.0.0.0 Maske:255.255.255.255
venet0:0 hat hierbei die öffentliche IP
iptables -A INPUT -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
es funktioniert auch ohne die Optionen NEW und RELATED.

Gruß
sonnenrot
toberkel
Posts: 86
Joined: 2004-07-16 17:22
Location: Hamburg
Contact:
 

Re: iptables ohne Effekt

Post by toberkel »

Hmm. Merkwürdig. Bei mir gings nicht ohne NEW... Naja, habs ja nur kurz getestet...

MfG,

toberkel
sonnenrot
Posts: 63
Joined: 2007-10-14 21:41
 

Re: iptables ohne Effekt

Post by sonnenrot »

NEW sollte der Beschreibung nach ausschließlich, dann Verwendung finden, wenn der Server selbst eine Verbindung initiert. Dies sollte bei einer eingehenden Verbindung nicht der Fall sein, oder?
toberkel
Posts: 86
Joined: 2004-07-16 17:22
Location: Hamburg
Contact:
 

Re: iptables ohne Effekt

Post by toberkel »

Auszug aus man iptables
NEW meaning that the packet has started a new connection
Ich bin der Meinung es gilt auf für Pakete die per INPUT an deinem Server ankommen.

MfG,

toberkel
Roger Wilco
Posts: 5923
Joined: 2004-05-23 12:53
 

Re: iptables ohne Effekt

Post by Roger Wilco »

sonnenrot
Posts: 63
Joined: 2007-10-14 21:41
 

Re: iptables ohne Effekt

Post by sonnenrot »

Dank dir -

iptables = schön zu haben
iptables = bringen etwas gegen automatisches abklopfen von draußen
iptables = nützen nichts gegen einen gezielten Angriff
Post Reply