What FTP is
FTP (File Transfer Protocol, RFC 959) transfers files between a client and a server. It dates from 1985 and uses two TCP connections: a control connection, to port 21, carrying commands and replies in text, and a data connection, opened for each file or listing.
It encrypts nothing: the user name, the password and the files travel as they are. That's why it's rarely used today to manage network devices, and SFTP or SCP, which run inside SSH, are preferred. It still shows up on old servers, industrial equipment and as an option to upgrade the software of some devices.
Active mode and passive mode
| Active (PORT) | Passive (PASV) | |
|---|---|---|
| Who opens the data connection | The server, from its port 20, toward the client | The client, toward the port the server announces |
| Command | PORT h1,h2,h3,h4,p1,p2 (the client's IP and port) | PASV → 227 with the server's IP and port |
| Firewalls and NAT | Problematic: the connection comes in toward the client | Better: the client opens both connections |
| On Cisco IOS | Allowed without ip ftp passive | The only mode with ip ftp passive |
In both cases, the port is given as two numbers: the first × 256 + the second. Firewalls that understand FTP (FTP inspection) read the 227 or the PORT to open the data port; with NAT, they also have to rewrite the IP inside the text.
How it works: from the connection to the file
Five steps: the control connection, the login, passive mode, the transfer and the close.
Control connection and the 220 greeting
When copy running-config ftp: runs, R1 opens a TCP connection to port 21: the control connection, which only carries commands and replies. The IOS SYN carries a 4128-byte window and only the MSS option. Once the connection is open, the server introduces itself with a line of text: 220, service ready, and its name.
USER and PASS: the password in clear text
R1 sends USER backup (the one from ip ftp username) and the server asks for the password with 331. Then R1 sends PASS ThoR-Bkp-2026: the full password, in clear text, in a packet anyone along the path can capture. In the configuration it was encrypted with type 7, but that only hides it on screen: on the network it travels as is. The server replies 230: logged in.
TYPE I and PASV: passive mode
TYPE I asks for binary mode: the file is copied byte by byte, without touching line endings. Then PASV asks for passive mode: the server opens a port and replies 227 with six numbers, (192,168,20,20,156,64): the first four are its IP and the last two the port, 156 × 256 + 64 = 40000. R1 has ip ftp passive, which forces it to use passive mode only: that way the client opens both connections and gets through firewalls and NAT more easily.
Data connection and STOR
R1 opens a second TCP connection to port 40000. Over the control connection it sends STOR r1-confg and the server replies 150: ready to receive. The whole file travels over the data connection, 437 bytes of configuration readable in the capture: the hostname, the interfaces and even the ip ftp password line. R1 closes the data connection with FIN to mark the end of the file and the server confirms over the control connection with 226: transfer complete.
QUIT and the secure alternative
R1 sends QUIT and the server says goodbye with 221. During the whole session, the password and the configuration traveled unencrypted. That's why CCNA v2.0 (topic 4.2) asks you to manage device files with SFTP or SCP: both run inside SSH, which encrypts everything and authenticates the server. In IOS XE, copy running-config scp: does the same as this lab, but inside an SSH tunnel.
The replies
| First digit | Meaning | Examples from this lab |
|---|---|---|
| 1xx | Preliminary reply: the action started, another reply will follow | 150 Ok to send data |
| 2xx | Completed successfully | 220, 230, 200, 227, 226, 221 |
| 3xx | Accepted, but more information is needed | 331 Please specify the password |
| 4xx | Temporary error: it can be retried | 421, 425 (could not open the data connection) |
| 5xx | Permanent error | 530 (login incorrect), 550 (file unavailable) |
FTP, FTPS, SFTP and SCP
| Protocol | How it protects | Port |
|---|---|---|
| FTP | It protects nothing | TCP 21 (control) + data |
| FTPS | FTP inside TLS | TCP 21 (explicit) or 990 (implicit) |
| SFTP | A different protocol, inside SSH | TCP 22 |
| SCP | File copy inside SSH | TCP 22 |
| TFTP | Not even a password: no users and no encryption | UDP 69 |
On Cisco IOS XE, to copy configurations and images securely: ip ssh version 2 and, so others can copy from the router, ip scp server enable. From the router, copy running-config scp: or copy running-config sftp:.
The commands in Cisco IOS XE
| Command | What it does |
|---|---|
ip ftp username backup · ip ftp password … | The user name and password the router will use as an FTP client. |
ip ftp source-interface GigabitEthernet0/0/2 | The interface whose IP is used as the source. |
ip ftp passive | Uses passive mode only; without it, IOS allows both modes. |
copy running-config ftp://192.168.20.20/r1-confg | Copies the configuration to the server. |
copy ftp://… flash: | Downloads a file (for example, an image) to flash. |
copy running-config scp://backup@192.168.20.20/r1-confg | The same, encrypted inside SSH (topic 4.2). |
This lab belongs to the CCNA v2.0 track: topic 4.2 asks you to manage device configuration and software files using secure file transfer operations, SFTP and SCP. Seeing FTP in a capture makes it clear why.
Frequently asked questions
Why does FTP use two connections?
To separate the dialog from the data: commands and replies go over the control connection; each file or listing over the data connection. That way you can keep talking to the server while a transfer runs.
Does the type 7 password protect anything?
It only keeps someone from reading it off the screen: it can be decrypted in seconds. And over the network, FTP sends it in clear text anyway.
How do you see the password in Wireshark?
With the filter ftp.request.command == "PASS", or under Statistics > Credentials: Wireshark shows the FTP user name and password directly.
What is TFTP?
A minimal version over UDP 69, with no users or passwords. It's used to boot devices over the network or load images in lab networks, never across untrusted networks.
Why does passive mode work better with firewalls?
Because the client opens both connections outward. In active mode, the server has to open a connection toward the client, which a firewall or NAT usually blocks.
What you take away
- FTP uses a control connection (TCP 21) and another data connection for each file.
- Commands and replies are text lines ending in CRLF.
- USER and PASS travel in clear text: anyone along the path sees the password.
- In passive mode, the 227 carries the IP and port: first × 256 + second.
- With ip ftp passive, Cisco IOS uses passive mode only.
- For device management, CCNA v2.0 asks for SFTP or SCP, inside SSH.
NEXT STEP
From this lesson to the CCNA 2.0 Course
Secure file management (topic 4.2) is part of The House of Routing's CCNA 2.0 Course, with SSH, SCP and SFTP in the Canadá Logística lab. We'll let you know when it opens.
Upcoming protocol lessons
Sources
- RFC 959 · File Transfer Protocol (FTP)
- RFC 2577 · FTP Security Considerations
- Cisco · IOS Configuration Fundamentals Command Reference (ip ftp passive, password, source-interface, username)
- Cisco · 200-301 CCNA v2.0 Exam Topics (4.2)
Lesson prepared with AI assistance and checked against the sources cited. The bytes of every packet are generated according to the standard and verified with an independent tool.