Setting external IP on Pure-FTPd


    October 26th, 2008 | Tags: , ,

    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″


    Share it on del.icio.us




    20 responses

    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

       
    2. 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.

       
    3. I am a newbie to Unix. How to install this script on DNS-323?

       
    4. Aries,

      You would need to set up fun_plug on the DNS-323 or DNS-343 first. :)

       
    5. 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?

       
    6. 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?

       
    7. 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?

       
    8. 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…

       
    9. 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.

       
    10. 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?

       
    11. 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 :)

       
    12. 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.

       
    13. Ok… let me know the results when you test on V1.02~!

      Thanks bro! :)

       
    14. Oops… Tripole is me (gutlink28) btw…

       
    15. 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..

       
    16. Ryan,

      In passive setting, you need to forward the passive ports as well.

       
    17. 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

       
    18. 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.

       
    19. 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.,.

       
    20. 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.

       

    Leave a reply


    Send a trackback.

    Comments for this post will be closed on 24 March 2009.


    RSS Feeds



    Treat shadowandy!


    Like to treat shadowandy a cup of Starbucks?

    Polls


    Which is your preferred SOHO networking brand?

    • D-Link (48%, 225 Votes)
    • Linksys (27%, 126 Votes)
    • Cisco (12%, 57 Votes)
    • Netgear (7%, 34 Votes)
    • Buffalo (2%, 9 Votes)
    • TRENDnet (1%, 6 Votes)
    • PCI (1%, 5 Votes)
    • Planex (1%, 3 Votes)

    Total Voters: 465

    Loading ... Loading ...


    Recent Comments



    Friend's Blog



    Interesting Links



    Previous Postings




    Copyright © 2005 - 2008 www.shadowandy.net  94 queries. 0.688 seconds.Go back up ↑