1 .\" Copyright (c) 1985, 1991, 1993, 1994
2 .\" The Regents of the University of California. All rights reserved.
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\" notice, this list of conditions and the following disclaimer.
9 .\" 2. Redistributions in binary form must reproduce the above copyright
10 .\" notice, this list of conditions and the following disclaimer in the
11 .\" documentation and/or other materials provided with the distribution.
12 .\" 4. Neither the name of the University nor the names of its contributors
13 .\" may be used to endorse or promote products derived from this software
14 .\" without specific prior written permission.
16 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
17 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
20 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 .\" from: @(#)inetd.8 8.3 (Berkeley) 4/13/94
46 .Op Fl a Ar address | hostname
50 .Op Ar configuration file
54 utility should be run at boot time by
58 It then listens for connections on certain
60 When a connection is found on one
61 of its sockets, it decides what service the socket
62 corresponds to, and invokes a program to service the request.
63 The server program is invoked with the service socket
64 as its standard input, output and error descriptors.
68 continues to listen on the socket (except in some cases which
69 will be described below).
72 allows running one daemon to invoke several others,
73 reducing load on the system.
75 The following options are available:
76 .Bl -tag -width indent
80 Turn on logging of successful connections.
82 Turn on TCP Wrapping for external services.
84 .Sx "IMPLEMENTATION NOTES"
85 section for more information on TCP Wrappers support.
87 Turn on TCP Wrapping for internal services which are built in to
90 Specify the default maximum number of
91 simultaneous invocations of each service;
92 the default is unlimited.
93 May be overridden on a per-service basis with the "max-child"
96 Specify the default maximum number of times a service can be invoked
97 from a single IP address in one minute; the default is unlimited.
98 May be overridden on a per-service basis with the
99 "max-connections-per-ip-per-minute" parameter.
101 Specify the maximum number of times a service can be invoked
102 in one minute; the default is 256.
103 A rate of 0 allows an unlimited number of invocations.
105 Specify the default maximum number of
106 simultaneous invocations of each service from a single IP address;
107 the default is unlimited.
108 May be overridden on a per-service basis with the "max-child-per-ip"
111 Specify one specific IP address to bind to.
112 Alternatively, a hostname can be specified,
113 in which case the IPv4 or IPv6 address
114 which corresponds to that hostname is used.
115 Usually a hostname is specified when
119 in which case the hostname corresponds to the
123 When hostname specification is used
124 and both IPv4 and IPv6 bindings are desired,
125 one entry with the appropriate
127 type for each binding
128 is required for each service in
129 .Pa /etc/inetd.conf .
131 a TCP-based service would need two entries,
138 See the explanation of the
143 Specify an alternate file in which to store the process ID.
148 reads its configuration information from a configuration
149 file which, by default, is
150 .Pa /etc/inetd.conf .
151 There must be an entry for each field of the configuration
152 file, with entries for each field separated by a tab or
154 Comments are denoted by a
158 There must be an entry for each field.
160 fields of the configuration file are as follows:
162 .Bd -unfilled -offset indent -compact
166 {wait|nowait}[/max-child[/max-connections-per-ip-per-minute[/max-child-per-ip]]]
167 user[:group][/login-class]
169 server program arguments
173 .Tn "ONC RPC" Ns -based
174 service, the entry would contain these fields:
176 .Bd -unfilled -offset indent -compact
180 user[:group][/login-class]
182 server program arguments
185 There are two types of services that
187 can start: standard and TCPMUX.
188 A standard service has a well-known port assigned to it;
189 it may be a service that implements an official Internet standard or is a
194 TCPMUX services are nonstandard services that do not have a
195 well-known port assigned to them.
196 They are invoked from
198 when a program connects to the
200 well-known port and specifies
202 This feature is useful for adding locally-developed servers.
203 TCPMUX requests are only accepted when the multiplexor service itself
204 is enabled, above and beyond and specific TCPMUX-based servers; see the
205 discussion of internal services below.
209 entry is the name of a valid service in
212 or the specification of a
214 domain socket (see below).
217 services (discussed below), the service
220 be the official name of the service (that is, the first entry in
221 .Pa /etc/services ) .
222 When used to specify an
223 .Tn "ONC RPC" Ns -based
224 service, this field is a valid RPC service name in
227 The part on the right of the
229 is the RPC version number.
231 can simply be a single numeric argument or a range of versions.
232 A range is bounded by the low version to the high version -
234 For TCPMUX services, the value of the
236 field consists of the string
238 followed by a slash and the
239 locally-chosen service name.
240 The service names listed in
245 Try to choose unique names for your TCPMUX services by prefixing them with
246 your organization's name and suffixing them with a version number.
257 depending on whether the socket is a stream, datagram, raw,
258 reliably delivered message, or sequenced packet socket.
259 TCPMUX services must use
264 must be a valid protocol or
270 both of which imply IPv4 for backward compatibility.
285 specify that the entry accepts both IPv4 and IPv6 connections
289 If it is desired that the service is reachable via T/TCP, one should
292 which implies IPv4 for backward compatibility.
295 specifies IPv4 only, while
300 specify that the entry accepts both IPv6 and IPv6 connections
305 are specified with the
310 One can use specify IPv4 and/or IPv6 with the 4, 6 or 46 suffix, for example
314 TCPMUX services must use
323 entry specifies whether the server that is invoked by
326 the socket associated with the service access point, and thus whether
328 should wait for the server to exit before listening for new service
330 Datagram servers must use
332 as they are always invoked with the original datagram socket bound
333 to the specified service address.
334 These servers must read at least one datagram from the socket
336 If a datagram server connects
337 to its peer, freeing the socket so
339 can receive further messages on the socket, it is said to be
343 it should read one datagram from the socket and create a new socket
344 connected to the peer.
345 It should fork, and the parent should then exit
348 to check for new service requests to spawn new servers.
349 Datagram servers which process all incoming datagrams
350 on a socket and eventually time out are said to be
351 .Dq single-threaded .
357 utilities are both examples of the latter type of
361 utility is an example of a multi-threaded datagram server.
363 Servers using stream sockets generally are multi-threaded and
367 Connection requests for these services are accepted by
369 and the server is given only the newly-accepted socket connected
370 to a client of the service.
371 Most stream-based services operate in this manner.
372 Stream-based servers that use
374 are started with the listening service socket, and must accept
375 at least one connection request before exiting.
376 Such a server would normally accept and process incoming connection
377 requests until a timeout.
378 TCPMUX services must use
381 The maximum number of outstanding child processes (or
385 service may be explicitly specified by appending a
387 followed by the number to the
391 (or if a value of zero is specified) there is no maximum.
393 once the maximum is reached, further connection attempts will be
394 queued up until an existing child process exits.
398 mode, although a value other than one (the
399 default) might not make sense in some cases.
400 You can also specify the maximum number of connections per minute
401 for a given IP address by appending
404 followed by the number to the maximum number of
405 outstanding child processes.
406 Once the maximum is reached, further
407 connections from this IP address will be dropped until the end of the
409 In addition, you can specify the maximum number of simultaneous
410 invocations of each service from a single IP address by appending a
412 followed by the number to the maximum number of outstanding child
414 Once the maximum is reached, further connections from this
415 IP address will be dropped.
419 entry should contain the user name of the user as whom the server
421 This allows for servers to be given less permission
427 allows to specify group name different
428 than default group for this user.
433 allows to specify login class different
440 entry should contain the pathname of the program which is to be
443 when a request is found on its socket.
446 provides this service internally, this entry should
451 .Em server program arguments
452 should be just as arguments
453 normally are, starting with argv[0], which is the name of
455 If the service is provided internally, the
457 of the service (and any arguments to it) or the word
459 should take the place of this entry.
461 Currently, the only internal service to take arguments is
463 Without options, the service will always return
464 .Dq ERROR\ : HIDDEN-USER .
465 The available arguments to this service that alter its behavior are:
466 .Bl -tag -width indent
476 option discussed below),
477 return this username instead of an error
479 for either socket credentials or the username.
483 return this username for every request.
484 This is primarily useful when running this service on a NAT machine.
487 the user's name to the ident requester,
489 username made up of random alphanumeric characters,
494 flag overrides not only the user names,
495 but also any fallback name,
501 .Ar sec Ns Op . Ns Ar usec
503 Specify a timeout for the service.
504 The default timeout is 10.0 seconds.
508 service, as per RFC 1413.
509 All the remaining flags apply only in this case.
511 Return numeric user IDs instead of usernames.
515 exists in the home directory of the identified user, report the username
516 found in that file instead of the real username.
517 If the username found in
519 is that of an existing user,
520 then the real username is reported.
523 flag is also given then the username in
525 is checked against existing user IDs instead.
529 but without the restriction that the username in
531 must not match an existing user.
535 exists in the home directory of the identified user, return
536 .Dq ERROR\ : HIDDEN-USER .
539 file which might exist.
543 instead of the name of the system as reported by
549 utility also provides several other
551 services internally by use of
552 routines within itself.
557 (character generator),
559 (human readable time), and
561 (machine readable time, in the form of the number of seconds since
562 midnight, January 1, 1900).
563 All of these services are available in
564 both TCP and UDP versions; the UDP versions will refuse service if the
565 request specifies a reply port corresponding to any internal service.
566 (This is done as a defense against looping attacks; the remote IP address
568 For details of these services, consult the
573 The TCPMUX-demultiplexing service is also implemented as an internal service.
574 For any TCPMUX-based service to function, the following line must be included
577 .Bd -literal -offset indent
578 tcpmux stream tcp nowait root internal
585 will log an entry to syslog each time a connection is accepted, noting the
586 service selected and the IP-number of the remote requester if available.
587 Unless otherwise specified in the configuration file,
588 and in the absence of the
600 utility rereads its configuration file when it receives a hangup signal,
602 Services may be added, deleted or modified when the configuration file
604 Except when started in debugging mode,
606 records its process ID in the file
607 .Pa /var/run/inetd.pid
608 to assist in reconfiguration.
609 .Sh IMPLEMENTATION NOTES
615 will wrap all services specified as
624 option is given, such
626 services will be wrapped.
627 If both options are given, wrapping for both
628 internal and external services will be enabled.
629 Either wrapping option
630 will cause failed connections to be logged to the
635 flag to the wrapping options will include successful connections in the
642 only wraps requests for a
644 service while no servers are available to service requests.
646 connection to such a service has been allowed,
649 over subsequent connections to the service until no more servers
650 are left listening for connection requests.
652 When wrapping is enabled, the
654 daemon is not required, as that functionality is builtin.
655 For more information on TCP Wrappers, see the relevant documentation
656 .Pq Xr hosts_access 5 .
657 When reading that document, keep in mind that
659 services have no associated daemon name.
660 Therefore, the service name
663 should be used as the daemon name for
668 describes the TCPMUX protocol:
669 ``A TCP client connects to a foreign host on TCP port 1.
671 service name followed by a carriage-return line-feed <CRLF>.
673 service name is never case sensitive.
674 The server replies with a
675 single character indicating positive (+) or negative (\-)
676 acknowledgment, immediately followed by an optional message of
677 explanation, terminated with a <CRLF>.
678 If the reply was positive,
679 the selected protocol begins; otherwise the connection is closed.''
680 The program is passed the TCP connection as file descriptors 0 and 1.
682 If the TCPMUX service name begins with a
685 returns the positive reply for the program.
686 This allows you to invoke programs that use stdin/stdout
687 without putting any special server code in them.
689 The special service name
693 to list TCPMUX services in
696 The implementation includes a tiny hack
697 to support IPsec policy settings for each socket.
698 A special form of comment line, starting with
700 is interpreted as a policy specifier.
703 will be used as an IPsec policy string,
705 .Xr ipsec_set_policy 3 .
707 policy specifier is applied to all the following lines in
709 until the next policy specifier.
710 An empty policy specifier resets the IPsec policy.
712 If an invalid IPsec policy specifier appears in
715 will provide an error message via the
717 interface and abort execution.
718 .Ss Ux Domain Sockets
719 In addition to running services on IP sockets,
724 To do this you specify a
738 The specification of the socket must be
739 an absolute path name,
740 optionally prefixed by an owner and mode
742 .Em :user:group:mode: .
745 .Dl ":news:daemon:220:/var/run/sock"
747 creates a socket owned
752 with permissions allowing only that user and group to connect.
753 The default owner is the user that
756 The default mode only allows the socket's owner to connect.
763 must change the ownership and permissions on the socket.
764 This can only be done securely if
765 the directory in which the socket is created
766 is writable only by root.
771 to create sockets in world writable directories,
776 or a similar directory.
778 Internal services may be run on
780 domain sockets, in the usual way.
782 the name of the internal service
784 the last component of the socket's pathname.
786 .Bl -tag -width /var/run/inetd.pid -compact
787 .It Pa /etc/inetd.conf
789 .It Pa /etc/netconfig
790 network configuration data base
792 translation of service names to RPC program numbers
794 translation of service names to port numbers
795 .It Pa /var/run/inetd.pid
796 the pid of the currently running
800 Here are several example service entries for the various types of services:
802 ftp stream tcp nowait root /usr/libexec/ftpd ftpd -l
803 ntalk dgram udp wait root /usr/libexec/ntalkd ntalkd
804 telnet stream tcp6 nowait root /usr/libexec/telnetd telnetd
805 shell stream tcp46 nowait root /usr/libexec/rshd rshd
806 tcpmux/+date stream tcp nowait guest /bin/date date
807 tcpmux/phonebook stream tcp nowait guest /usr/local/bin/phonebook phonebook
808 rstatd/1-3 dgram rpc/udp wait root /usr/libexec/rpc.rstatd rpc.rstatd
809 /var/run/echo stream unix nowait root internal
811 chargen stream tcp nowait root internal
818 logs error messages using
820 Important error messages and their explanations are:
824 .Ar service Ns / Ns Ar protocol
825 .No "server failing (looping), service terminated."
827 The number of requests for the specified service in the past minute
829 The limit exists to prevent a broken program
830 or a malicious user from swamping the system.
831 This message may occur for several reasons:
832 .Bl -enum -offset indent
834 There are many hosts requesting the service within a short time period.
836 A broken client program is requesting the service too frequently.
838 A malicious user is running a program to invoke the service in
839 a denial-of-service attack.
841 The invoked service program has an error that causes clients
848 as described above, to change the rate limit.
849 Once the limit is reached, the service will be
850 reenabled automatically in 10 minutes.
853 .Ar service Ns / Ns Ar protocol :
859 .Ar service Ns / Ns Ar protocol :
872 (re)reads the configuration file.
873 The second message occurs when the
886 The user or group ID for the entry's
890 .It "setsockopt(SO_PRIVSTATE): Operation not supported"
893 utility attempted to renounce the privileged state associated with a
894 socket but was unable to.
901 No entry was found for either
914 No entry was found for either
923 .Xr ipsec_set_policy 3 ,
925 .Xr hosts_options 5 ,
940 .%A Michael C. St. Johns
941 .%T Identification Protocol
949 TCPMUX is based on code and documentation by Mark Lottor.
952 based services is modeled after that
956 The IPsec hack was contributed by the KAME project in 1999.
959 TCP Wrappers support first appeared in