1 .\" $OpenBSD: ftp-proxy.8,v 1.11 2008/02/26 18:52:53 henning Exp $
3 .\" Copyright (c) 2004, 2005 Camiel Dobbelaar, <cd@sentia.nl>
5 .\" Permission to use, copy, modify, and distribute this software for any
6 .\" purpose with or without fee is hereby granted, provided that the above
7 .\" copyright notice and this permission notice appear in all copies.
9 .\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 .\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 .\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 .\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 .\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
24 .Nd Internet File Transfer Protocol proxy daemon
32 .Op Fl m Ar maxsessions
42 is a proxy for the Internet File Transfer Protocol.
43 FTP control connections should be redirected into the proxy using the
46 command, after which the proxy connects to the server on behalf of
49 The proxy allows data connections to pass, rewriting and redirecting
50 them so that the right addresses are used.
51 All connections from the client to the server have their source
52 address rewritten so they appear to come from the proxy.
53 Consequently, all connections from the server to the proxy have
54 their destination address rewritten, so they are redirected to the
61 Assuming the FTP control connection is from $client to $server, the
62 proxy connected to the server using the $proxy source address, and
63 $port is negotiated, then
65 adds the following rules to the various anchors.
66 (These example rules use inet, but the proxy also supports inet6.)
68 In case of active mode (PORT or EPRT):
69 .Bd -literal -offset 2n
70 rdr from $server to $proxy port $port -> $client
71 pass quick inet proto tcp \e
72 from $server to $client port $port
75 In case of passive mode (PASV or EPSV):
76 .Bd -literal -offset 2n
77 nat from $client to $server port $port -> $proxy
78 pass in quick inet proto tcp \e
79 from $client to $server port $port
80 pass out quick inet proto tcp \e
81 from $proxy to $server port $port
84 The options are as follows:
88 The proxy will expect and use IPv6 addresses for all communication.
89 Only the extended FTP modes EPSV and EPRT are allowed with IPv6.
90 The proxy is in IPv4 mode by default.
92 Only permit anonymous FTP connections.
93 Either user "ftp" or user "anonymous" is allowed.
95 The proxy will use this as the source address for the control
96 connection to a server.
98 Address where the proxy will listen for redirected control connections.
99 The default is 127.0.0.1, or ::1 in IPv6 mode.
101 Debug level, ranging from 0 to 7.
102 Higher is more verbose.
104 (These levels correspond to the
109 The process will stay in the foreground, logging to standard error.
110 .It Fl m Ar maxsessions
111 Maximum number of concurrent FTP sessions.
112 When the proxy reaches this limit, new connections are denied.
113 The default is 100 sessions.
114 The limit can be lowered to a minimum of 1, or raised to a maximum of 500.
117 Only used in combination with
119 The default is port 21.
121 Port where the proxy will listen for redirected connections.
122 The default is port 8021.
124 Create rules with queue
126 appended, so that data connections can be queued.
128 Fixed server address, also known as reverse mode.
129 The proxy will always connect to the same server, regardless of
130 where the client wanted to connect to (before it was redirected).
131 Use this option to proxy for a server behind NAT, or to forward all
132 connections to another proxy.
134 Rewrite sourceport to 20 in active mode to suit ancient clients that insist
135 on this RFC property.
137 The filter rules will add tag
139 to data connections, and not match quick.
140 This way alternative rules that use the
142 keyword can be implemented following the
145 These rules can use special
147 features like route-to, reply-to, label, rtable, overload, etc. that
149 does not implement itself.
151 Number of seconds that the control connection can be idle, before the
152 proxy will disconnect.
153 The maximum is 86400 seconds, which is also the default.
154 Do not set this too low, because the control connection is usually
155 idle when large data transfers are taking place.
157 Set the 'log' flag on pf rules committed by
159 Use twice to set the 'log-all' flag.
160 The pf rules do not log by default.
163 To make use of the proxy,
165 needs the following rules.
166 All anchors are mandatory.
167 Adjust the rules as needed.
170 .Bd -literal -offset 2n
171 nat-anchor "ftp-proxy/*"
172 rdr-anchor "ftp-proxy/*"
173 rdr pass on $int_if proto tcp from $lan to any port 21 -> \e
178 .Bd -literal -offset 2n
180 pass out proto tcp from $proxy to any port 21
188 does not allow the ruleset to be modified if the system is running at a
193 cannot add rules to the anchors and FTP data connections may get blocked.
195 Negotiated data connection ports below 1024 are not allowed.
197 The negotiated IP address for active modes is ignored for security
199 This makes third party file transfers impossible.
202 chroots to "/var/empty" and changes to user "proxy" to drop privileges.