1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
|
.\" $OpenBSD: ftp-proxy.8,v 1.4 2001/08/22 05:41:03 beck Exp $
.\"
.\" Copyright (c) 1996-2001
.\" Obtuse Systems Corporation, All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\" 3. Neither the name of the University nor the names of its contributors
.\" may be used to endorse or promote products derived from this software
.\" without specific prior written permission.
.\"
.\" THIS SOFTWARE IS PROVIDED BY OBTUSE SYSTEMS AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL OBTUSE OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.Dd Aug 17, 2001
.Dt FTP-PROXY 8
.Os
.Sh NAME
.Nm ftp-proxy
.Nd
Internet File Transfer Protocol proxy server.
.Sh SYNOPSIS
.Nm ftp-proxy
.Op Fl AnVwr
.Op Fl D Ar debuglevel
.Op Fl g Ar group
.Op Fl m Ar minport
.Op Fl M Ar maxport
.Op Fl t Ar timeout
.Op Fl u Ar user
.Sh DESCRIPTION
.Nm
is a proxy for the Internet file transfer protocol.
The proxy uses
.Xr pf 4
and expects to have the ftp control connection as described in
.Xr services 5
redirected to it via a pf rdr command.
.Pp
The options are as follows:
.Bl -tag -width Ds
.It Fl A
Permit only anonymous ftp connections. The proxy will allow connections
to log in to other sites as the user "ftp" or "anonymous" only. Any
attempt to log in as another user will be blocked by the proxy.
.It Fl g Ar groupname
specify the named group to drop group priviledges to, after doing pf lookups
which require root. By default
.Nm ftp-proxy
uses the default group of the user it drops priviledge to.
.It Fl u Ar username
specify the named user to drop priviledge to, after doing pf lookups
which require root priviledge. By default
.Nm ftp-proxy
does not drop priviledge and runs as root.
.Pp
Running as root means that the source of data connections the proxy makes
for PORT and EPRT will be the RFC mandated port 20. When
running as a non-root user the source of the data connections from
.Nm ftp-proxy
will be chosen randomly from the range
.Nm minport
to
.Nm maxport
as described below.
.It Fl n
Activate network address translation mode. in this mode, the proxy
will not attempt to proxy passive mode (PASV or EPSV) data connections,
for this to work on a gateway you will need to be forwarding packets
and doing network address translation to allow the outbound passive
connections from the client to reach the server. See
.Xr nat.conf 5
for more details on nat. The proxy only ignores passive mode data connections
when using this flag, it will still proxy PORT and EPRT mode data connections.
Without this flag,
.Nm ftp-proxy
does not require any ip forwarding or NAT beyond the rdr necessary to
capture the ftp control connection.
.It Fl V
Be verbose. With this option the proxy logs the control commands
sent by clients and the replies send by the servers to
.Xr syslog 8
.It Fl w
Use the tcp wrapper access control library
.Xr hosts_access 3
allowing connections to be allowed or denied based on the tcp wrapper's
.Xr hosts.allow 5
and
.Xr hosts.deny 5
files. The proxy does libwrap operations after determining the destination
of the captured control connection, so that tcp wrapper rules may
be written based on the destination as well as the source of ftp connections.
.It Fl r
Use reverse host (reverse DNS) lookups for logging and libwrap use
By default the proxy does not look up hostnames for libwrap or logging
purposes.
.It Fl m Ar minport
specify the lower end of the port range the proxy will use for all
data connections it establishes. The default is
.Ev IPPORT_HIFIRSTAUTO
defined in <netinet/in.h>
as 49152.
.It Fl M Ar maxport
specify the upper end of the port range the proxy will use for the
data connections it establishes. The default is
.Ev IPPORT_HILASTAUTO
defined in <netinet/in.h>
as 65535.
.It Fl t Ar timeout
specifies a timeout, in seconds. The proxy will exit
and close open connections if it sees no data the duration of
the timeout. The default is 0, which means the proxy will not time out.
.It Fl D Ar debuglevel
specify a debug level, where the proxy emits verbose debug output
into
.Xr syslog 8
at level LOG_DEBUG. meaningful values of debuglevel are 0-3, where 0
is no debug output and 3 is lots of debug output, the default being 0.
.El
.Pp
ftp-proxy is run from
.Xr inetd 8
and requires that ftp connections are redirected to it using an rdr
rule. A typical way to do this would be to use a rule such as
.Pp
rdr on xl0 from any to any port 21 -> 127.0.0.1 port 8081
.Pp
In
.Xr nat.conf 5
(this assumes you are on a gateway where xl0 would be your inside interface).
You would then need to configure
.Xr inetd 8
to run ftp-proxy on the port from above
using
.Pp
8081 stream tcp nowait root /usr/libexec/ftp-proxy ftp-proxy
.Pp
in
.Xr inetd.conf 5 .
.Sh SEE ALSO
.Xr ftp 1 ,
.Xr host.allow 5 ,
.Xr host.deny 5 ,
.Xr nat.conf 5 ,
.Xr pfctl 8 ,
.Xr syslogd 8
.Sh BUGS
.Pp
Extended Passive mode (EPSV) is not supported by the proxy and will
not work unless the proxy is run in network address translation mode.
When not in network address translation mode, the proxy returns an error
to the client, hopefully forcing the client to revert to Passive mode (PASV)
which is supported. EPSV will work in network address translation mode,
assuming a
.Xr nat.conf 5
setup which allows the EPSV connections through to their destinations.
.Pp
IPv6 is not yet supported. This will have to wait for corresponding
support from
.Xr pf 4 .
|