|
NAMEinetd —
internet “super-server”
SYNOPSIS
DESCRIPTIONTheinetd utility should be run at boot time by
/etc/rc (see
rc(8)). It
then listens for connections on certain internet sockets. When a connection 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 below). Essentially, inetd allows running
one daemon to invoke several others, reducing load on the system.
The following options are available:
Upon execution, service-name socket-type protocol {wait|nowait}[/max-child[/max-connections-per-ip-per-minute[/max-child-per-ip]]] user[:group][/login-class] server-program server-program-arguments To specify an ONC RPC-based service, the entry would contain these fields: service-name/version socket-type rpc/protocol {wait|nowait}[/max-child[/max-connections-per-ip-per-minute[/max-child-per-ip]]] user[:group][/login-class] server-program server-program-arguments There are two types of services that The service-name entry is the name of a valid service in the file /etc/services, or the specification of a UNIX domain socket (see below). For “internal” services (discussed below), the service name should be the official name of the service (that is, the first entry in /etc/services). When used to specify an ONC RPC-based service, this field is a valid RPC service name listed in the file /etc/rpc. The part on the right of the “/” is the RPC version number. This can simply be a single numeric argument or a range of versions. A range is bounded by the low version to the high version - “rusers/1-3”. For TCPMUX services, the value of the service-name field consists of the string “tcpmux” followed by a slash and the locally-chosen service name. The service names listed in /etc/services and the name “help” are reserved. Try to choose unique names for your TCPMUX services by prefixing them with your organization's name and suffixing 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 services must use “stream”. The protocol must be a valid protocol or
“unix”. Examples are “tcp” or
“udp”, both of which imply IPv4 for backward compatibility.
The names “tcp4” and “udp4” specify IPv4 only.
The names “tcp6” and “udp6” specify IPv6 only.
The names “tcp46” and “udp46” specify that the
entry accepts both IPv4 and IPv6 connections via a wildcard
The wait/nowait entry specifies whether the
server that is invoked by Servers using stream sockets generally are multi-threaded and use
the “nowait” entry. Connection requests for these services are
accepted by The maximum number of outstanding child processes (or “threads”) for a “nowait” service may be explicitly specified by appending a “/” followed by the number to the “nowait” keyword. Normally (or if a value of zero is specified) there is no maximum. Otherwise, once the maximum is reached, further connection attempts will be queued up until an existing child process exits. This also works in the case of “wait” mode, although a value other than one (the default) might not make sense in some cases. You can also specify the maximum number of connections per minute for a given IP address by appending a “/” followed by the number to the maximum number of outstanding child processes. Once the maximum is reached, further connections from this IP address will be dropped until the end of the minute. In addition, you can specify the maximum number of simultaneous invocations of each service from a single IP address by appending a “/” followed by the number to the maximum number of outstanding child processes. Once the maximum is reached, further connections from this IP address will be dropped. The user 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 group part separated by “:” allows a group name other than the default group for this user to be specified. The optional login-class part separated by “/” allows specification of a login class other than the default “daemon” login class. The server-program entry should contain the
pathname of the program which is to be executed by
The server-program-arguments entry lists the arguments to be passed to the server-program, starting with argv[0], which usually is the name of the program. If the service is provided internally, the service-name of the service (and any arguments to it) or the word “internal” should take the place of this entry. Currently, the only internal service to take arguments is “auth”. Without options, the service will always return “ERROR : HIDDEN-USER”. The available arguments to this service that alter its behavior are:
The The TCPMUX-demultiplexing service is also implemented as an internal service. For any TCPMUX-based service to function, the following line must be included in inetd.conf: tcpmux stream tcp nowait root internal When given the The IMPLEMENTATION NOTESTCP WrappersWhen given the-w option, inetd
will wrap all services specified as “stream nowait” or
“dgram” except for “internal” services. If the
-W option is given, such “internal”
services will be wrapped. If both options are given, wrapping for both
internal and external services will be enabled. Either wrapping option will
cause failed connections to be logged to the “auth” syslog
facility. Adding the -l flag to the wrapping options
will include successful connections in the logging to the “auth”
facility.
Note that When wrapping is enabled, the tcpd daemon is not required, as that functionality is builtin. For more information on TCP Wrappers, see the relevant documentation (hosts_access(5)). When reading that document, keep in mind that “internal” services have no associated daemon name. Therefore, the service name as specified in inetd.conf should be used as the daemon name for “internal” services. TCPMUXRFC 1078 describes the TCPMUX protocol: ``A TCP client connects to a foreign host on TCP port 1. It sends the service name followed by a carriage-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 program is passed the TCP connection as file descriptors 0 and 1.If the TCPMUX service name begins with a “+”,
The special service name “help” causes
IPsecThe implementation includes a tiny hack to support IPsec policy settings for each socket. A special form of comment line, starting with “#@ ”, is interpreted as a policy
specifier. Everything after the “#@ ”
will be used as an IPsec policy string, as described in
ipsec_set_policy(3).
Each policy specifier is applied to all the following lines in
inetd.conf until the next policy specifier. An empty
policy specifier resets the IPsec policy.
If an invalid IPsec policy specifier appears in
inetd.conf, UNIX Domain SocketsIn addition to running services on IP sockets,inetd can
also manage UNIX domain sockets. To do this you
specify a protocol of “unix” and specify the
UNIX domain socket as the
service-name. The service-type may be
“stream” or “dgram”. The specification of the
socket must be an absolute path name, optionally prefixed by an owner and mode
of the form :user:group:mode:. The specification:
:news:daemon:220:/var/run/sock creates a socket owned by user “news” in group
“daemon” with permissions allowing only that user and group to
connect. The default owner is the user that WARNING: while creating a
UNIX domain socket, Internal services may be run on UNIX domain sockets, in the usual way. In this case the name of the internal service is determined using the last component of the socket's pathname. For example, specifying a socket named /var/run/chargen would invoke the “chargen” service when a connection is received on that socket. FILES
EXAMPLESHere are several example service entries for the various types of services:# The first four launch the relevant daemon when a connection on a port # as defined by /etc/services is opened. ftp stream tcp nowait root /usr/libexec/ftpd ftpd -l ntalk dgram udp wait root /usr/libexec/ntalkd ntalkd telnet stream tcp6 nowait root /usr/libexec/telnetd telnetd shell stream tcp46 nowait root /usr/libexec/rshd rshd # Let the system respond to date requests via tcpmux tcpmux/+date stream tcp nowait guest /bin/date date # Let people access the system phonebook via tcpmux tcpmux/phonebook stream tcp nowait guest /usr/local/bin/phonebook phonebook # Make kernel statistics accessible rstatd/1-3 dgram rpc/udp wait root /usr/libexec/rpc.rstatd rpc.rstatd # Use netcat as a one-shot HTTP proxy with nc (from freebsd-tips fortune) http stream tcp nowait nobody /usr/bin/nc nc -N dest-ip 80 # Set up a unix socket at /var/run/echo that echo's back whatever is written # to it. /var/run/echo stream unix nowait root internal # Run chargen for IPsec Authentication Headers #@ ipsec ah/require chargen stream tcp nowait root internal #@ ERROR MESSAGESTheinetd server logs error messages using
syslog(3).
Important error messages and their explanations are:
SEE ALSOnc(1), ipsec_set_policy(3), hosts_access(5), hosts_options(5), login.conf(5), netconfig(5), passwd(5), rpc(5), services(5), comsat(8), fingerd(8), ftpd(8), rlogind(8), rpcbind(8), rshd(8), talkd(8), telnetd(8), tftpd(8)Michael C. St. Johns, Identification Protocol, RFC1413. HISTORYTheinetd utility appeared in
4.3BSD. TCPMUX is based on code and documentation by
Mark Lottor. Support for ONC RPC-based services is modeled after that provided
by SunOS 4.1. The IPsec hack was contributed by the KAME project in 1999. The
FreeBSD TCP Wrappers support first appeared in
FreeBSD 3.2.
Visit the GSP FreeBSD Man Page Interface. |