1. Home
  2. Computing & Technology
  3. Linux

Linux Network Administrators Guide

From Authors, for About.com


   Linux Network Administrators Guide
   Prev    Chapter 12. ImportantNetwork Features    Next

12.1. The inetd Super Server

Programs that provide application services via the network are called network daemons . A daemon is a program that opens a port, most commonly a well-known service port, and waits for incoming connections on it. If one occurs, the daemon creates a child process that accepts the connection, while the parent continues to listen for further requests. This mechanism works well, but has a few disadvantages; at least one instance of every possible service you wish to provide must be active in memory at all times. In addition, the software routines that do the listening and port handling must be replicated in every network daemon.

To overcome these inefficiencies, most Unix installations run a special network daemon, what you might consider a "super server." This daemon creates sockets on behalf of a number of services and listens on all of them simultaneously. When an incoming connection is received on any of these sockets, the super server accepts the connection and spawns the server specified for this port, passing the socket across to the child to manage. The server then returns to listening.

The most common super server is called inetd , the Internet Daemon. It is started at system boot time and takes the list of services it is to manage from a startup file named /etc/inetd.conf . In addition to those servers, there are a number of trivial services performed by inetd itself called internal services . They include chargen , which simply generates a string of characters, and daytime , which returns the system's idea of the time of day.

An entry in this file consists of a single line made up of the following fields:


   

service type protocol wait user server cmdline

Each of the fields is described in the following list:

  • service
  •    

    Gives the service name. The service name has to be translated to a port number by looking it up in the /etc/services file. This file will be described later in this chapter in the section Section 12.3 ."


  • type
  •    

    Specifies a socket type, either stream (for connection-oriented protocols) or dgram (for datagram protocols). TCP-based services should therefore always use stream , while UDP-based services should always use dgram .


  • protocol
  •    

    Names the transport protocol used by the service. This must be a valid protocol name found in the protocols file, explained later.


  • wait
  •    

    This option applies only to dgram sockets. It can be either wait or nowait . If wait is specified, inetd executes only one server for the specified port at any time. Otherwise, it immediately continues to listen on the port after executing the server.

    This is useful for "single-threaded" servers that read all incoming datagrams until no more arrive, and then exit. Most RPC servers are of this type and should therefore specify wait . The opposite type, "multi-threaded" servers, allow an unlimited number of instances to run concurrently. These servers should specify nowait .

    stream sockets should always use nowait .


  • user
  •    

    This is the login ID of the user who will own the process when it is executing. This will frequently be the root user, but some services may use different accounts. It is a very good idea to apply the principle of least privilege here, which states that you shouldn't run a command under a privileged account if the program doesn't require this for proper functioning. For example, the NNTP news server runs as news , while services that may pose a security risk (such as tftp or finger ) are often run as

* License

* Linux Network Administrators Guide Guide Index

Explore Linux

More from About.com

  1. Home
  2. Computing & Technology
  3. Linux
  4. Linux Documentation
  5. Linux Network Admin Guide
  6. Linux Network Administrators Guide - The inetd Super Server

©2008 About.com, a part of The New York Times Company.

All rights reserved.