xref: /dflybsd-src/usr.sbin/ftp-proxy/ftp-proxy.8 (revision 86d7f5d305c6adaa56ff4582ece9859d73106103)
1*86d7f5d3SJohn Marino.\"	$OpenBSD: ftp-proxy.8,v 1.10 2007/08/01 15:45:41 jmc Exp $
2*86d7f5d3SJohn Marino.\"
3*86d7f5d3SJohn Marino.\" Copyright (c) 2004, 2005 Camiel Dobbelaar, <cd@sentia.nl>
4*86d7f5d3SJohn Marino.\"
5*86d7f5d3SJohn Marino.\" Permission to use, copy, modify, and distribute this software for any
6*86d7f5d3SJohn Marino.\" purpose with or without fee is hereby granted, provided that the above
7*86d7f5d3SJohn Marino.\" copyright notice and this permission notice appear in all copies.
8*86d7f5d3SJohn Marino.\"
9*86d7f5d3SJohn Marino.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10*86d7f5d3SJohn Marino.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11*86d7f5d3SJohn Marino.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12*86d7f5d3SJohn Marino.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13*86d7f5d3SJohn Marino.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14*86d7f5d3SJohn Marino.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15*86d7f5d3SJohn Marino.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16*86d7f5d3SJohn Marino.\"
17*86d7f5d3SJohn Marino.Dd September 9, 2010
18*86d7f5d3SJohn Marino.Dt FTP-PROXY 8
19*86d7f5d3SJohn Marino.Os
20*86d7f5d3SJohn Marino.Sh NAME
21*86d7f5d3SJohn Marino.Nm ftp-proxy
22*86d7f5d3SJohn Marino.Nd Internet File Transfer Protocol proxy daemon
23*86d7f5d3SJohn Marino.Sh SYNOPSIS
24*86d7f5d3SJohn Marino.Nm
25*86d7f5d3SJohn Marino.Bk -words
26*86d7f5d3SJohn Marino.Op Fl 6Adrv
27*86d7f5d3SJohn Marino.Op Fl a Ar address
28*86d7f5d3SJohn Marino.Op Fl b Ar address
29*86d7f5d3SJohn Marino.Op Fl D Ar level
30*86d7f5d3SJohn Marino.Op Fl m Ar maxsessions
31*86d7f5d3SJohn Marino.Op Fl P Ar port
32*86d7f5d3SJohn Marino.Op Fl p Ar port
33*86d7f5d3SJohn Marino.Op Fl q Ar queue
34*86d7f5d3SJohn Marino.Op Fl R Ar address
35*86d7f5d3SJohn Marino.Op Fl T Ar tag
36*86d7f5d3SJohn Marino.Op Fl t Ar timeout
37*86d7f5d3SJohn Marino.Ek
38*86d7f5d3SJohn Marino.Sh DESCRIPTION
39*86d7f5d3SJohn Marino.Nm
40*86d7f5d3SJohn Marinois a proxy for the Internet File Transfer Protocol.
41*86d7f5d3SJohn MarinoFTP control connections should be redirected into the proxy using the
42*86d7f5d3SJohn Marino.Xr pf 4
43*86d7f5d3SJohn Marino.Ar rdr
44*86d7f5d3SJohn Marinocommand, after which the proxy connects to the server on behalf of
45*86d7f5d3SJohn Marinothe client.
46*86d7f5d3SJohn Marino.Pp
47*86d7f5d3SJohn MarinoThe proxy allows data connections to pass, rewriting and redirecting
48*86d7f5d3SJohn Marinothem so that the right addresses are used.
49*86d7f5d3SJohn MarinoAll connections from the client to the server have their source
50*86d7f5d3SJohn Marinoaddress rewritten so they appear to come from the proxy.
51*86d7f5d3SJohn MarinoConsequently, all connections from the server to the proxy have
52*86d7f5d3SJohn Marinotheir destination address rewritten, so they are redirected to the
53*86d7f5d3SJohn Marinoclient.
54*86d7f5d3SJohn MarinoThe proxy uses the
55*86d7f5d3SJohn Marino.Xr pf 4
56*86d7f5d3SJohn Marino.Ar anchor
57*86d7f5d3SJohn Marinofacility for this.
58*86d7f5d3SJohn Marino.Pp
59*86d7f5d3SJohn MarinoAssuming the FTP control connection is from $client to $server, the
60*86d7f5d3SJohn Marinoproxy connected to the server using the $proxy source address, and
61*86d7f5d3SJohn Marino$port is negotiated, then
62*86d7f5d3SJohn Marino.Nm
63*86d7f5d3SJohn Marinoadds the following rules to the various anchors.
64*86d7f5d3SJohn Marino(These example rules use inet, but the proxy also supports inet6.)
65*86d7f5d3SJohn Marino.Pp
66*86d7f5d3SJohn MarinoIn case of active mode (PORT or EPRT):
67*86d7f5d3SJohn Marino.Bd -literal -offset 2n
68*86d7f5d3SJohn Marinordr from $server to $proxy port $port -> $client
69*86d7f5d3SJohn Marinopass quick inet proto tcp \e
70*86d7f5d3SJohn Marino    from $server to $client port $port
71*86d7f5d3SJohn Marino.Ed
72*86d7f5d3SJohn Marino.Pp
73*86d7f5d3SJohn MarinoIn case of passive mode (PASV or EPSV):
74*86d7f5d3SJohn Marino.Bd -literal -offset 2n
75*86d7f5d3SJohn Marinonat from $client to $server port $port -> $proxy
76*86d7f5d3SJohn Marinopass in quick inet proto tcp \e
77*86d7f5d3SJohn Marino    from $client to $server port $port
78*86d7f5d3SJohn Marinopass out quick inet proto tcp \e
79*86d7f5d3SJohn Marino    from $proxy to $server port $port
80*86d7f5d3SJohn Marino.Ed
81*86d7f5d3SJohn Marino.Pp
82*86d7f5d3SJohn MarinoThe options are as follows:
83*86d7f5d3SJohn Marino.Bl -tag -width Ds
84*86d7f5d3SJohn Marino.It Fl 6
85*86d7f5d3SJohn MarinoIPv6 mode.
86*86d7f5d3SJohn MarinoThe proxy will expect and use IPv6 addresses for all communication.
87*86d7f5d3SJohn MarinoOnly the extended FTP modes EPSV and EPRT are allowed with IPv6.
88*86d7f5d3SJohn MarinoThe proxy is in IPv4 mode by default.
89*86d7f5d3SJohn Marino.It Fl A
90*86d7f5d3SJohn MarinoOnly permit anonymous FTP connections.
91*86d7f5d3SJohn MarinoEither user "ftp" or user "anonymous" is allowed.
92*86d7f5d3SJohn Marino.It Fl a Ar address
93*86d7f5d3SJohn MarinoThe proxy will use this as the source address for the control
94*86d7f5d3SJohn Marinoconnection to a server.
95*86d7f5d3SJohn Marino.It Fl b Ar address
96*86d7f5d3SJohn MarinoAddress where the proxy will listen for redirected control connections.
97*86d7f5d3SJohn MarinoThe default is 127.0.0.1, or ::1 in IPv6 mode.
98*86d7f5d3SJohn Marino.It Fl D Ar level
99*86d7f5d3SJohn MarinoDebug level, ranging from 0 to 7.
100*86d7f5d3SJohn MarinoHigher is more verbose.
101*86d7f5d3SJohn MarinoThe default is 5.
102*86d7f5d3SJohn Marino(These levels correspond to the
103*86d7f5d3SJohn Marino.Xr syslog 3
104*86d7f5d3SJohn Marinolevels.)
105*86d7f5d3SJohn Marino.It Fl d
106*86d7f5d3SJohn MarinoDo not daemonize.
107*86d7f5d3SJohn MarinoThe process will stay in the foreground, logging to standard error.
108*86d7f5d3SJohn Marino.It Fl m Ar maxsessions
109*86d7f5d3SJohn MarinoMaximum number of concurrent FTP sessions.
110*86d7f5d3SJohn MarinoWhen the proxy reaches this limit, new connections are denied.
111*86d7f5d3SJohn MarinoThe default is 100 sessions.
112*86d7f5d3SJohn MarinoThe limit can be lowered to a minimum of 1, or raised to a maximum of 500.
113*86d7f5d3SJohn Marino.It Fl P Ar port
114*86d7f5d3SJohn MarinoFixed server port.
115*86d7f5d3SJohn MarinoOnly used in combination with
116*86d7f5d3SJohn Marino.Fl R .
117*86d7f5d3SJohn MarinoThe default is port 21.
118*86d7f5d3SJohn Marino.It Fl p Ar port
119*86d7f5d3SJohn MarinoPort where the proxy will listen for redirected connections.
120*86d7f5d3SJohn MarinoThe default is port 8021.
121*86d7f5d3SJohn Marino.It Fl q Ar queue
122*86d7f5d3SJohn MarinoCreate rules with queue
123*86d7f5d3SJohn Marino.Ar queue
124*86d7f5d3SJohn Marinoappended, so that data connections can be queued.
125*86d7f5d3SJohn Marino.It Fl R Ar address
126*86d7f5d3SJohn MarinoFixed server address, also known as reverse mode.
127*86d7f5d3SJohn MarinoThe proxy will always connect to the same server, regardless of
128*86d7f5d3SJohn Marinowhere the client wanted to connect to (before it was redirected).
129*86d7f5d3SJohn MarinoUse this option to proxy for a server behind NAT, or to forward all
130*86d7f5d3SJohn Marinoconnections to another proxy.
131*86d7f5d3SJohn Marino.It Fl r
132*86d7f5d3SJohn MarinoRewrite sourceport to 20 in active mode to suit ancient clients that insist
133*86d7f5d3SJohn Marinoon this RFC property.
134*86d7f5d3SJohn Marino.It Fl T Ar tag
135*86d7f5d3SJohn MarinoAutomatically tag packets passing through the
136*86d7f5d3SJohn Marino.Xr pf 4
137*86d7f5d3SJohn Marinorule with the name supplied.
138*86d7f5d3SJohn Marino.It Fl t Ar timeout
139*86d7f5d3SJohn MarinoNumber of seconds that the control connection can be idle, before the
140*86d7f5d3SJohn Marinoproxy will disconnect.
141*86d7f5d3SJohn MarinoThe maximum is 86400 seconds, which is also the default.
142*86d7f5d3SJohn MarinoDo not set this too low, because the control connection is usually
143*86d7f5d3SJohn Marinoidle when large data transfers are taking place.
144*86d7f5d3SJohn Marino.It Fl v
145*86d7f5d3SJohn MarinoSet the 'log' flag on pf rules committed by
146*86d7f5d3SJohn Marino.Nm .
147*86d7f5d3SJohn MarinoUse twice to set the 'log-all' flag.
148*86d7f5d3SJohn MarinoThe pf rules do not log by default.
149*86d7f5d3SJohn Marino.El
150*86d7f5d3SJohn Marino.Sh CONFIGURATION
151*86d7f5d3SJohn MarinoTo make use of the proxy,
152*86d7f5d3SJohn Marino.Xr pf.conf 5
153*86d7f5d3SJohn Marinoneeds the following rules.
154*86d7f5d3SJohn MarinoAll anchors are mandatory.
155*86d7f5d3SJohn MarinoAdjust the rules as needed.
156*86d7f5d3SJohn Marino.Pp
157*86d7f5d3SJohn MarinoIn the NAT section:
158*86d7f5d3SJohn Marino.Bd -literal -offset 2n
159*86d7f5d3SJohn Marinonat-anchor "ftp-proxy/*"
160*86d7f5d3SJohn Marinordr-anchor "ftp-proxy/*"
161*86d7f5d3SJohn Marinordr pass on $int_if proto tcp from $lan to any port 21 -> \e
162*86d7f5d3SJohn Marino    127.0.0.1 port 8021
163*86d7f5d3SJohn Marino.Ed
164*86d7f5d3SJohn Marino.Pp
165*86d7f5d3SJohn MarinoIn the rule section:
166*86d7f5d3SJohn Marino.Bd -literal -offset 2n
167*86d7f5d3SJohn Marinoanchor "ftp-proxy/*"
168*86d7f5d3SJohn Marinopass out proto tcp from $proxy to any port 21
169*86d7f5d3SJohn Marino.Ed
170*86d7f5d3SJohn Marino.Sh SEE ALSO
171*86d7f5d3SJohn Marino.Xr ftp 1 ,
172*86d7f5d3SJohn Marino.Xr pf 4 ,
173*86d7f5d3SJohn Marino.Xr pf.conf 5
174*86d7f5d3SJohn Marino.Sh CAVEATS
175*86d7f5d3SJohn Marino.Xr pf 4
176*86d7f5d3SJohn Marinodoes not allow the ruleset to be modified if the system is running at a
177*86d7f5d3SJohn Marinosecurelevel
178*86d7f5d3SJohn Marino.\".Xr securelevel 7
179*86d7f5d3SJohn Marinohigher than 1.
180*86d7f5d3SJohn MarinoAt that level
181*86d7f5d3SJohn Marino.Nm
182*86d7f5d3SJohn Marinocannot add rules to the anchors and FTP data connections may get blocked.
183*86d7f5d3SJohn Marino.Pp
184*86d7f5d3SJohn MarinoNegotiated data connection ports below 1024 are not allowed.
185*86d7f5d3SJohn Marino.Pp
186*86d7f5d3SJohn MarinoThe negotiated IP address for active modes is ignored for security
187*86d7f5d3SJohn Marinoreasons.
188*86d7f5d3SJohn MarinoThis makes third party file transfers impossible.
189*86d7f5d3SJohn Marino.Pp
190*86d7f5d3SJohn Marino.Nm
191*86d7f5d3SJohn Marinochroots to "/var/empty" and changes to user "proxy" to drop privileges.
192