LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 08-18-2011, 07:24 AM   #1
lithos
Senior Member
 
Registered: Jan 2010
Location: SI : 45.9531, 15.4894
Distribution: CentOS, OpenNA/Trustix, testing desktop openSuse 12.1 /Cinnamon/KDE4.8
Posts: 1,144

Rep: Reputation: 217Reputation: 217Reputation: 217
I'm lost in IPTABLES PREROUTING, forwarding to another destination port range


Hi

I'm running Linux RHEL4 based server with IPTABLES routing/ forwarding a port 55555 (let's say it's 55555) to another IP port 1234 with:
Code:
iptables -t nat -A PREROUTING -p tcp --dport 55555 -j DNAT --to-destination 1.222.333.444:21
iptables -t nat -A POSTROUTING -j MASQUERADE
and so far so good, but the destination IP has a FTP (vsftpd) service running on that port with PASSIVE connections, so I am not able to establish the LIST of directories on the server.
Code:
Retrieving directory listing...
Command:	PWD
Response:	257 "/"
Command:	TYPE I
Response:	200 Switching to Binary mode.
Command:	PASV
Response:	227 Entering Passive Mode (1,222,333,444,203,192)
Command:	LIST

and here it hangs until disconnected from server
How to forward the Passive ports also to that server? Maybe I should forward also the destination port 20 as it's used in Vsftpd for transfer port ? How ?

Kindly asking for help (not man iptables, because I lost the track of trying)



My best regards.

Last edited by lithos; 08-18-2011 at 07:29 AM.
 
Old 08-18-2011, 11:41 AM   #2
smallpond
Senior Member
 
Registered: Feb 2011
Location: Massachusetts, USA
Distribution: Fedora
Posts: 4,140

Rep: Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263
iptables has a special kernel module for FTP NAT.
Code:
modprobe ip_conntrack_ftp
modprobe ip_nat_ftp
Also you need to open ports 20, 21 and the passive ports in iptables:
See this thread:
http://www.linuxquestions.org/questi...d-port-891483/
 
Old 08-18-2011, 02:21 PM   #3
lithos
Senior Member
 
Registered: Jan 2010
Location: SI : 45.9531, 15.4894
Distribution: CentOS, OpenNA/Trustix, testing desktop openSuse 12.1 /Cinnamon/KDE4.8
Posts: 1,144

Original Poster
Rep: Reputation: 217Reputation: 217Reputation: 217
I have
Code:
root@~#>modprobe -c | grep ftp
alias symbol:ip_nat_tftp_hook ip_conntrack_tftp
alias symbol:ip_nat_ftp_hook ip_conntrack_ftp
so I assume that IPTABLES FTP NAT has it.

Also passive ports are opened on the 'destination' server 1,222,333,444 (otherwise I could not connect to it directly)
so the problem is forwarding from the RHEL4 server port 55555 to destination 1,222,333,444 other passive ports.

Do I have forward the passive ports for 1.222.333.444 too, somehow ?
 
Old 08-18-2011, 08:18 PM   #4
smallpond
Senior Member
 
Registered: Feb 2011
Location: Massachusetts, USA
Distribution: Fedora
Posts: 4,140

Rep: Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263
Quote:
Originally Posted by lithos View Post
I have
Code:
root@~#>modprobe -c | grep ftp
alias symbol:ip_nat_tftp_hook ip_conntrack_tftp
alias symbol:ip_nat_ftp_hook ip_conntrack_ftp
so I assume that IPTABLES FTP NAT has it.

Also passive ports are opened on the 'destination' server 1,222,333,444 (otherwise I could not connect to it directly)
so the problem is forwarding from the RHEL4 server port 55555 to destination 1,222,333,444 other passive ports.

Do I have forward the passive ports for 1.222.333.444 too, somehow ?
You either need to forward the passive ports in iptables, or disable passive mode on the server.
That might be simpler if you don't need more than one simultaneous connection.
 
Old 08-19-2011, 05:01 AM   #5
lithos
Senior Member
 
Registered: Jan 2010
Location: SI : 45.9531, 15.4894
Distribution: CentOS, OpenNA/Trustix, testing desktop openSuse 12.1 /Cinnamon/KDE4.8
Posts: 1,144

Original Poster
Rep: Reputation: 217Reputation: 217Reputation: 217
Quote:
need to forward the passive ports in iptables
I'd like to ask if one could give me an example how.

Quote:
or disable passive mode on the server.
not really an option as it's almost never only 1 connection (but many from allowed IP in our company)
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Prerouting, port forwarding SashaBoy Linux - Networking 9 07-25-2010 06:42 AM
[SOLVED] IPTables port forwarding using prerouting not working blackman890 Linux - Networking 3 02-19-2010 02:33 PM
udp port forwarding to ip range oddo Linux - Networking 0 10-04-2004 07:09 AM
IPTABLES --to-destination muliple ip:port hawk4eye Linux - Networking 4 02-07-2003 04:59 AM
Port Range Forwarding htimst Linux - Networking 1 07-14-2002 12:31 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 10:22 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration