INETD(8)
🌈 NAME 🌈
okay so bestie, meet inetd, inetd.conf — the internet super-server 💅 (yes it's a manual page for section 8, the system manager zone, we're fancy here)
✨ SYNOPSIS ✨
inetd [-d] [-E] [-i] [-l] [-q length] [-R rate] [configuration_file]
💖 DESCRIPTION 💖
So here's the whole vibe: inetd sits there listening on certain internet sockets. The second a connection shows up on one of its sockets, it clocks what service that socket is for and spawns a program to handle the request. When that program is done, inetd just goes right back to listening on the socket — except in some cases, which we'll get into below. Basically inetd lets one daemon invoke a whole squad of others, which takes load off the system. one daemon, many jobs, main character energy fr 👑
The options are as follows:
-d— Turns on debugging. 🐛-E— Stopsinetdfrom laundering the environment. Without this option, a selection of potentially harmful environment variables — includingPATH— get removed and are not inherited by services.-i— Makes the program not daemonize itself.-l— Turns on libwrap connection logging and access control. Internal services cannot be wrapped. When it's enabled,/usr/sbin/tcpdis <em>silently</em> not executed even if it's present in/etc/inetd.conf, and instead libwrap gets called directly byinetd.-qlength — Specify the length of thelisten(2)connections queue; the default is 128.-Rrate — Specify the max number of times a service can be invoked in one minute; the default is 256. If a service blows past this limit,inetdwill log the problem and stop servicing requests for that specific service for ten minutes. See also the wait/nowait configuration fields below. ⏳
When it runs, inetd reads its configuration info from a configuration file which, by default, is /etc/inetd.conf. There has to be an entry for each field of the configuration file, with entries for each field separated by a tab or a space. Comments are marked by a “#” at the beginning of a line. The fields of the configuration file are as follows:
service name
socket type
protocol[,sndbuf=size][,rcvbuf=size]
wait/nowait[.max]
user[.group] or user[:group]
server program
server program arguments
and if you're doing a Sun-RPC based service, the entry would have these fields instead:
service name/version
socket type
rpc/protocol[,sndbuf=size][,rcvbuf=size]
wait/nowait[.max]
user[.group] or user[:group]
server program
server program arguments
For internet services, the first field of the line can <em>also</em> have a host address specifier prefixed to it, separated from the service name by a colon. If you do that, the string before the colon in the first field says what local address inetd should use when listening for that service. Multiple local addresses can go on the same line, separated by commas. You can use numeric IP addresses in dotted-quad notation <em>and</em> symbolic hostnames. Symbolic hostnames get looked up using getaddrinfo(). If a hostname maps to multiple addresses, inetd creates a socket to listen on each address. 🌐
The single character “*” means INADDR_ANY — a.k.a. “all local addresses”. To avoid repeating an address that shows up a lot, a line with a host address specifier and colon but <em>no further fields</em> makes the host address specifier get remembered and used for all further lines with no explicit host specifier (until another such line, or the end of the file). A line
*:
is implicitly provided at the top of the file. So traditional configuration files (the ones with no host address specifiers) get interpreted the traditional way, with all services listened for on all local addresses. If the protocol is “unix”, this value is ignored.
The service name entry is the name of a valid service in /etc/services, or a port number. For “internal” services (we'll get to those below), the service name must be the official name of the service — that is, the <em>first</em> entry in /etc/services. When it's used to specify a Sun-RPC based service, this field is a valid RPC service name in /etc/rpc. The part on the right of the “/” is the RPC version number. This can just be a single numeric argument, or a range of versions. A range is bounded by the low version to the high version — like “rusers/1-3”. For Unix-domain sockets, this field specifies the path name of the socket. 🧚
The socket type should be one of “stream” or “dgram”, depending on whether the socket is a stream or datagram socket.
The protocol must be a valid protocol as given in /etc/protocols or “unix”. Examples might be “tcp” or “udp”. RPC based services are specified with the “rpc/tcp” or “rpc/udp” service type. “tcp” and “udp” get recognized as “TCP or UDP over both IPv4 and IPv6.” If you need to specify IPv4 or IPv6 explicitly, use something like “tcp4” or “udp6”. A protocol of “unix” is used to specify a socket in the Unix-domain.
Okay and here's a cute bonus: on top of the protocol, the configuration file can specify the send and receive socket buffer sizes for the listening socket. This is especially useful for TCP because the window scale factor — which is based on the receive socket buffer size — gets advertised when the connection handshake happens, so the socket buffer size for the server <em>must</em> be set on the listen socket. By bumping up the socket buffer sizes, you might get better TCP performance in some situations. You specify the socket buffer sizes by appending their values to the protocol specification like this:
tcp,rcvbuf=16384
tcp,sndbuf=64k
tcp,rcvbuf=64k,sndbuf=1m
You can put a literal value, or modify it with ‘k’ for kilobytes or ‘m’ for megabytes. 💾
The wait/nowait entry tells inetd whether it should wait for the server program to return, or keep processing connections on the socket. If a datagram server connects to its peer and frees the socket so inetd can receive more messages on it, it's called a “multi-threaded” server and should use the “nowait” entry. For datagram servers that process <em>all</em> incoming datagrams on a socket and eventually time out, the server is “single-threaded” and should use a “wait” entry. comsat(8) (biff(1)) and talkd(8) are both examples of that latter type of datagram server. The optional “max” suffix (separated from “wait” or “nowait” by a dot) specifies the max number of times a service can be invoked in one minute; the default is 256. If a service goes over this limit, inetd will log the problem and stop servicing requests for that specific service for ten minutes. See also the -R option above. ⏰
Stream servers are usually marked as “nowait”, but if a single server process is meant to handle multiple connections, it can be marked as “wait”. The master socket then gets passed as fd 0 to the server, which will then need to accept the incoming connection. The server should eventually time out and exit when no more connections are active. inetd will keep listening on the master socket for connections, so the server should not close it when it exits.
The user entry should contain the user name of the user that the server should run as. This lets servers be given less permission than root. An optional group name can be specified by appending a dot to the user name followed by the group name. This lets servers run with a different (primary) group ID than what's specified in the password file. If a group is specified and the user is not root, the supplementary groups associated with that user will still be set. 🫶
The server program entry should contain the pathname of the program that inetd is supposed to execute when a request shows up on its socket. If inetd provides this service internally, this entry should be “internal”.
The server program arguments should be just like 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.
Now for the fun part: inetd provides several “trivial” services internally using routines inside 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 the deets on these services, consult the appropriate RFC from the Network Information Center. 📚
inetd rereads its configuration file when it receives a hangup signal, SIGHUP. Services can be added, deleted or modified when the configuration file is reread. 🔄
🎀 libwrap 🎀
Support for TCP wrappers is included with inetd to provide built-in tcpd-like access control functionality. An external tcpd program is not needed. You do <em>not</em> need to change the /etc/inetd.conf server-program entry to enable this capability. inetd uses /etc/hosts.allow and /etc/hosts.deny for access control facility configurations, as described in hosts_access(5).
🦋 IPv6 TCP/UDP behavior 🦋
The default is to run two servers: one for IPv4 and one for IPv6 traffic. If you have different requirements, then you can specify one or two separate lines in inetd.conf, for “tcp4” and “tcp6”.
Under various combinations of IPv4/v6 daemon settings, inetd will behave as follows:
- If you have only one server on
“tcp4”, IPv4 traffic will be routed to the server. IPv6 traffic will not be accepted. - If you have two servers on
“tcp4”and“tcp6”, IPv4 traffic will be routed to the server on“tcp4”, and IPv6 traffic will go to the server on“tcp6”, which is identical to the default behaviour when only“tcp”is specified. - If you have only one server on
“tcp6”, only IPv6 traffic will be routed to the server.- The special
“tcp46”parameter can be used for obsolete servers which require to receive IPv4 connections mapped in an IPv6 socket. Its usage is discouraged. 🙈
- The special
🌸 FILES 🌸
/etc/inetd.conf
⭐ SEE ALSO ⭐
fingerd(8), ftpd(8), identd(8), talkd(8)
💜 HISTORY 💜
The inetd command appeared in 4.3BSD. Support for Sun-RPC based services is modelled after that provided by SunOS 4.1. IPv6 support was added by the KAME project in 1999.
Marco d'Itri ported this code from OpenBSD in summer 2002 and added socket buffers tuning and libwrap support from the NetBSD source tree. 🫡
💀 BUGS 💀 (yes bestie, the messy parts, we're airing them out)
Okay so nobody's perfect and inetd is not the exception, so let's talk about the little gremlin behaviors, no cap.
- Linux girlies, listen up: the daemon cannot reload its configuration. Like, at all. So if you change the host address for a service between
"*"and a specific address? You have to restart the whole thing. It's giving no grace, it's giving full reboot energy. 😭 - Server programs that get used with
"dgram","udp", and"nowait"must read from the network socket. If they don't?inetdwill just keep spawning processes over and over until it hits the maximum. Not a cute look. The way that it will absolutely spiral fr fr. 💀 - Host address specifiers… okay so conceptually they make total sense for RPC services, but they do not work entirely correctly. Why? Largely because the portmapper interface just doesn't provide a way to register different ports for the same service on different local addresses. So like, the plumbing isn't there, not the vibe's fault. 🙈
But here's the good news: provided you never have more than one entry for a given RPC service, everything should work correctly. One entry, one slay. 👑
Also note (this is the sneaky part, iykyk): default host address specifiers do apply to RPC lines with no explicit specifier. So even if you didn't write one, there's one in there. Surprise. ✨
And that's the whole page bestie, we made it to the end together 🫶 this icon of a manual came from Debian, dated February 10, 2020, and lives under the name INETD(8). Go forth and configure responsibly, mwah 💅💖
📦 where this page comes from
- debian bookworm: openbsd-inetd 0.20221205-2~deb12u1
- debian trixie: openbsd-inetd 0.20221205-3+b2
- ubuntu noble: openbsd-inetd 0.20221205-3build4
- ubuntu questing: openbsd-inetd 0.20221205-3build4
- ubuntu resolute: openbsd-inetd 0.20221205-3build5
- ubuntu stonking: openbsd-inetd 0.20221205-3build5
- Copyright (c) 1985, 1991 The Regents of the University of California
- 💖 girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms