Deleted Added
sdiff udiff text old ( 51495 ) new ( 56977 )
full compact
1.TH HOSTS_ACCESS 5
2.SH NAME
3hosts_access \- format of host access control files
4.SH DESCRIPTION
5This manual page describes a simple access control language that is
6based on client (host name/address, user name), and server (process
7name, host name/address) patterns. Examples are given at the end. The
8impatient reader is encouraged to skip to the EXAMPLES section for a
9quick introduction.
10.PP
11An extended version of the access control language is described in the
12\fIhosts_options\fR(5) document. The extensions are turned on at
13program build time by building with -DPROCESS_OPTIONS.
14.PP
15In the following text, \fIdaemon\fR is the the process name of a
16network daemon process, and \fIclient\fR is the name and/or address of
17a host requesting service. Network daemon process names are specified
18in the inetd configuration file.
19.SH ACCESS CONTROL FILES
20The access control software consults two files. The search stops
21at the first match:
22.IP \(bu
23Access will be granted when a (daemon,client) pair matches an entry in
24the \fI/etc/hosts.allow\fR file.
25.IP \(bu
26Otherwise, access will be denied when a (daemon,client) pair matches an
27entry in the \fI/etc/hosts.deny\fR file.
28.IP \(bu
29Otherwise, access will be granted.
30.PP
31A non-existing access control file is treated as if it were an empty
32file. Thus, access control can be turned off by providing no access
33control files.
34.SH ACCESS CONTROL RULES
35Each access control file consists of zero or more lines of text. These
36lines are processed in order of appearance. The search terminates when a
37match is found.
38.IP \(bu
39A newline character is ignored when it is preceded by a backslash
40character. This permits you to break up long lines so that they are
41easier to edit.
42.IP \(bu
43Blank lines or lines that begin with a `#\' character are ignored.
44This permits you to insert comments and whitespace so that the tables
45are easier to read.
46.IP \(bu
47All other lines should satisfy the following format, things between []
48being optional:
49.sp
50.ti +3
51daemon_list : client_list [ : shell_command ]
52.PP
53\fIdaemon_list\fR is a list of one or more daemon process names
54(argv[0] values) or wildcards (see below).
55.PP
56\fIclient_list\fR is a list
57of one or more host names, host addresses, patterns or wildcards (see
58below) that will be matched against the client host name or address.
59.PP
60The more complex forms \fIdaemon@host\fR and \fIuser@host\fR are
61explained in the sections on server endpoint patterns and on client
62username lookups, respectively.
63.PP
64List elements should be separated by blanks and/or commas.
65.PP
66With the exception of NIS (YP) netgroup lookups, all access control
67checks are case insensitive.
68.ne 4
69.SH PATTERNS
70The access control language implements the following patterns:
71.IP \(bu
72A string that begins with a `.\' character. A host name is matched if
73the last components of its name match the specified pattern. For
74example, the pattern `.tue.nl\' matches the host name
75`wzv.win.tue.nl\'.
76.IP \(bu
77A string that ends with a `.\' character. A host address is matched if
78its first numeric fields match the given string. For example, the
79pattern `131.155.\' matches the address of (almost) every host on the
80Eind\%hoven University network (131.155.x.x).
81.IP \(bu
82A string that begins with an `@\' character is treated as an NIS
83(formerly YP) netgroup name. A host name is matched if it is a host
84member of the specified netgroup. Netgroup matches are not supported
85for daemon process names or for client user names.
86.IP \(bu
87An expression of the form `n.n.n.n/m.m.m.m\' is interpreted as a
88`net/mask\' pair. A host address is matched if `net\' is equal to the
89bitwise AND of the address and the `mask\'. For example, the net/mask
90pattern `131.155.72.0/255.255.254.0\' matches every address in the
91range `131.155.72.0\' through `131.155.73.255\'.
92.IP \(bu
93An expression of the form `[n:n:n:n:n:n:n:n]/m\' is interpreted as a
94`[net]/prefixlen\' pair. A IPv6 host address is matched if
95`prefixlen\' bits of `net\' is equal to the `prefixlen\' bits of the
96address. For example, the [net]/prefixlen pattern
97`[3ffe:505:2:1::]/64\' matches every address in the range
98`3ffe:505:2:1::\' through `3ffe:505:2:1:ffff:ffff:ffff:ffff\'.
99.IP \(bu
100A string that begins with a `/\' character is treated as a file
101name. A host name or address is matched if it matches any host name
102or address pattern listed in the named file. The file format is
103zero or more lines with zero or more host name or address patterns
104separated by whitespace. A file name pattern can be used anywhere
105a host name or address pattern can be used.
106.SH WILDCARDS
107The access control language supports explicit wildcards:
108.IP ALL
109The universal wildcard, always matches.
110.IP LOCAL
111Matches any host whose name does not contain a dot character.
112.IP UNKNOWN
113Matches any user whose name is unknown, and matches any host whose name
114\fIor\fR address are unknown. This pattern should be used with care:
115host names may be unavailable due to temporary name server problems. A
116network address will be unavailable when the software cannot figure out
117what type of network it is talking to.
118.IP KNOWN
119Matches any user whose name is known, and matches any host whose name
120\fIand\fR address are known. This pattern should be used with care:
121host names may be unavailable due to temporary name server problems. A
122network address will be unavailable when the software cannot figure out
123what type of network it is talking to.
124.IP PARANOID
125Matches any host whose name does not match its address. When tcpd is
126built with -DPARANOID (default mode), it drops requests from such
127clients even before looking at the access control tables. Build
128without -DPARANOID when you want more control over such requests.
129.ne 6
130.SH OPERATORS
131.IP EXCEPT
132Intended use is of the form: `list_1 EXCEPT list_2\'; this construct
133matches anything that matches \fIlist_1\fR unless it matches
134\fIlist_2\fR. The EXCEPT operator can be used in daemon_lists and in
135client_lists. The EXCEPT operator can be nested: if the control
136language would permit the use of parentheses, `a EXCEPT b EXCEPT c\'
137would parse as `(a EXCEPT (b EXCEPT c))\'.
138.br
139.ne 6
140.SH SHELL COMMANDS
141If the first-matched access control rule contains a shell command, that
142command is subjected to %<letter> substitutions (see next section).
143The result is executed by a \fI/bin/sh\fR child process with standard
144input, output and error connected to \fI/dev/null\fR. Specify an `&\'
145at the end of the command if you do not want to wait until it has
146completed.
147.PP
148Shell commands should not rely on the PATH setting of the inetd.
149Instead, they should use absolute path names, or they should begin with
150an explicit PATH=whatever statement.
151.PP
152The \fIhosts_options\fR(5) document describes an alternative language
153that uses the shell command field in a different and incompatible way.
154.SH % EXPANSIONS
155The following expansions are available within shell commands:
156.IP "%a (%A)"
157The client (server) host address.
158.IP %c
159Client information: user@host, user@address, a host name, or just an
160address, depending on how much information is available.
161.IP %d
162The daemon process name (argv[0] value).
163.IP "%h (%H)"
164The client (server) host name or address, if the host name is
165unavailable.
166.IP "%n (%N)"
167The client (server) host name (or "unknown" or "paranoid").
168.IP %p
169The daemon process id.
170.IP %s
171Server information: daemon@host, daemon@address, or just a daemon name,
172depending on how much information is available.
173.IP %u
174The client user name (or "unknown").
175.IP %%
176Expands to a single `%\' character.
177.PP
178Characters in % expansions that may confuse the shell are replaced by
179underscores.
180.SH SERVER ENDPOINT PATTERNS
181In order to distinguish clients by the network address that they
182connect to, use patterns of the form:
183.sp
184.ti +3
185process_name@host_pattern : client_list ...
186.sp
187Patterns like these can be used when the machine has different internet
188addresses with different internet hostnames. Service providers can use
189this facility to offer FTP, GOPHER or WWW archives with internet names
190that may even belong to different organizations. See also the `twist'
191option in the hosts_options(5) document. Some systems (Solaris,
192FreeBSD) can have more than one internet address on one physical
193interface; with other systems you may have to resort to SLIP or PPP
194pseudo interfaces that live in a dedicated network address space.
195.sp
196The host_pattern obeys the same syntax rules as host names and
197addresses in client_list context. Usually, server endpoint information
198is available only with connection-oriented services.
199.SH CLIENT USERNAME LOOKUP
200When the client host supports the RFC 931 protocol or one of its
201descendants (TAP, IDENT, RFC 1413) the wrapper programs can retrieve
202additional information about the owner of a connection. Client username
203information, when available, is logged together with the client host
204name, and can be used to match patterns like:
205.PP
206.ti +3
207daemon_list : ... user_pattern@host_pattern ...
208.PP
209The daemon wrappers can be configured at compile time to perform
210rule-driven username lookups (default) or to always interrogate the
211client host. In the case of rule-driven username lookups, the above
212rule would cause username lookup only when both the \fIdaemon_list\fR
213and the \fIhost_pattern\fR match.
214.PP
215A user pattern has the same syntax as a daemon process pattern, so the
216same wildcards apply (netgroup membership is not supported). One
217should not get carried away with username lookups, though.
218.IP \(bu
219The client username information cannot be trusted when it is needed
220most, i.e. when the client system has been compromised. In general,
221ALL and (UN)KNOWN are the only user name patterns that make sense.
222.IP \(bu
223Username lookups are possible only with TCP-based services, and only
224when the client host runs a suitable daemon; in all other cases the
225result is "unknown".
226.IP \(bu
227A well-known UNIX kernel bug may cause loss of service when username
228lookups are blocked by a firewall. The wrapper README document
229describes a procedure to find out if your kernel has this bug.
230.IP \(bu
231Username lookups may cause noticeable delays for non-UNIX users. The
232default timeout for username lookups is 10 seconds: too short to cope
233with slow networks, but long enough to irritate PC users.
234.PP
235Selective username lookups can alleviate the last problem. For example,
236a rule like:
237.PP
238.ti +3
239daemon_list : @pcnetgroup ALL@ALL
240.PP
241would match members of the pc netgroup without doing username lookups,
242but would perform username lookups with all other systems.
243.SH DETECTING ADDRESS SPOOFING ATTACKS
244A flaw in the sequence number generator of many TCP/IP implementations
245allows intruders to easily impersonate trusted hosts and to break in
246via, for example, the remote shell service. The IDENT (RFC931 etc.)
247service can be used to detect such and other host address spoofing
248attacks.
249.PP
250Before accepting a client request, the wrappers can use the IDENT
251service to find out that the client did not send the request at all.
252When the client host provides IDENT service, a negative IDENT lookup
253result (the client matches `UNKNOWN@host') is strong evidence of a host
254spoofing attack.
255.PP
256A positive IDENT lookup result (the client matches `KNOWN@host') is
257less trustworthy. It is possible for an intruder to spoof both the
258client connection and the IDENT lookup, although doing so is much
259harder than spoofing just a client connection. It may also be that
260the client\'s IDENT server is lying.
261.PP
262Note: IDENT lookups don\'t work with UDP services.
263.SH EXAMPLES
264The language is flexible enough that different types of access control
265policy can be expressed with a minimum of fuss. Although the language
266uses two access control tables, the most common policies can be
267implemented with one of the tables being trivial or even empty.
268.PP
269When reading the examples below it is important to realize that the
270allow table is scanned before the deny table, that the search
271terminates when a match is found, and that access is granted when no
272match is found at all.
273.PP
274The examples use host and domain names. They can be improved by
275including address and/or network/netmask information, to reduce the
276impact of temporary name server lookup failures.
277.SH MOSTLY CLOSED
278In this case, access is denied by default. Only explicitly authorized
279hosts are permitted access.
280.PP
281The default policy (no access) is implemented with a trivial deny
282file:
283.PP
284.ne 2
285/etc/hosts.deny:
286.in +3
287ALL: ALL
288.PP
289This denies all service to all hosts, unless they are permitted access
290by entries in the allow file.
291.PP
292The explicitly authorized hosts are listed in the allow file.
293For example:
294.PP
295.ne 2
296/etc/hosts.allow:
297.in +3
298ALL: LOCAL @some_netgroup
299.br
300ALL: .foobar.edu EXCEPT terminalserver.foobar.edu
301.PP
302The first rule permits access from hosts in the local domain (no `.\'
303in the host name) and from members of the \fIsome_netgroup\fP
304netgroup. The second rule permits access from all hosts in the
305\fIfoobar.edu\fP domain (notice the leading dot), with the exception of
306\fIterminalserver.foobar.edu\fP.
307.SH MOSTLY OPEN
308Here, access is granted by default; only explicitly specified hosts are
309refused service.
310.PP
311The default policy (access granted) makes the allow file redundant so
312that it can be omitted. The explicitly non-authorized hosts are listed
313in the deny file. For example:
314.PP
315/etc/hosts.deny:
316.in +3
317ALL: some.host.name, .some.domain
318.br
319ALL EXCEPT in.fingerd: other.host.name, .other.domain
320.PP
321The first rule denies some hosts and domains all services; the second
322rule still permits finger requests from other hosts and domains.
323.SH BOOBY TRAPS
324The next example permits tftp requests from hosts in the local domain
325(notice the leading dot). Requests from any other hosts are denied.
326Instead of the requested file, a finger probe is sent to the offending
327host. The result is mailed to the superuser.
328.PP
329.ne 2
330/etc/hosts.allow:
331.in +3
332.nf
333in.tftpd: LOCAL, .my.domain
334.PP
335.ne 2
336/etc/hosts.deny:
337.in +3
338.nf
339in.tftpd: ALL: (/some/where/safe_finger -l @%h | \\
340 /usr/ucb/mail -s %d-%h root) &
341.fi
342.PP
343The safe_finger command is intended for use in back-fingering and should be
344installed in a suitable place. It limits possible damage from data sent
345by the remote finger server. It gives better protection than the
346standard finger command.
347.PP
348The expansion of the %h (client host) and %d (service name) sequences
349is described in the section on shell commands.
350.PP
351Warning: do not booby-trap your finger daemon, unless you are prepared
352for infinite finger loops.
353.PP
354On network firewall systems this trick can be carried even further.
355The typical network firewall only provides a limited set of services to
356the outer world. All other services can be "bugged" just like the above
357tftp example. The result is an excellent early-warning system.
358.br
359.ne 4
360.SH DIAGNOSTICS
361An error is reported when a syntax error is found in a host access
362control rule; when the length of an access control rule exceeds the
363capacity of an internal buffer; when an access control rule is not
364terminated by a newline character; when the result of %<letter>
365expansion would overflow an internal buffer; when a system call fails
366that shouldn\'t. All problems are reported via the syslog daemon.
367.SH IMPLEMENTATION NOTES
368Some operating systems are distributed with TCP Wrappers as part of the
369base system. It is common for such systems to build wrapping functionality
370into networking utilities. Notably, some systems offer an \fIinetd\fR(8)
371which does not require the use of the \fItcpd\fR(8). Check your system's
372documentation for details.
373.SH FILES
374.na
375.nf
376/etc/hosts.allow, (daemon,client) pairs that are granted access.
377/etc/hosts.deny, (daemon,client) pairs that are denied access.
378.ad
379.fi
380.SH SEE ALSO
381.nf
382tcpd(8) tcp/ip daemon wrapper program.
383tcpdchk(8), tcpdmatch(8), test programs.
384.SH BUGS
385If a name server lookup times out, the host name will not be available
386to the access control software, even though the host is registered.
387.PP
388Domain name server lookups are case insensitive; NIS (formerly YP)
389netgroup lookups are case sensitive.
390.SH AUTHOR
391.na
392.nf
393Wietse Venema (wietse@wzv.win.tue.nl)
394Department of Mathematics and Computing Science
395Eindhoven University of Technology
396Den Dolech 2, P.O. Box 513,
3975600 MB Eindhoven, The Netherlands
398\" @(#) hosts_access.5 1.20 95/01/30 19:51:46
399\" $FreeBSD: head/contrib/tcp_wrappers/hosts_access.5 56977 2000-02-03 10:27:03Z shin $