Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game. |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
08-18-2011, 07:24 AM
|
#1
|
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
|
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.
|
|
|
08-18-2011, 11:41 AM
|
#2
|
Senior Member
Registered: Feb 2011
Location: Massachusetts, USA
Distribution: Fedora
Posts: 4,210
|
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/
|
|
|
08-18-2011, 02:21 PM
|
#3
|
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
|
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 ?
|
|
|
08-18-2011, 08:18 PM
|
#4
|
Senior Member
Registered: Feb 2011
Location: Massachusetts, USA
Distribution: Fedora
Posts: 4,210
|
Quote:
Originally Posted by lithos
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.
|
|
|
08-19-2011, 05:01 AM
|
#5
|
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
|
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)
|
|
|
All times are GMT -5. The time now is 04:34 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|