#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2010
    Posts
    3
    Rep Power
    0

    Ftp_connect for multiple ftp servers behind 1 router


    After 2 days of googling and trying different solutions I decided to join this forum and ask more experienced people for a possible solution. The problem has similarities with a thread posted before, but because it is not totally similar I started this new thread.

    Ok, the configuration:
    I have a modem/router (option - Globesurfer III) with a static external IP address (say 88.200.88.8) and an internal IP address 192.168.1.1. Connected are two HTTP+FTP servers. 192.168.1.2 and 192.168.1.3.

    I want to be able to reach the HTTP and FTP servers of both from the Internet so I applied the following settings in the Port forwarding part of the router:

    192.168.1.2; TCP Any -> 50002; (Forward to port: 80)
    192.168.1.3; TCP Any -> 50003; (Forward to port: 80)
    192.168.1.2; TCP Any -> 21; (Forward to port: 21)
    192.168.1.3; TCP Any -> 60003; (Forward to port: 21)

    Further I put the firewall from the router on minimum (just for testing) so Internet services from within the LAN are all allowed.

    These settings almost work for me. I can reach both HTTP servers by going to 88.200.88.8:50002 or 88.200.88.8:50003. In addition to this I can make a FTP connection (using FilleZilla on active with port 21 and port 60003), do directory listing and upload/download files. So everything works fine for me so far.

    The problem:
    I am also using ftp_connect from a server on the Internet to put and get some files from both servers. This works fine with the server with port 21 for ftp but doesn't totally work with the FTP port with external FTP port 60003. It does connect, and it makes the files I want to put, but all files are 0KB and no files are downloaded.

    I tried it by setting it on pasv mode and tried forwarding different ports. But i am lost. I am new at php as well as setting ports and am hoping somebody can help me with this.

    Thanks in advance for any help,
    Evan
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2010
    Posts
    3
    Rep Power
    0

    Still no improvements


    After having above problem I have been trying different thinks, but still I have got the same problem. On php net I read this:

    Connecting through a firewall also depends on the type. This is an example for the Secure Gateway FTP. First you have to connect to the firewall, then open a session to the destination ftp server. This looks like this:


    // Connect to firewall
    $conn_id = ftp_connect("firewall.yournet.com");

    // Open a session to an external ftp site
    $login_result = ftp_login ($conn_id, "userid@externalhost.com", "password");

    // Check open
    if ((!$conn_id) || (!$login_result)) {
    echo "Ftp-connect failed!"; die;
    } else {
    echo "Connected.";
    }

    // turn on passive mode transfers
    ftp_pasv ($conn_id, true) ;

    ... and go on ...


    Because ftp_connect to 88.200.88.8:21 works I thought maybe this is an option for me. So I tried:

    // Connect to firewall
    $conn_id = ftp_connect("88.200.88.8", 21, 300);

    // Open a session to an external ftp site
    $login_result = ftp_login ($conn_id, "USER@88.200.88.8:60003", "PASS");


    This gives me the error: "Warning: ftp_login() [function.ftp-login]: Login incorrect. in ..."



    Is there anybody who can give any help?
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2011
    Posts
    2
    Rep Power
    0
    I was wondering if you have ever been able to get this working. I have also been trying to do the same thing, but can't get the combination of triggering/forwarding to allow 2 instances of ftp to different ip addresses. I did find this link that tells to open up port 60010 - 60030 to the ip of the address you need passive mode. That will allow for the connection. I am just wondering if you could pm me the info on how you got the 2 ftps to work.

    thanks
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2010
    Posts
    3
    Rep Power
    0
    Hey grandfinalmike,

    Sorry, did not resolve the question. Seems that is has to do something with the provider, not allowing ftp on a different port than 21.
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2011
    Posts
    2
    Rep Power
    0
    can i ask how you set these up. for some reason, no matter what combo i do, it doesn't seem to work.. maybe its that the linksys i have doesn't allow for it.



    I want to be able to reach the HTTP and FTP servers of both from the Internet so I applied the following settings in the Port forwarding part of the router:

    192.168.1.2; TCP Any -> 50002; (Forward to port: 80)
    192.168.1.3; TCP Any -> 50003; (Forward to port: 80)
    192.168.1.2; TCP Any -> 21; (Forward to port: 21)
    192.168.1.3; TCP Any -> 60003; (Forward to port: 21)

    Further I put the firewall from the router on minimum (just for testing) so Internet services from within the LAN are all allowed.

    These settings almost work for me. I can reach both HTTP servers by going to 88.200.88.8:50002 or 88.200.88.8:50003. In addition to this I can make a FTP connection (using FilleZilla on active with port 21 and port 60003), do directory listing and upload/download files. So everything works fine for me so far.

IMN logo majestic logo threadwatch logo seochat tools logo