ftp forward to internal machine
Hello everyone,
I have a firewall configured to forward port 80 traffic to an internal machine. I was wondering if the same thing is possible with ftp traffic. The rules I am using are as follows:
iptables -A PREROUTING -t nat -i EXTINF -p tcp -d 1.2.3.4 --dport 21 -j DNAT --to 192.168.2.5:21
iptables -A FORWARD -i EXTINF -p tcp -d 192.168.2.5 --dport 21 ACCEPT
iptables -A FORWARD -i EXTINF -o INTIF -p tcp --dport 21 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
iptables -t nat -A PREROUTING -i EXTINF -p tcp --dport 21 -d 1.2.3.4 -j DNAT --to-destination 192.168.2.5:21
iptables -t nat -A POSTROUTING -o INTIF -p tcp --dport 21 -d 192.168.2.5 -j SNAT --to-source 192.168.2.254
I can connect to the ftp server but then I cannot establish a data channel between the client and the server.
Any help would be appreciated. If you want to see output of anything I can include it.
Thanks
Travis Crook
Visions Beyond
Quoted 13 lines · Travis Crook
Hello everyone,
I have a firewall configured to forward port 80 traffic to an internal
machine. I was wondering if the same thing is possible with ftp traffic. The rules I am using are as follows:iptables -A PREROUTING -t nat -i EXTINF -p tcp -d 1.2.3.4 --dport 21 -j DNAT --to 192.168.2.5:21
iptables -A FORWARD -i EXTINF -p tcp -d 192.168.2.5 --dport 21 ACCEPT
iptables -A FORWARD -i EXTINF -o INTIF -p tcp --dport 21 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
Quoted 8 lines
iptables -t nat -A PREROUTING -i EXTINF -p tcp --dport 21 -d 1.2.3.4 -j DNAT --to-destination 192.168.2.5:21
iptables -t nat -A POSTROUTING -o INTIF -p tcp --dport 21 -d 192.168.2.5 -j SNAT --to-source 192.168.2.254
I can connect to the ftp server but then I cannot establish a data channel between the client and the server.
You haven't included port 20.
Ftp uses port 21 for the control connection, and port 20 for the data
connection. You must translate and forward both of them for ftp to work,
and even then in these circumstances I think you'll only be able to use passive mode.
Antony
Quoted 4 lines
You haven't included port 20.
I included port 20 and it seems to work fine now. Thanks!! Is is possible to send it over a different port (i.e. 21345 instead of 21, and 20345 instead of 20)?
Quoted 9 lines
Ftp uses port 21 for the control connection, and port 20 for the data
connection. You must translate and forward both of them for ftp to work,
and even then in these circumstances I think you'll only be able to use passive mode.Antony
Quoted 5 lines · Travis Crook
Quoted 1 line
You haven't included port 20.
I included port 20 and it seems to work fine now. Thanks!! Is is possible to send it over a different port (i.e. 21345 instead of 21, and 20345 instead of 20)?
You'd have to nobble the source code of a client or a server (depending on which one you want to think the other end is running on a weird port number) to get this to work.
You can't just "ftp ftp.microsoft.com:12345" like you can with http....
Antony.
Thanks a bunch!! This list is great!
I think I can get it from here.
Travis Crook
Visions Beyond
----- Original Message -----
From: "Antony Stone" <[email protected]>
To: <[email protected]>
Sent: Tuesday, June 04, 2002 4:26 PM
Subject: Re: ftp forward to internal machine
Quoted 5 lines · Travis Crook
Quoted 4 lines
Quoted 2 lines
You haven't included port 20.
I included port 20 and it seems to work fine now. Thanks!! Is is
possible
Quoted 5 lines
Quoted 2 lines
to send it over a different port (i.e. 21345 instead of 21, and 20345 instead of 20)?
You'd have to nobble the source code of a client or a server (depending on which one you want to think the other end is running on a weird port
number)
Quoted 7 lines
to get this to work.
You can't just "ftp ftp.microsoft.com:12345" like you can with http....
Antony.