Various changes. Add configuration grammar to help text. Change to
[fwd] / fw.1
CommitLineData
10a454ad 1.\" -*-nroff-*-
2.ie t .ds o \(bu
3.el .ds o o
4.de hP
5.IP
6\h'-\w'\fB\\$1\ \fP'u'\fB\\$1\ \fP\c
7..
8.TH fw 1 "1 July 1999" fw
9.SH NAME
10fw \- port forwarder
11.SH SYNOPSIS
12.B fw
13.RB [ \-db ]
14.RB [ \-f
15.IR file ]
16.IR config-stmt ...
17.SH DESCRIPTION
18The
19.B fw
20program is a simple port forwarder. It supports a number of features
21the author hasn't found in similar programs:
22.TP
23.I "Connection logging"
24Each connection attempt to the forwarder is logged, giving the time of
25the connection, the DNS-resolved hostname (if available), and the user
26name resulting from an RFC931 lookup. These lookups are done
27asynchronously to the main forwarder's operation.
28.TP
29.I "Access control"
30Each forwarded port may have an access control list attached to it.
31Only authorized hosts are allowed to connect. Access control checks are
32performed by quick checks on the client's IP address.
33.TP
34.I "Nonblocking single-process design"
35The internal structure of the server is completely nonblocking. The
36connections don't block; the reading and writing don't block; the name
37lookups don't block. This is all done in a single process, with the
38single exception of the DNS resolver.
39.SS "Command line options"
40The
41.B fw
42program understands a few simple command line options:
43.TP
44.B "\-h, \-\-help"
45Displays a screen of help text on standard output and exits
46successfully.
47.TP
48.B "\-v, \-\-version"
49Writes the version number to standard output and exits successfully.
50.TP
51.B "\-u, \-\-usage"
52Writes a terse usage summary to standard output and exits successfully.
53.TP
54.BI "\-f, \-\-file=" file
55Read configuration information from
56.IR file .
57.TP
58.B "\-d, \-\-dump"
59Writes a dump of the final configuration to standard output and exits
60successfully.
61.TP
62.B "\-b, \-\-background, \-\-fork"
63Forks into the background after reading the configuration and
64initializing properly.
65.PP
66Any further command line arguments are interpreted as configuration
67lines to be read. Configuration supplied in command line arguments has
68precisely the same syntax as configuration in files. If there are no
69configurmation statements on the command line, and no
70.B \-f
71options were supplied, configuration is read from standard input, if
72stdin is not a terminal.
73.SS "Configuration language"
74The forwarder understands a simple free-form configuration language,
75described by the following BNF-like grammar:
76.PP
77.ll +20
78.I config
79::=
80.IR stmt ...
81.br
82.I stmt
83::=
84.I fwd-stmt
85|
86.I acl-stmt
87.br
88.I fwd-stmt
89::=
90.B forward
91.RB [ port ]
92.I port
93.RB [ to ]
94.I addr
95.RB [ : ]
96.I port
97.RI [ fwd-attr ]
98.RB [ ; ]
99.br
100.I fwd-attr
101::=
102.B {
103.IR acl-stmt ...
104.B }
105.br
106.I acl-stmt
107::=
108.RB ( allow
109|
110.BR deny )
111.RB [ from ]
112.I addr
113.RB [ /
114.IR mask ]
115.RB [ ; ]
116.ll -20
117.PP
118In the above, a
119.I port
120may be a port number or service name defined in
121.BR /etc/services ;
122an
123.I addr
124may be a hostname or an IP address in dotted-quad notation; a
125.I mask
126may be either a netmask in dotted-quad notation or the integer number of
127set bits in the netmask (e.g.,
128.B /24
129means the same as
130.B /255.255.255.0
131as a netmask).
132.PP
133A forwarding statement makes
134.B fw
135listen on the first-named port and open connections to the given address
136and port when it
137.PP
138ACL statements within a brace enclosed attribute list attached to a
139forwarding statement apply only to that particular port; ACL statements
140outside the scope of a forwarding statement contribute to a
141.IR "global ACL" .
142When an incoming connection is detected, it is first matched against
143each rule in the port's local ACL in turn. If there's no match there,
144it's then looked up in the global ACL. If that doesn't match either,
145the connection is either refused or accepted, whichever is the opposite
146of the last rule tried. If there are no rules, all connections are
147allowed since this is more useful than denying all connections.
148.PP
149Comments may be included in a configuration file. They are introduced
150by a
151.RB ` # '
152character, and continue until the end of the line. When reading
153configuration from the command line, each argument is considered to be a
154separate line.
155.SS "Logging"
156The
157.B fw
158program logs each incoming connection. Since the log entry is made
159after the connection is established (since it needs to perform DNS and
160RFC931 lookups), it includes the actual time of the connection in the
161message body.
162.PP
163If the server is run in the foreground (i.e., the
164.B \-b
165flag isn't specified) log messages are sent to standard error. If the
166server is in the background, log messages are sent to the system log
167service (see
168.BR syslogd (8))
169with facility
170.B LOG_DAEMON
171and level
172.BR LOG_NOTICE .
173.SS "The DNS resolver"
174The background resolver works by creating child resolver processes.
175There's a fixed limit of 10 concurrent resolvers: resolution jobs are
176queued until a resolver becomes free. Resolver processes persist for
177multiple resolution jobs, although they are killed if they're idle for
178more than a minute.
179.PP
180It's unlikely that the resolver's use of processes will become a problem
181even for fairly heavily loaded servers.
182.SH "BUGS"
183I don't know of any bugs at all in
184.BR fw .
185If there are any, please let me know so I can fix them. Provide the
186version number from
187.BR "fw \-\-version" ,
188your operating system name and version, and complete descriptions of
189what you did to cause the bug and what
190.B fw
191did wrong at that point.
192.PP
193I'm particularly concerned about security-related bugs. If you find
194any, please let me know
195.I really
196quickly. I've taken some care to avoid security holes in
197.B fw
198but if there are any I've missed, I want to zap them as quickly as I
199can.
200.PP
201Things which would be nice, but that I haven't done yet, are:
202.hP \*o
203Optionally notice connections from privileged ports and bind the
204forwarding socket to a local privileged port.
205.SH "AUTHOR"
206Mark Wooding, <mdw@nsict.org>