INETD(8) BSD System Manager's Manual INETD(8)NAMEinetd - internet ``super-server''
SYNOPSISinetd [-d] [-R rate] [-u port-list] [configuration file]
DESCRIPTION
The inetd program should be run at boot time by /etc/rc (see rc(8)). It
then listens for connections on certain internet sockets. When a connec-
tion is found on one of its sockets, it decides what service the socket
corresponds to, and invokes a program to service the request. The server
program is invoked with the service socket as its standard input, output
and error descriptors. After the program is finished, inetd continues to
listen on the socket (except in some cases which will be described be-
low). Essentially, inetd allows running one daemon to invoke several
others, reducing load on the system.
The options available for inetd:
-d Turns on debugging.
-R rate
Specifies the maximum number of times a service can be invoked in
one minute; the default is 1000.
-u port-list
For the internal UDP based services, the -u option specifies a
list of comma separated UDP service names or port numbers. If
one of the internal UDP services receives a packet from one of
these ports, that packet will be silently ignored (after a sys-
log(3) entry has been made). The service name ``internal'' is
shorthand for a list of all the internally implemented UDP ser-
vices, plus the ``systat'' and ``quotd'' services. This is the
default action if the -u option is not specified. A value of
``-'' can be used to allow the internal UDP services to respond
to all source ports.
Upon execution, inetd reads its configuration information from a configu-
ration file which, by default, is /etc/inetd.conf. This file contains a
list of service descriptions. Each service description must have an en-
try for each for each field separated by a tab or a space. Service de-
scriptions may be continued on multiple lines, the second and subsequent
lines must start with a tab or a space. Comments are denoted by a ``#''
at the beginning of a line.
By default, all service descriptions are assumed to be IP version 4 (un-
less the protocol field explicitly states otherwise). A line may contain
just one entry, specified as either ``ipv4'' or ``ipv6'', to change the
default IP version for successive service descriptions. Specifying
``ipv4'' means only IP version 4, and ``ipv6'' means both IP version 4
and IP version 6. Note that most applications will require some modifi-
cation to work with IP version 6 addresses.
The fields of a service description are as follows:
service name
socket type
protocol
wait/nowait
user[/sec]
server program
server program arguments
There are two types of services that inetd can start: standard and TCP-
MUX. A standard service has a well-known port assigned to it; it may be
a service that implements an official Internet standard or is a BSD-spe-
cific service. As described in RFC 1078, TCPMUX services are nonstandard
services that do not have a well-known port assigned to them. They are
invoked from inetd when a program connects to the ``tcpmux'' well-known
port and specifies the service name. This feature is useful for adding
locally-developed servers.
The service-name entry is the name of a valid service in the file
/etc/services. For ``internal'' services (discussed below), the service
name must be the official name of the service (that is, the first entry
in /etc/services). For TCPMUX services, the value of the service-name
field consists of the string ``tcpmux'' followed by a slash and the lo-
cally-chosen service name. The service names listed in /etc/services and
the name ``help'' are reserved. Try to choose unique names for your TCP-
MUX services by prefixing them with your organization's name and suffix-
ing them with a version number.
The socket-type should be one of ``stream'', ``dgram'', ``raw'', ``rdm'',
or ``seqpacket'', depending on whether the socket is a stream, datagram,
raw, reliably delivered message, or sequenced packet socket. TCPMUX ser-
vices must use ``stream''.
The protocol must be a valid protocol as given in /etc/protocols. Exam-
ples might be ``tcp'' or ``udp''. TCPMUX services must use ``tcp''. The
protocol may have an ``4'' or ``6'' appended to it, e.g., ``tcp6'', to
explicitly state the version of IP that should be used. Specifying ``4''
means just IP version 4, and ``6'' means both IP version 4 and IP version
6.
The wait/nowait entry specifies whether the server that is invoked by in-
etd will take over the socket associated with the service access point,
and thus whether inetd should wait for the server to exit before listen-
ing for new service requests. Datagram servers must use ``wait'', as
they are always invoked with the original datagram socket bound to the
specified service address. These servers must read at least one datagram
from the socket before exiting. If a datagram server connects to its
peer, freeing the socket so inetd can received further messages on the
socket, it is said to be a ``multi-threaded'' server; it should read one
datagram from the socket and create a new socket connected to the peer.
It should fork, and the parent should then exit to allow inetd to check
for new service requests to spawn new servers. Datagram servers which
process all incoming datagrams on a socket and eventually time out are
said to be ``single-threaded''. Comsat(8), (biff(1)) and talkd(8) are
both examples of the latter type of datagram server. Tftpd(8) is an ex-
ample of a multi-threaded datagram server.
Servers using stream sockets generally are multi-threaded and use the
``nowait'' entry. Connection requests for these services are accepted by
inetd, and the server is given only the newly-accepted socket connected
to a client of the service. Most stream-based services operate in this
manner. Stream-based servers that use ``wait'' are started with the lis-
tening service socket, and must accept at least one connection request
before exiting. Such a server would normally accept and process incoming
connection requests until a timeout. TCPMUX services must use
``nowait''.
The user[/sec] entry should contain the user name of the user as whom the
server should run. This allows for servers to be given less permission
than root. The optional /sec part can be used to specify IPSEC informa-
tion. The information is specified as a string of pairs of characters.
The first character of the pair specifies the type of information, and
the second specifies the level. The type may be 'A', 'E' or 'T', for au-
thentication, transport mode, or tunnel mode. The level may be 'd' (de-
fault), 'u' (use), 'r' (require), 'q' (unique) or 'n' (never), or a nu-
meric value between -1 and 3.
NOTE: The format for specifying security information is in flux, and will
change in future releases.
The server-program entry should contain the pathname of the program which
is to be executed by inetd when a request is found on its socket. If
inetd provides this service internally, this entry should be
``internal''.
The server program arguments should be just as arguments normally are,
starting with argv[0], which is the name of the program. If the service
is provided internally, the word ``internal'' should take the place of
this entry.
The inetd program provides several ``trivial'' services internally by use
of routines within itself. These services are ``echo'', ``discard'',
``chargen'' (character generator), ``daytime'' (human readable time), and
``time'' (machine readable time, in the form of the number of seconds
since midnight, January 1, 1900). All of these services are tcp based.
For details of these services, consult the appropriate RFC from the Net-
work Information Center.
The inetd program rereads its configuration file when it receives a
hangup signal, SIGHUP. Services may be added, deleted or modified when
the configuration file is reread.
TCPMUX
RFC 1078 describes the TCPMUX protocol: ``A TCP client connects to a for-
eign host on TCP port 1. It sends the service name followed by a car-
riage-return line-feed <CRLF>. The service name is never case sensitive.
The server replies with a single character indicating positive (+) or
negative (-) acknowledgment, immediately followed by an optional message
of explanation, terminated with a <CRLF>. If the reply was positive, the
selected protocol begins; otherwise the connection is closed.'' The pro-
gram is passed the TCP connection as file descriptors 0 and 1.
If the TCPMUX service name begins with a ``+'', inetd returns the posi-
tive reply for the program. This allows you to invoke programs that use
stdin/stdout without putting any special server code in them.
The special service name ``help'' causes inetd to list TCPMUX services in
inetd.conf.
IPsec
To support IPsec policy settings for each socket, a special form of the
comment line, starting with ``#@'', is used as a policy specifier. The
content of the comment line will be treated as a IPsec policy string, as
described in ipsec_set_policy(3). Multiple IPsec policy strings may be
specified by using a semicolon as a separator. If conflicting policy
strings are found in a single line, the last string will take effect. A
#@ line affects all of the following lines in inetd.conf, but the IPsec
policy can be reset by using a comment line containing only #@ (with no
policy string).
If an invalid IPsec policy string appears in inetd.conf, inetd logs an
error message using syslog(3) and terminates itself.
EXAMPLES
Here are several example service entries for the various types of ser-
vices:
ftp stream tcp nowait root /usr/libexec/ftpd ftpd -l
ntalk dgram udp wait root /usr/libexec/ntalkd ntalkd
tcpmux/+date stream tcp nowait guest /bin/date date
tcpmux/phonebook stream tcp nowait guest /usr/local/bin/phonebook phonebook
ERROR MESSAGES
The inetd server logs error messages using syslog(3). Important error
messages and their explanations are:
service/protocol server failing (looping), service terminated.
The number of requests for the specified service in the past minute ex-
ceeded the limit. The limit exists to prevent a broken program or a mali-
cious user from swamping the system. This message may occur for several
reasons: 1) there are lots of hosts requesting the service within a short
time period, 2) a 'broken' client program is requesting the service too
frequently, 3) a malicious user is running a program to invoke the ser-
vice in a 'denial of service' attack, or 4) the invoked service program
has an error that causes clients to retry quickly. Use the -R option, as
described above, to change the rate limit. Once the limit is reached,
the service will be re-enabled automatically in 10 minutes.
service/protocol: No such user 'user', service ignored
service/protocol: getpwnam: user: No such user
No entry for user exists in the passwd file. The first message occurs
when inetd (re)reads the configuration file. The second message occurs
when the service is invoked.
service: can't set uid number
service: can't set gid number
The user or group ID for the entry's user is invalid.
SEE ALSOsetusercontext(3), ipsec(4), comsat(8), fingerd(8), ftpd(8),
rexecd(8), rlogind(8), rshd(8), telnetd(8), tftpd(8)HISTORY
The inetd command appeared in 4.3BSD. TCPMUX is based on code and docu-
mentation by Mark Lottor.
4.4BSD June 1, 1994 4