Understanding the FTP PORT command | TechTarget (2024)

Tip

FTP uses control and data channels, each using a separate TCP port. Port 21 is for the control channel, and port 20 is for the data channel. Learn how these two channels are used.

You may already know that, when FTP commands cross the wire, they use TCP port 21 by default. You may also know that port 20 is assigned to the FTP data channel by default. For further reference, see the ftp-data entry in the Service Name and Transport Protocol Port Number Registry on the Internet Assigned Numbers Authority, or IANA, website.

Even though port 20 is assigned to the FTP data channel, most FTP data sessions don't use port 20, unfortunately. Individual control and data channels are used to separate control commands from large file transfers. Let's look at how FTP works and the purpose of the PORT command.

What is the FTP PORT command?

FTP communications use two TCP port number values: one for commands -- port 21 by default -- and one for data transfer. This is where the PORT command comes into play.

The PORT command is sent by an FTP client to establish a secondary connection (address and port) for data to travel over. In some FTP implementations port 20 is used for data, but that is the exception rather than the rule.

An FTP client sends a PORT command to the FTP server to identify what port the client will be listening on for the data channel connection. Upon receipt of the PORT command, the server establishes a new TCP connection to the client using that TCP port value. This is illustrated in this active FTP diagram.

Understanding the FTP PORT command | TechTarget (1)

Typically, in a packet trace of active mode FTP, you'll see the data channel originating from server port 20 to a dynamic client port number. IANA states that this range should be between 49152 through 65535, but most likely, you'll see your application using a port just above 1024 -- the area that used to be the dynamic port number area.

You may see numerous PORT commands issued during a single FTP session -- a new data channel must be established to transfer directory listings and perform file GET and PUT operations.

Active mode FTP does have a problem. It doesn't work when the client is behind a firewall or when network address translation (NAT) is used on the client's network. Passive mode FTP was created to solve this problem. It relies on the client sending a PASV command to the server over the control channel. The server response includes a high port number that the client should use to open the data connection -- see the passive FTP diagram above.

Mixed IPv4 and IPv6 networks require the use of extended passive mode commands EPRT and EPSV to instruct the client and server to support both address types as described in RFC 2428.

Other FTP commands and response codes

Many other FTP commands can create a directory, remove a directory, list files in a directory, remove a file, set file type (ASCII/binary) and copy files.

The responses to the FTP commands are numeric response codes that mean different things. About 50 codes exist in the following ranges:

  • 100-199 represent "command received, processing underway."
  • 200-299 indicate success, perhaps with other conditions.
  • 300-399 report success and that the server is waiting for additional data.
  • 400-499 and 500-599 signify errors.

FTP security

The FTP default data transport mechanism does not provide any security -- all commands and data are sent unencrypted. RFC 2228, FTP Security Extensions, defines extensions to provide secure authentication, as well as control and data channel encryption, known as FTP Secure, or FTPS. Three commands support this secure mode:

  1. AUTH TLS negotiates a Transport Layer Security (TLS) connection on the control channel.
  2. PBSZ 0 sets the encryption buffer size and set to zero for TLS.
  3. PROT P enables TLS encryption of the data channel.

An alternative Secure FTP is based on the Secure Shell security mechanism.

In summary, the PORT command is used in FTP to communicate the TCP port number to use for the data transfer channel. In active mode FTP, the client uses the PORT command to tell the server which high-numbered port the client will use for the data channel, and the server opens a connection to that port. In passive mode, the PASV command is sent by the client, and the server responds with the high-numbered port on which it will accept the data connection. The result supports operation of FTP with firewalls and NAT. Further enhancements to FTP support IPv6 and improved security.

Next Steps

How to use the LFTP client to download files

Related Resources

Dig Deeper on Network infrastructure

  • What is FTP?By: AlexanderGillis
  • What is SSH (Secure Shell) and How Does It Work?By: AlexanderGillis
  • How to use the LFTP client to download filesBy: DamonGarn
  • How to use TFTP to transfer files across the networkBy: DamonGarn
Understanding the FTP PORT command | TechTarget (2024)

References

Top Articles
2024 NASCAR All-Star Race: North Wilkesboro DFS lineups, Fantasy picks, odds, rankings, driver pool by expert
Opinion: Actions Detrimental to NASCAR? Please.
Digitaler Geldbeutel fürs Smartphone: Das steckt in der ID Wallet-App
Craigslist Free Stuff Merced Ca
Can Banks Take Your Money To Pay Off Debts? StepChange
Reports of romance scams hit record highs in 2021
Nycers Pay Schedule
Victoria Tortilla & Tamales Factory Menu
Puss In Boots: The Last Wish Showtimes Near Fox Berkshire
Lynaritaa Boobs
Jackie Knust Wendel
Rebecca Benedict Forum
Tabdil Tarikh
Apryl Prose Wiki
Wat is 7x7? De gouden regel voor uw PowerPoint-presentatie
Soorten wolken - Weerbericht, weerhistorie, vakantieweer en veel weereducatie.
Wmlink/Sspr
Tinyzonetv.to Unblocked
Nutrislice White Bear Lake
Gas Station Drive Thru Car Wash Near Me
Toothio Login
11 Shows Your Mom Loved That You Should Probably Revisit
Sodexo Northern Portal
Ice Dodo Unblocked 76
Otis Inmate Search Michigan
Accuweather Mold Count
General Kearny Inn Motel & Event Center
Unmhealth My Mysecurebill
Duen Boobs
Go Smiles Herndon Reviews
Ignition Date Format
Slim Thug’s Wealth and Wellness: A Journey Beyond Music
Litter-Robot 3 Pinch Contact & Dfi Kit
No Compromise in Maneuverability and Effectiveness
Etfh Hatchery
Brian Lizer Life Below Zero Next Generation
Papa Louie When Pizzas Attack Unblocked
Culver's Flavor Of The Day Whitewater
Fandafia
Metroplus Rewards Sign In
Tu Pulga Online Utah
Left Periprosthetic Femur Fracture Icd 10
Tacoma Craigslist Free
Epiq Document Delivery
Gwcc Salvage
Understanding DeFi The Roles, Tools, Risks, and Rewards of -- Alexandra Damsker -- 2024 -- O'Reilly Media -- 9781098120764 -- 79accdb00af9d0f41d97f44fa7970ff1 -- Annas Archive - Biblioteconomia
Dtm Urban Dictionary
Walmart Makes Its Fashion Week Debut
Redbox Walmart Near Me
CareLink™ Personal Software | Medtronic
Edible Arrangements Track
Sam Smith Lpsg
Latest Posts
Article information

Author: Carlyn Walter

Last Updated:

Views: 6699

Rating: 5 / 5 (70 voted)

Reviews: 93% of readers found this page helpful

Author information

Name: Carlyn Walter

Birthday: 1996-01-03

Address: Suite 452 40815 Denyse Extensions, Sengermouth, OR 42374

Phone: +8501809515404

Job: Manufacturing Technician

Hobby: Table tennis, Archery, Vacation, Metal detecting, Yo-yoing, Crocheting, Creative writing

Introduction: My name is Carlyn Walter, I am a lively, glamorous, healthy, clean, powerful, calm, combative person who loves writing and wants to share my knowledge and understanding with you.