Why does FTP's EPSV command spare a NAT the rewriting that PASV needs, and what does it still leave firewalls to handle, including on IPv6?
answer
- what the reply leaves out
- same address as port 21
- the port is still a secret
- IPv6 has no room in PORT
basics
~20 sEPSV's 229 reply carries only a port; the client reuses the control connection's address, so no private address appears for a NAT to rewrite. Firewalls must still learn or pre-open that port, on IPv4 and IPv6 alike.
solid answer
~50 s`PASV`'s `227` reply embeds an IPv4 address and a port, so a server behind NAT leaks its private address unless the server or a NAT helper fixes it. RFC 2428's `EPSV` is answered with `229 Entering Extended Passive Mode (|||6446|)`: the address fields are left blank and the client connects to the same address it used for the control connection, which is already the public one. RFC 2428 states this explicitly: EPSV does not require a NAT to change the address. What remains is the port. A stateful firewall in front of the server must still admit the data connection, either through a helper that reads the `229` reply or through a fixed, statically opened passive range. On IPv6, `PORT` and `PASV` cannot express a 128-bit address at all, so `EPRT` and `EPSV` are mandatory; there is usually no NAT, but the stateful firewall problem is unchanged, and `EPRT` still carries an address.
go deeper
Recall that EPSV is the extended passive command, that its 229 reply contains only a port, and that IPv6 needs the extended commands.
Explain that the client reuses the control connection's address, why that avoids rewriting a private address, and why the port must still be forwarded and admitted.
Use the EPSV-works-PASV-fails pattern to localise a fault to the advertised address, and plan IPv6 FTP with firewall ranges or helpers that parse EPRT and 229.
Assess whether moving FTP partners to IPv6 or EPSV-only clients reduces operational burden, given that the firewall's port problem survives both changes.
## Two passive replies, one difference FTP's passive mode has two forms, and the difference that matters at a NAT is what the server's reply contains. | Command | Reply | Carries | NAT has to rewrite | |---|---|---|---| | `PASV` (RFC 959) | `227 Entering Passive Mode (h1,h2,h3,h4,p1,p2)` | IPv4 address and port | The address, if the server is behind NAT and not configured to advertise its public one | | `EPSV` (RFC 2428) | `229 Entering Extended Passive Mode`, port in the parentheses | Port only | Nothing | A full example is `229 Entering Extended Passive Mode (|||6446|)`. RFC 2428 requires the first two fields of that reply to be blank and says the data connection uses the same network protocol and the same address as the control connection. A client talking to a server published as `203.0.113.10` already reached that address for port 21, so it dials `203.0.113.10` again for data. The server's private address never appears in the conversation. RFC 2428 section 4 makes the point itself: using EPSV does not require NATs to change the network address in the traffic, whereas they would have to if `EPRT` were used. RFC 3027, which lists protocols that NAT complicates, cites the same section as the way to take FTP off the NAT helper's hands. ## What EPSV does not fix Removing the address does not remove the **port**, and the port is what a stateful firewall needs to admit the data connection. - **The server's firewall still blocks an unannounced port.** A stateful firewall drops inbound connections it did not expect. It either runs an FTP helper that parses the `229` reply and opens a pinhole, or it permanently allows a fixed passive range configured on the server. - **The NAT still has to forward the port.** Port forwarding (a destination-NAT rule) for the passive range is needed whether the reply is `227` or `229`; EPSV removes only the payload rewrite. - **A useful diagnostic falls out of it.** If EPSV clients succeed and PASV clients hang against the same server, the forwarding and firewall rules for the passive range are fine; the fault is the private address the server writes into `227`, and the fix is to configure the public address it should advertise. - **Encryption still blinds the helper.** Under explicit FTPS the `229` reply is inside TLS, so a helper cannot see the port; only a statically opened range works. - **Clients and servers must both support it.** A server that does not implement `EPSV` answers with an error, and a client that then falls back to `PASV` is back to an embedded address. ## IPv6: extended commands are not optional The classic commands encode exactly four address bytes. An IPv6 address is sixteen, so RFC 2428 introduced: - `EPRT |2|2001:db8::15|5282|`, the active-mode form, carrying a network-protocol number (1 for IPv4, 2 for IPv6), the address and the port; - `EPSV`, which on IPv6 gives the same port-only `229` reply. On IPv6 there is normally no NAT, because hosts have globally unique addresses. That removes the address-rewriting problem entirely, but it does not remove filtering: 1. An IPv6 stateful firewall still drops unsolicited inbound connections. 2. Passive transfers still need the server's passive range opened, or a helper that understands `229`. 3. Active transfers still need an inbound connection to the client, which the client's firewall blocks unless its helper parses `EPRT`. So the IPv6 migration fixes FTP's address problem and leaves its port problem untouched. ## Where EPRT stands `EPRT` is the extended form of `PORT` and, like `PORT`, carries the client's address. Behind an IPv4 NAT, a client that uses `EPRT` needs the NAT's helper to rewrite that address just as it would for `PORT`, and the server's passive range plays no part: the problem sits on the client's side. That is why the advice for clients behind NAT is passive mode, and with RFC 2428 support, EPSV specifically. ## What a good answer covers A middle-level answer says that `229` has no address, that the client reuses the control connection's address, and that this sidesteps the private-address leak. A stronger one adds the limit: the port still has to be admitted, the NAT still has to forward it, TLS still hides it, and IPv6 changes the address story but not the firewall story.
- If a server behind NAT answers EPSV with 229, does the NAT still need a port-forwarding rule for data?Yes. EPSV removes the address from the reply, not the need to reach the port. The client dials the server's public address on the announced port, and the NAT must forward that port to the server. In practice that means pinning the server to a fixed passive range and forwarding the whole range, plus 21.
- Does IPv6 make FTP firewall-friendly?No. IPv6 usually removes NAT, so no address needs rewriting, but stateful firewalls still drop unsolicited inbound connections. Passive transfers still need the server's range opened or a helper that reads `229`, and active transfers still need an inbound connection to the client after `EPRT`.
- EPSV works through any firewall because it needs no open port
- The 229 reply carries the server's public address, learned automatically
- On IPv6 FTP needs no firewall planning because there is no NAT
- EPRT avoids NAT rewriting just as EPSV does
- PASV can carry an IPv6 address in its 227 reply