Log in

Bekijk de volledige versie : Help in understanding FTP access from WAN



bibi-phoque
10-02-2009, 18:26
Hello,
this thing is driving me really crazy so I wanted to see if anybody could clear things up for me. First of all, I did get it working, but the way I did it is not logical.

I have the latest Oleg's firmware so I'm using vsftp.

My post-firewall is simple and used only to open specific ports (ftp, ssh, web server, etc..)

#!/bin/sh
# this opens the ssh port to internet! Be sure to have strong passwords!
iptables -I INPUT -m tcp -p tcp --dport 443 -j ACCEPT
iptables -I INPUT -m tcp -p tcp --dport 81 -j ACCEPT
iptables -I INPUT -m tcp -p tcp --dport 9091 -j ACCEPT
iptables -I INPUT -m tcp -p tcp --dport 21 -j ACCEPT
iptables -I INPUT -m tcp -p tcp --dport 80 -j ACCEPT
iptables -I INPUT -m tcp -p tcp --dport 51413 -j ACCEPT

I have followed Wengi's tutorial at the letter.

ssh works from wan, webserver works from wan but ftp is giving me trouble (FTP from LAN works no problem).

- First, without a virtual server defined in the GUI, I cannot connect.
- If I setup a virtual server (port forwarding) for 20:21 and direct to 21 on 192.168.1.1, the ftp client is able to connect but is unable to print the listing which then produce a timout error (both in passive and active mode using filezilla).
- If I setup a virtual server, but this time forwarding port 20 and 21 to my wl500 WAN IP, then I can connect no problem and transfer data.

Even though I got it working, I don't understand the logic behind it and I'm sure there is another way to achieve this.
I did a lot of research and played a bit with the post-firewall, adding PREROUTING rule like this one (and removing my virtual server):
iptables -t nat -A PREROUTING -i vlan1 -p tcp --dport 21 -j DNAT --to-destination $4:21

But it doesn't work.

Can somebody tell me if what I'm doing is correct? Anybody could share settings (post-firewall, virtual server, ftp client settings) of a working FTP from WAN?

Thanks in advance,
Yann

Tamadite
10-02-2009, 20:18
Have you tried with ftp passive mode from the client?

bibi-phoque
11-02-2009, 10:48
Yes I did. Both active and passive mode from the client have the same problem.
It is something to do with something I have installed on the wl500gp. When i first flashed it with Oleg's FW, ftp was working fine from WAN, no need to forward anything actually. I didn't have a post-firewall at the time either.
Now that I have all my services running I experience this issue. Funny enough, if you have the official ASUS firmware, forwarding to your external WAN IP is the only way to get the ftp server accessable from WAN.

lyxes
11-02-2009, 17:06
What happened to me was that when I activated NAT Setting -Virtual DMZ and gave the exposed station ip adress then my ftp server was reachable only from Lan . Maybe this help maybe not :) please tell me if does.

bibi-phoque
11-02-2009, 17:24
Well, thanks for the tips, it worked. I removed the DMZ (I had it for the PS3), removed the virtual server on port 21 and I can connect just fine from work.
I don't think I need the DMZ anymore anyway, with the upnp enabled on the PS3 and router.

Thanks!
Yann