Re: iptables, ftp and dnat?


You should try and keep this on list


On Fri, Dec 05, 2008 at 02:17:42PM -0700, Robert L. Harris wrote:
Hash: SHA1


I've updated my rules to this:
# # allow ftpd
/sbin/modprobe nf_conntrack_ftp
# General
iptables -I INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -A INPUT -p tcp --dport 21 -m state --state NEW -j ACCEPT
iptables -A FORWARD -p tcp --dport 21 -m state --state NEW -j ACCEPT
iptables -t nat -A PREROUTING -p tcp --dport 21 -j DNAT --to

I think I confused myself though, do I need the other rules I had for
port 20 or will the first INPUT rule
above cover that?

have a look here (quick google on
ftp & ports).

It shows you how the ports are used for ftp.

The ftp contrack module that you where loading previous should handle
the "related" ports and allow them through, what I am not sure about is
weather it will handle the dnat'ing of those port. But then again you
could specify passive ftp only

here is another link (again google).

My strength is in itables not ftp (which is the reason for googling :) )

Also anything to do with iptables and firewalls you should probably read
a tutorial on iptables

Thank you for your help, I've not done anything this complex with
iptables before.


Robert L. Harris | GPG Key ID: E344DA3B
@ x-hkp://
These are MY OPINIONS With Dreams To Be A King,
ALONE. I speak for First One Should Be A Man
no-one else. - Manowar

Version: GnuPG v1.4.8 (Darwin)


"Obviously, I pray every day there's less casualty."

- George W. Bush
Fort Hood, TX

Attachment: signature.asc
Description: Digital signature

Relevant Pages

  • Re: Understanding iptables FC4
    ... > possible that your machine is still blocking the ports, ... > because I am not an iptables expert. ... I personally never allow FTP on servers I manage as it is an insecure ...
  • Re: Newbie question about ports.
    ... Can you do a CVSup to update your ports via http? ... Cvsup does not support http, but neither does it use ftp (see man cvsup, ... openable through your firewall. ...
  • RE: FTP Server on SBS 2003
    ... When I access the ftp site ... In the properties the ftp is set to "all assigned ports" should this ... > You connect the SBS to a third party Router and forward port 21 to the SBS ... The network administrator of the server network can consult the ...
  • RE: Passive FTP
    ... Some FTP servers are able to set the passive ports he can use, ... Onderwerp: Passive FTP ... Dit E-mail bericht is slechts bestemd voor de persoon aan wie het is ...
  • Re: Ideas on solving the file transfer problem
    ... out of the range of easy solution for the vast majority of users? ... Port 21 may be the default port for FTP, ... Given the two channel nature of FTP, NAT is a bigger problem than ... Firewalls can be configured by the end-user to open the necessary ports. ...