FTP Forwarding
Hi,
I've been trying to forward port 21 to an ftp server on another machine, IP address 10.0.0.199.
eth1 - external (connected to the net)
eth0 - internal
/sbin/iptables -A FORWARD -p tcp -i eth1 --dport 21 -j ACCEPT /sbin/iptables -A PREROUTING -t nat -p tcp -i eth1 --dport 21 -j DNAT --to 10.0.0.199:21
but can't get it to work..
any ideas ?
Thanks
Wasim
Quoted 8 lines · On Fri, 22 Nov 2002 10:08:16 -0000 Bantam <[email protected]> wrote:
Hi,
I've been trying to forward port 21 to an ftp server on another machine, IP address 10.0.0.199.
eth1 - external (connected to the net)
eth0 - internal
Quoted 8 lines
/sbin/iptables-A FORWARD -p tcp -i eth1 --dport 21 -j ACCEPT/sbin/iptables-A PREROUTING -t nat -p tcp -i eth1 --dport 21 -j DNAT --to 10.0.0.199:21but can't get it to work..
any ideas ?
FTP is a complex protocol .
http://www.freesoft.org/CIE/Topics/69.htm
Quoted 6 lines
Thanks
Wasim
Signature · 4 lines
Sheshka Aleksey Senior Security Administrator PGP key : http://pgp.dtype.org:11371/pks/lookup?op=get&search=0x0BE90515
Quoted 8 lines · On Fri, 22 Nov 2002 10:08:16 -0000 Bantam <[email protected]> wrote:
Hi,
I've been trying to forward port 21 to an ftp server on another machine, IP address 10.0.0.199.
eth1 - external (connected to the net)
eth0 - internal
Quoted 8 lines
/sbin/iptables-A FORWARD -p tcp -i eth1 --dport 21 -j ACCEPT/sbin/iptables-A PREROUTING -t nat -p tcp -i eth1 --dport 21 -j DNAT --to 10.0.0.199:21but can't get it to work..
any ideas ?
FTP is a complex protocol .
http://www.freesoft.org/CIE/Topics/69.htm
Quoted 6 lines
Thanks
Wasim
Signature · 4 lines
Sheshka Aleksey Senior Security Administrator PGP key : http://pgp.dtype.org:11371/pks/lookup?op=get&search=0x0BE90515
Wasim:
If you do an lsmod, does it show thatip_nat_ftp and ip_conntrack_ftp are loaded? They are required to make ftp work through nat. Also what Linux Distro and Iptables are you using?
Stu.........
-----Original Message-----
From: [email protected] [mailto:[email protected]]On Behalf Of Bantam
Sent: November 22, 2002 2:08 AM
To: netfilter
Subject: FTP Forwarding
Hi,
I've been trying to forward port 21 to an ftp server on another machine, IP address 10.0.0.199.
eth1 - external (connected to the net)
eth0 - internal
/sbin/iptables -A FORWARD -p tcp -i eth1 --dport 21 -j ACCEPT /sbin/iptables -A PREROUTING -t nat -p tcp -i eth1 --dport 21 -j DNAT --to 10.0.0.199:21
but can't get it to work..
any ideas ?
Thanks
Wasim
Hi,
neither ip_nat_ftp and ip_conntrack_ftp are loaded, how do i load these ?
I'm using redhat 8.
Regards,
Wasim
-----Original Message-----
From: [email protected] [mailto:[email protected]]On Behalf Of Stewart Thompson
Sent: 22 November 2002 10:32
To: Bantam; netfilter
Subject: RE: FTP Forwarding
Wasim:
If you do an lsmod, does it show thatip_nat_ftp and ip_conntrack_ftp are loaded? They are required to make ftp work through nat. Also what Linux Distro and Iptables are you using?
Stu.........
-----Original Message-----
From: [email protected] [mailto:[email protected]]On Behalf Of Bantam
Sent: November 22, 2002 2:08 AM
To: netfilter
Subject: FTP Forwarding
Hi,
I've been trying to forward port 21 to an ftp server on another machine, IP address 10.0.0.199.
eth1 - external (connected to the net)
eth0 - internal
/sbin/iptables -A FORWARD -p tcp -i eth1 --dport 21 -j ACCEPT /sbin/iptables -A PREROUTING -t nat -p tcp -i eth1 --dport 21 -j DNAT --to 10.0.0.199:21
but can't get it to work..
any ideas ?
Thanks
Wasim
Wasim:
Put the following lines at the beginning of your script /sbin/insmod ip_conntrack_ftp
/sbin/insmod ip_conntrack_ftp
That is the path on my system. Do a which insmod to
make sure that is right for your system. I am not running 8.0 on any of the systems I look after. Theoretically, the system should load them when they are all referenced. However, I specifically load all the ones I need in my firewall script. Also, see Rob's rule for related and established. Also, if you want people to be able to initiate FTP sessions from outside your network, you will also nee to allow new connections. Hope that helps.
Stu.............
-----Original Message-----
From: [email protected] [mailto:[email protected]]On Behalf Of Wasim Bashir
Sent: November 22, 2002 2:37 AM
To: stewart.thompson; 'Bantam'; 'netfilter'
Subject: RE: FTP Forwarding
Hi,
neither ip_nat_ftp and ip_conntrack_ftp are loaded, how do i load these ?
I'm using redhat 8.
Regards,
Wasim
-----Original Message-----
From: [email protected] [mailto:[email protected]]On Behalf Of Stewart Thompson
Sent: 22 November 2002 10:32
To: Bantam; netfilter
Subject: RE: FTP Forwarding
Wasim:
If you do an lsmod, does it show thatip_nat_ftp and ip_conntrack_ftp are loaded? They are required to make ftp work through nat. Also what Linux Distro and Iptables are you using?
Stu.........
-----Original Message-----
From: [email protected] [mailto:[email protected]]On Behalf Of Bantam
Sent: November 22, 2002 2:08 AM
To: netfilter
Subject: FTP Forwarding
Hi,
I've been trying to forward port 21 to an ftp server on another machine, IP address 10.0.0.199.
eth1 - external (connected to the net)
eth0 - internal
/sbin/iptables -A FORWARD -p tcp -i eth1 --dport 21 -j ACCEPT /sbin/iptables -A PREROUTING -t nat -p tcp -i eth1 --dport 21 -j DNAT --to 10.0.0.199:21
but can't get it to work..
any ideas ?
Thanks
Wasim
Hi,
Many thanks for your help, got it all working!!!
Thanks
Wasim
-----Original Message-----
From: [email protected] [mailto:[email protected]]On Behalf Of Stewart Thompson
Sent: 22 November 2002 11:09
To: wasim.bashir; 'Bantam'; 'netfilter'
Subject: RE: FTP Forwarding
Wasim:
Put the following lines at the beginning of your script /sbin/insmod ip_conntrack_ftp
/sbin/insmod ip_conntrack_ftp
That is the path on my system. Do a which insmod to
make sure that is right for your system. I am not running 8.0 on any of the systems I look after. Theoretically, the system should load them when they are all referenced. However, I specifically load all the ones I need in my firewall script. Also, see Rob's rule for related and established. Also, if you want people to be able to initiate FTP sessions from outside your network, you will also nee to allow new connections. Hope that helps.
Stu.............
-----Original Message-----
From: [email protected] [mailto:[email protected]]On Behalf Of Wasim Bashir
Sent: November 22, 2002 2:37 AM
To: stewart.thompson; 'Bantam'; 'netfilter'
Subject: RE: FTP Forwarding
Hi,
neither ip_nat_ftp and ip_conntrack_ftp are loaded, how do i load these ?
I'm using redhat 8.
Regards,
Wasim
-----Original Message-----
From: [email protected] [mailto:[email protected]]On Behalf Of Stewart Thompson
Sent: 22 November 2002 10:32
To: Bantam; netfilter
Subject: RE: FTP Forwarding
Wasim:
If you do an lsmod, does it show thatip_nat_ftp and ip_conntrack_ftp are loaded? They are required to make ftp work through nat. Also what Linux Distro and Iptables are you using?
Stu.........
-----Original Message-----
From: [email protected] [mailto:[email protected]]On Behalf Of Bantam
Sent: November 22, 2002 2:08 AM
To: netfilter
Subject: FTP Forwarding
Hi,
I've been trying to forward port 21 to an ftp server on another machine, IP address 10.0.0.199.
eth1 - external (connected to the net)
eth0 - internal
/sbin/iptables -A FORWARD -p tcp -i eth1 --dport 21 -j ACCEPT /sbin/iptables -A PREROUTING -t nat -p tcp -i eth1 --dport 21 -j DNAT --to 10.0.0.199:21
but can't get it to work..
any ideas ?
Thanks
Wasim
Quoted 4 lines
/sbin/iptables-A FORWARD -p tcp -i eth1 --dport 21 -j ACCEPT/sbin/iptables-A PREROUTING -t nat -p tcp -i eth1 --dport 21 -j DNAT --to
10.0.0.199:21
Do you also have something like :/sbin/iptables -A FORWARD -m state --state RELATED,ESTABLISHED -j ACCEPT
Rob
Hello,
Quoted 12 lines · Bantam
Hi,
I've been trying to forward port 21 to an ftp server on another machine, IP address 10.0.0.199.
eth1 - external (connected to the net)
eth0 - internal
/sbin/iptables-A FORWARD -p tcp -i eth1 --dport 21 -j ACCEPT/sbin/iptables-A PREROUTING -t nat -p tcp -i eth1 --dport 21 -j DNAT --to 10.0.0.199:21
Quoted 7 lines
but can't get it to work..
any ideas ?
Thanks
Wasim
I think you need to specify -o eth0 in the FORWARD table like this:
/sbin/iptables -A FORWARD -p tcp -i eth1 -o eth0 --dport 21 -j ACCEPT
You will also need:
/sbin/iptables -A FORWARD -p tcp -i eth0 -o eth1 --sport 21 -j ACCEPT
for packets comming from your ftp server.
Generally for FTP connections you will also need to forward port 20, the ftp data stream.
Is your 10.0.0.199 serving th Internet or is it only local network. If it is for the Internet, then you need SNAT to a real IP on the firewall.
I would suggest you to use IP connection tracking instead:
ipt=iptables
GW_IP=your firewall's IP on eth1 (a real IP)
### Enable ESTABLISHED,RELATED connections
$ipt -A FORWARD -i eth1 -o eth0 --match state --state ESTABLISHED,RELATED --jump ACCEPT
### Enable FTP data
$ipt -A FORWARD -i eth1 -o eth0 -d 10.0.0.199 --dport 20 -m state --state NEW -j ACCEPT
### Enable FTP
$ipt -A FORWARD -i eth1 -o eth0 -d 10.0.0.199 --dport 21 -m state --state NEW -j ACCEPT
### DNAT FTP data
$ipt -t nat -A PREROUTING -i eth1 -d $GW_IP --dport 20 -j DNAT --to-destination 10.0.0.199:20
### DNAT FTP
$ipt -t nat -A PREROUTING -i eth1 -d $GW_IP --dport 21 -j DNAT --to-destination 10.0.0.199:21
### SNAT
$ipt -t nat -A POSTROUTING -o eth1 -s 10.0.0.199 -j SNAT --to-source $GW_IP
Hope it helps.
Erdal Mutlu