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)
Top Articles
Pros and cons of UV water treatment of drinking water | AWT-ASIA
Ultraviolet disinfection of drinking water
Mcgeorge Academic Calendar
Occupational therapist
Nc Maxpreps
The Best English Movie Theaters In Germany [Ultimate Guide]
Paketshops | PAKET.net
Urinevlekken verwijderen: De meest effectieve methoden - Puurlv
Seth Juszkiewicz Obituary
Dityship
Summoner Class Calamity Guide
Raleigh Craigs List
Gma Deals And Steals Today 2022
Roof Top Snipers Unblocked
Cta Bus Tracker 77
Kountry Pumpkin 29
Dcf Training Number
Craigslist Battle Ground Washington
Uncovering The Mystery Behind Crazyjamjam Fanfix Leaked
Reviews over Supersaver - Opiness - Spreekt uit ervaring
Mineral Wells Skyward
Bleacher Report Philadelphia Flyers
1979 Ford F350 For Sale Craigslist
Ou Football Brainiacs
Grave Digger Wynncraft
Hwy 57 Nursery Michie Tn
Craigslist Auburn Al
Sinfuldeed Leaked
Desales Field Hockey Schedule
Egg Crutch Glove Envelope
Clearvue Eye Care Nyc
Black Adam Showtimes Near Amc Deptford 8
In Polen und Tschechien droht Hochwasser - Brandenburg beobachtet Lage
Cherry Spa Madison
Daly City Building Division
Flags Half Staff Today Wisconsin
Bcy Testing Solution Columbia Sc
The best bagels in NYC, according to a New Yorker
Worcester County Circuit Court
All Obituaries | Sneath Strilchuk Funeral Services | Funeral Home Roblin Dauphin Ste Rose McCreary MB
Kutty Movie Net
Fairbanks Auto Repair - University Chevron
Here's Everything You Need to Know About Baby Ariel
Portal Pacjenta LUX MED
Eat Like A King Who's On A Budget Copypasta
Stephen Dilbeck, The First Hicks Baby: 5 Fast Facts You Need to Know
Msatlantathickdream
Black Adam Showtimes Near Kerasotes Showplace 14
Cars & Trucks near Old Forge, PA - craigslist
Gelato 47 Allbud
Tamilyogi Cc
Craigslist Charlestown Indiana
Latest Posts
Article information

Author: The Hon. Margery Christiansen

Last Updated:

Views: 5836

Rating: 5 / 5 (70 voted)

Reviews: 85% of readers found this page helpful

Author information

Name: The Hon. Margery Christiansen

Birthday: 2000-07-07

Address: 5050 Breitenberg Knoll, New Robert, MI 45409

Phone: +2556892639372

Job: Investor Mining Engineer

Hobby: Sketching, Cosplaying, Glassblowing, Genealogy, Crocheting, Archery, Skateboarding

Introduction: My name is The Hon. Margery Christiansen, I am a bright, adorable, precious, inexpensive, gorgeous, comfortable, happy person who loves writing and wants to share my knowledge and understanding with you.