PDA

Archiv verlassen und diese Seite im Standarddesign anzeigen : iptables und ftp-server



Fir3fly
20.05.02, 20:14
Hi, nachdem ich nun einiges an zeit damit verbracht habe muß ich doch mal um expertenrat bitten. Mein Firewallscript mit iptables v1.2.3 auf Kernel 2.4.7-10 (Redhat 7.2) macht mir schwierigkeiten. Ich habe manchmal einen kleinen ftp server laufen und will den zugriff von außen natürlich auch ermöglichen. Im aktiven modus scheint auch alles zu klappen, allerdings verweigert die Firewall den passiven mode. Man kann sich normal einloggen, aber die dateiliste lehnt der server kategorisch ab (im aktiven modus gehts)



ftp> ls
227 Entering Passive Mode (217,80,78,51,128,96)
ftp: connect: Connection refused


ich hab da was gelesen, was ich leider nicht in die tat umsetzten kann (bin vermutlich zu dämlich):



The initial connection comes from a high-numbered port on the client side to the FTP control port, 21. This is going to be allowed through most firewalls. But the problem is the reply. When you send an FTP command (ls, get, put, etc.), that opens a whole separate TCP connection from the server to the client. This causes a problem -- firewalls may block THAT connection.


FTP Client -------------|----|-------------> FTP server
10.1.1.10 | fw | 10.1.1.4
port 41327 | * |------------- port 20

Fortunately for us, iptables allows us to track the state of an FTP connection and specify rules for it with the --state flag. So you can permit packets that are part of an already established session with --state ESTABLISHED, or packets that are part of a new session based on an old one (as in the case of active FTP) with --state RELATED.



mein firewall script (der ftp teil)

# ftp
$IPTABLES -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
$IPTABLES -A INPUT -p tcp --dport 20 -j ACCEPT
$IPTABLES -A INPUT -p tcp --dport 21 -j ACCEPT

sieht dann im iptables -L so aus

ACCEPT tcp -- anywhere anywhere tcp dpt:glftp-data
ACCEPT tcp -- anywhere anywhere tcp dpt:glftpd

Wo is der Harken??

Ich bin dankbar für jeden vorschlag

Fir3fly

Tommy_20
21.05.02, 08:26
Für Passiv-FTP musst du erstmal Ports definieren, die in diesem Modus verwendet werden (ein paar highports - werden bei proftpd direkt in der conf eingetragen).

Diese Ports müssen dann natürlich auch offen sein auf der Firewall.