Setting external IP on Pure-FTPd (29)
Cannot FTP back to your DNS-323? Directory listing fail on the Pure-FTPd? Need to do passive (pasv) ftp on the Pure-FTPd on the DNS-323/DNS-343?
I face some problems while trying to ftp to my DNS-323/DNS-343 behind the router. Sometimes it works and sometimes it doesn’t. I normally have problem when I am trying to ftp from a location that is behind NAT as well.
Wrote up a shell script for starting the Pure-FTPd correctly on DNS-323 and DNS-343. It is meant for fonz’s fun_plug 0.5 and firmware on the DNS-323 should be greater than 1.04. Just edit the necessary settings and Pure-FTPd will start as a chroot daemon.
The shell script will detect you WAN IP and pass in as a parameter to start the daemon.
Download the file: pure-ftpd.sh
Content of the file
#!/ffp/bin/sh
# PROVIDE: Pure-FTPD
. /ffp/etc/ffp.subr
# shadowandy.sg[at]gmail.com
# ftp port to listen on
pureftp_ftpport=”20021″
# passive port range to use
pureftp_passive=”20032:20039″
# bandwidth limit down:up in kB
pureftp_bandwidth=”380:8″##### You should not need to edit anything below #####
name=”pure-ftpd”
start_cmd=”pureftpd_start”
stop_cmd=”pureftpd_stop”
status_cmd=”pureftpd_status”pureftpd_start()
{
tmp_ip=”/ffp/tmp/pureftp_ip.tmp”
ip_tmp=`wget http://checkip.dyndns.com:8245/ -q -O /ffp/tmp/pureftp_ip1.tmp`
ip_add=`cat /ffp/tmp/pureftp_ip1.tmp | grep “IP Address” | sed -e ‘s/</ /g’ | awk ‘{ print $11 }’`
ip_command=”echo $ip_add”
echo “Starting $name”
pure-ftpd -P ${ip_add} -p ${pureftp_passive} -S ,${pureftp_ftpport} -A -B -C 10 -I 2 -E -T ${pureftp_bandwidth}
}
pureftpd_stop()
{
echo “Stopping $name”
killall $name
}
pureftpd_status()
{
_pids=$(pidof $name)
if test -n “$_pids”; then
echo “$name is running”
else
echo “$name not running”
fi
}
run_rc_command “$1″
Nice,
I am using “pure-ftpd -P 192.168.1.103 -p 65501:65510 -S ,21 -B -C 3 -I 2 -E -T 100:100″ and I put it in fun_plug
GaMerZ,
I see. Does it work if both parties are behind NAT? I think it is better to set it to chroot (-A) if you wish to lock each user to their home directories.
Try using this or edit to your likings. Shift it to /ffp/start/ and chmod a+x it. I think it is more modular than editing fun_plug directly.
I am a newbie to Unix. How to install this script on DNS-323?
Aries,
You would need to set up fun_plug on the DNS-323 or DNS-343 first.
Bro,
Encountered some problem when using the sh file.
When I attempt to run the script, it gives me an error.
wget: bad address ‘checkip.dyndns.com:8245′
Any idea why?
gutlink28,
Hi bro. Do try if you can use the wget command on your DNS-343. Are you running the latest copy of fun_plug?
1. Do try if you can use the wget command on your DNS-343.
Yup, when I telnet in and type ‘wget’, I get the Wget usage list. So I suppose it is running. Is this what you’re refering?
2. Are you running the latest copy of fun_plug?
I got DNS-343 from your MO last time. So that time, I installed V0.5 for the fun_plug. Unless you’re referring to the variants of it?
LOL… Solved the wget issue but now encountered another issue…
During FTP login,
Command: USER xxx
Response: 331 User xxx OK. Password required
Command: PASS ******
Response: 530 Login authentication failed
Error: Could not connect to server
So far still cannot find out the reason why…
gutlink28,
You should set the username and password using the web UI, and use the same username and password after adding them in the ftp page of web UI. Then it should work.
I posted in the Vr-Zone forum on the login issue that I have. I am suspecting in V1.02 for DNS-343, one of the updates “FTP server now supports TLS/SSH” is giving me problem.
Apparently it works in DNS-343 V1.01. But in V1.02, it keeps having the “Response: 530 Login authentication failed” error when I configured via pure-ftpd. However, when I enabled the ftp service in the webui, at least my username and password is verified and accepted.
As you said, I configured my username and password in webui and added it to the ftp access rights. But it still has the problem.
Shadowandy, so far did you try with DNS-343 with firmware V1.02 using pure-ftpd?
I have copied the script and run it to bring up the pure-ftpd server (before that I have disabled built in ftp server).
When try to login it is stuck at the “Connection established, waiting for welcome message…” which took quite long although some times it is working.
Second problem is if it is successfully pass the welcome message, the list command took a long time and then failed after that.
Any idea what is going on? Sorry for newbie here
gutlink28,
On my set it works but I am still on 1.01. Yet to upgrade to 1.02.
Ryan,
Try using a client like FileZilla, it would give you a more descriptive error message.
Ok… let me know the results when you test on V1.02~!
Thanks bro!
Oops… Tripole is me (gutlink28) btw…
Hi Andy,
FileZilla also have the same problem. the error message said:
Status: Connected
Status: Retrieving directory listing…
Command: PWD
Response: 257 “/” is your current location
Command: TYPE I
Response: 200 TYPE is now 8-bit binary
Command: PASV
Response: 227 Entering Passive Mode (xxx,x,xxx,xxx,xx,xx)
Command: LIST
Error: Connection timed out
Error: Failed to retrieve directory listing
is it because I have completely forward all the needed port? I have only put port forwarding for 20021.
Thanks for the help..
Ryan,
In passive setting, you need to forward the passive ports as well.
Hi Andy,
Thanks for the info… After I forward port 20032 ~ 20039 it is ok now..
One more question since the external IP address can be changed anytime how to make ftp server binds to the correct ip everytime?
Thanks for the help again
Ryan,
Some ftp clients are smart enough to use the connected server’s IP as the pasv IP if pasv IP has been reported wrongly by the ftp server. So it shouldn’t be much of a problem. Hope it helps.
Looks like periodically we have to re-start the ftp server in order for it to bind to the correct external IP. This is because of external IP is dynamic IP.
Like if I restart the ftp server now, it might bound to IP 116.15.169.64. Few days later the IP might change to another IP (decided by the ISP DHCP server) while the ftp server still bound to this old IP hence the client will not be able to connect to it.
Is there anyway we can automate this refresh?
Thanks for the info and guide.,.
Ryan,
You might wish to crontab the starting and stopping of the ftp daemon at certain time intervals. As mentioned earlier, most ftp clients nowadays would know that the reported IP (by the server) is wrong and it would automatically use the IP it is connected to as the host to connect for the PASV connections.
i got this error msg
Could not retrieve directory listing
I won’t open a connection to 192.168.2.5 (only to 222.164.182.2)
i forward ports 20032 – 20039 and 21 on my router
any other issues to take not of or to re-edit the Pure-FTPD file??
How do u execute this script? jst put in fun_plug directory?
Guju,
You can put it in /ffp/start . This script is meant for those who knows what they are doing.
yea thax, but i figured it out
tested it out, it works.
hello, i have problem on pure-ftpd.sh , i did put the file and set it correctly, but still can’t list the file, i am using port 22288 and 22289-22900 for pasv port, i am currently using dir-655 and did port forward also, any suggestion? thanks
seijai98,
Make sure you have enabled pasv mode on your ftp client
hello shadowandy, i did!
Andy -
I picked up a 343 a few weeks ago and after much trial and error I’ve finally gotten it to do most of what I want it to do. The last thing I need to get working is Passive FTP.
I found your script (http://www.shadowandy.net/2008/10/setti … e-ftpd.htm) to start the FTP server from fun_plug and set that up. But now when I try to login to the server i get a message telling me that my user is ok, but the password is not. To make sure I went in to the GUI and reset the password for that particular user and tried again. Same message. I’ve tried from an external IP and a local machine behind the firewall.
I’m running the latest beta firmware (because 1.02 causes all sorts of issues with fun_plug), 1.03b70.
Anyone else get the passive FTP working on the 343 with the new firmware?
Thanks,
j.
Ftp log:
Status: Connection established, waiting for welcome message…
Response: 220———- Welcome to Pure-FTPd [TLS] ———-
Response: 220-You are user number 2 of 4 allowed.
Response: 220-Local time is now 10:13. Server port: 20021.
Response: 220-This is a private system – No anonymous login
Response: 220 You will be disconnected after 2 minutes of inactivity.
Command: USER XXXXXX
Response: 331 User XXXXXX OK. Password required
Command: PASS *******
Response: 530 Login authentication failed
is it possible to get SSL working? I’d like for for ssl connections, but it doesn’t seem to be working.
let me know if you have some insight.