Jump to content

I have a FTP server in my home that I use daily. The problem is that I want to use it outside my home network with port forwarding. FTP uses two ports, so I set port 21 to a random port (Ex. 6768) and then set port 20 to another random port (Ex. 6769). FTP does not work over the internet for some reason and I don't understand the two port thing. How would my client know that data is being sent on another port if I connect with 6768? I also heard since I am using a NAT/Firewall my FTP is much harder to configure. 

 

This whole thing doesn't make sense to me and I need help.

 

Thank You!

Link to comment
https://linustechtips.com/topic/428334-ftp-port-forwarding-help/
Share on other sites

Link to post
Share on other sites

#iptables + #linuxrouter

Laptop: Thinkpad W520 i7 2720QM 24GB RAM 1920x1080 2x SSDs Main Rig: 4790k 12GB Hyperx Beast Zotac 980ti AMP! Fractal Define S (window) RM850 Noctua NH-D15 EVGA Z97 FTW with 3 1080P 144hz monitors from Asus Secondary: i5 6600K, R9 390 STRIX, 16GB DDR4, Acer Predator 144Hz 1440P

As Centos 7 SU once said: With great power comes great responsibility.

Link to comment
https://linustechtips.com/topic/428334-ftp-port-forwarding-help/#findComment-5745633
Share on other sites

Link to post
Share on other sites

plz explain

To forward a port and then have it as a different port outside the network u need a linux firewall

 

 

like if u wanna have port 21 inside the network but 2001 outside the network most routers dont support that.

Laptop: Thinkpad W520 i7 2720QM 24GB RAM 1920x1080 2x SSDs Main Rig: 4790k 12GB Hyperx Beast Zotac 980ti AMP! Fractal Define S (window) RM850 Noctua NH-D15 EVGA Z97 FTW with 3 1080P 144hz monitors from Asus Secondary: i5 6600K, R9 390 STRIX, 16GB DDR4, Acer Predator 144Hz 1440P

As Centos 7 SU once said: With great power comes great responsibility.

Link to comment
https://linustechtips.com/topic/428334-ftp-port-forwarding-help/#findComment-5745665
Share on other sites

Link to post
Share on other sites

you can tell your FTP client where his ports are. Port 20 is for authenticating and general commands and Port 21 for data transfer. You could also make it a SFTP so it would use Port 22 and build a SSL-tunnel meaning it is much easier to route and safer for your data.

 

Usually you just need to forward the ports you want to use in your router. For example: 

From Ports: 20 | To Ports: 6768 | Computer: 192.168.1.20

From Ports: 21 | To Ports: 6769 | Computer: 192.168.1.20

 

then set your client to 6768 and 6769 e.g. in Filezilla and you are done. if your FTP runs on linux you might need to set a rule in iptables to let it through

iptables -I INPUT -p tcp -m tcp --dport 20 -j ACCEPTiptables -I INPUT -p tcp -m tcp --dport 21 -j ACCEPT

Bitfenix Phenom M White | ASUS RoG Maximus VIII Gene | Intel i7 6700K @4.6GHz | HyperX Savage 2800MHz CL14 DDR4 16GB | EVGA GTX1080 SC | Intel 750 Series PCIe SSD 400GB | EVGA SuperNova G2 550W | Windows 10 Professional x64 | Logitech G900, Corsair K70 RGB MXbrown O-ringed, BeyerDynamic DT880 (600 Ω) on Fiio E10K & Samson Meteor | Dell U2715H 27", Samsung SyncMaster P2450H 24", Samsung SyncMaster 931BF 19" | DIY Ambilight

Link to comment
https://linustechtips.com/topic/428334-ftp-port-forwarding-help/#findComment-5745672
Share on other sites

Link to post
Share on other sites

 

you can tell your FTP client where his ports are. Port 20 is for authenticating and general commands and Port 21 for data transfer. You could also make it a SFTP so it would use Port 22 and build a SSL-tunnel meaning it is much easier to route and safer for your data.

 

Usually you just need to forward the ports you want to use in your router. For example: 

From Ports: 20 | To Ports: 6768 | Computer: 192.168.1.20

From Ports: 21 | To Ports: 6769 | Computer: 192.168.1.20

 

then set your client to 6768 and 6769 e.g. in Filezilla and you are done. if your FTP runs on linux you might need to set a rule in iptables to let it through

iptables -I INPUT -p tcp -m tcp --dport 20 -j ACCEPTiptables -I INPUT -p tcp -m tcp --dport 21 -j ACCEPT

 

This has been so helpful, but I am using Windows explorer and I don't know how to connect with two ports. I am also using chrome to connect to it, so how would I connect using the two ports if I use chrome and windows explorer.

 

Edit: How would my client know that the server is sending everything through another port? Lets say I changed port 20 and 21 to 6001 and 6002, how would the client know that the data is coming on port 6001?

Link to comment
https://linustechtips.com/topic/428334-ftp-port-forwarding-help/#findComment-5748976
Share on other sites

Link to post
Share on other sites

To forward a port and then have it as a different port outside the network u need a linux firewall

 

 

like if u wanna have port 21 inside the network but 2001 outside the network most routers dont support that.

 

My router supports that. I forwarded port 21 and 20 to different ports outside the network. What should I be doing now?

Link to comment
https://linustechtips.com/topic/428334-ftp-port-forwarding-help/#findComment-5748987
Share on other sites

Link to post
Share on other sites

The issue I believe you are having is the windows FTP client does not know you are using ports other than the defaults. IANA has assigned port 20 for FTP Transfer and 21 for FTP control. When you issue the FTP command from a command prompt in windows (I assume that's what you are using) it will go to those ports. It has no way of knowing that you are using ports 6768 or 6769. I do not believe you can tell the windows FTP client to use alternate ports. If you were to use an FTP client that would be an option. 

 

Your best option would be download an FTP client that let's you specify ports, a good option that is free is WINSCP. Or you could just forward the default FTP ports 20 and 21 to 20 and 21. 

Link to comment
https://linustechtips.com/topic/428334-ftp-port-forwarding-help/#findComment-5750192
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×