old-www/LDP/nag2/x-087-2-appl.services.html

342 lines
6.5 KiB
HTML

<HTML
><HEAD
><TITLE
>The Services and Protocols Files</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.57"><LINK
REL="HOME"
TITLE="Linux Network Administrators Guide"
HREF="index.html"><LINK
REL="UP"
TITLE="ImportantNetwork Features"
HREF="x-087-2-appl.html"><LINK
REL="PREVIOUS"
TITLE="The tcpd Access Control Facility"
HREF="x-087-2-appl.tcpd.html"><LINK
REL="NEXT"
TITLE="Remote Procedure Call"
HREF="x-087-2-appl.rpc.html"></HEAD
><BODY
CLASS="SECT1"
BGCOLOR="#FFFFFF"
TEXT="#000000"
LINK="#0000FF"
VLINK="#840084"
ALINK="#0000FF"
><DIV
CLASS="NAVHEADER"
><TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="3"
ALIGN="center"
>Linux Network Administrators Guide</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="x-087-2-appl.tcpd.html"
>Prev</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
>Chapter 12. ImportantNetwork Features</TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="x-087-2-appl.rpc.html"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="SECT1"
><H1
CLASS="SECT1"
><A
NAME="X-087-2-APPL.SERVICES"
>12.3. The Services and Protocols Files</A
></H1
><P
>The port numbers on which certain &#8220;standard&#8221; services are
offered are defined in the Assigned Numbers RFC. To enable server and client
programs to convert service names to these numbers, at least part of
the list is kept on each host; it is stored in a file called
<TT
CLASS="FILENAME"
>/etc/services</TT
>. An entry is made up like this:
<TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><PRE
CLASS="SCREEN"
><TT
CLASS="REPLACEABLE"
><I
>service</I
></TT
> <TT
CLASS="REPLACEABLE"
><I
>port</I
></TT
>/<TT
CLASS="REPLACEABLE"
><I
>protocol</I
></TT
> [<TT
CLASS="REPLACEABLE"
><I
>aliases</I
></TT
>]</PRE
></TD
></TR
></TABLE
></P
><P
>Here, <TT
CLASS="REPLACEABLE"
><I
>service</I
></TT
> specifies the service name,
<TT
CLASS="REPLACEABLE"
><I
>port</I
></TT
> defines the port the service is offered on,
and <TT
CLASS="REPLACEABLE"
><I
>protocol</I
></TT
> defines which transport protocol
is used. Commonly, the latter field is either
<TT
CLASS="REPLACEABLE"
><I
>udp</I
></TT
> or
<TT
CLASS="REPLACEABLE"
><I
>tcp</I
></TT
>. It is possible for a service to be
offered for more than one protocol, as well as offering different services on
the same port as long as the protocols are different. The
<TT
CLASS="REPLACEABLE"
><I
>aliases</I
></TT
> field allows you to specify alternative
names for the same service.</P
><P
>Usually, you don't have to change the services file that comes along
with the network software on your Linux system. Nevertheless, we give a
small excerpt from that file in <A
HREF="x-087-2-appl.services.html#X-087-2-ETC.SERVICES"
>Example 12-2</A
>.</P
><DIV
CLASS="EXAMPLE"
><A
NAME="X-087-2-ETC.SERVICES"
></A
><P
><B
>Example 12-2. A Sample /etc/services File</B
></P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><PRE
CLASS="SCREEN"
># The services file:
#
# well-known services
echo 7/tcp # Echo
echo 7/udp #
discard 9/tcp sink null # Discard
discard 9/udp sink null #
daytime 13/tcp # Daytime
daytime 13/udp #
chargen 19/tcp ttytst source # Character Generator
chargen 19/udp ttytst source #
ftp-data 20/tcp # File Transfer Protocol (Data)
ftp 21/tcp # File Transfer Protocol (Control)
telnet 23/tcp # Virtual Terminal Protocol
smtp 25/tcp # Simple Mail Transfer Protocol
nntp 119/tcp readnews # Network News Transfer Protocol
#
# UNIX services
exec 512/tcp # BSD rexecd
biff 512/udp comsat # mail notification
login 513/tcp # remote login
who 513/udp whod # remote who and uptime
shell 514/tcp cmd # remote command, no passwd used
syslog 514/udp # remote system logging
printer 515/tcp spooler # remote print spooling
route 520/udp router routed # routing information protocol</PRE
></TD
></TR
></TABLE
></DIV
><P
>
Note that the <B
CLASS="COMMAND"
>echo</B
> service is offered on port 7 for both
TCP and UDP, and that port 512 is used for two
different services: remote execution (<B
CLASS="COMMAND"
>rexec</B
>) using TCP,
and the <B
CLASS="COMMAND"
>COMSAT</B
> daemon, which notifies users of new mail, over UDP
(see <B
CLASS="COMMAND"
>xbiff(1x)</B
>&#8201;).</P
><P
>
Like the services file, the networking library needs a way to translate
protocol names&#8212;for example, those used in the services file&#8212;to
protocol numbers understood by the IP layer on other hosts. This is done by
looking up the name in the <TT
CLASS="FILENAME"
>/etc/protocols</TT
> file. It
contains one entry per line, each containing a protocol name, and the
associated number. Having to touch this file is even more unlikely than
having to meddle with <TT
CLASS="FILENAME"
>/etc/services</TT
>. A sample file
is given in <A
HREF="x-087-2-appl.services.html#X-087-2-ETC.PROTOCOLS"
>Example 12-3</A
>.</P
><DIV
CLASS="EXAMPLE"
><A
NAME="X-087-2-ETC.PROTOCOLS"
></A
><P
><B
>Example 12-3. A Sample /etc/protocols File</B
></P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><PRE
CLASS="SCREEN"
>#
# Internet (IP) protocols
#
ip 0 IP # internet protocol, pseudo protocol number
icmp 1 ICMP # internet control message protocol
igmp 2 IGMP # internet group multicast protocol
tcp 6 TCP # transmission control protocol
udp 17 UDP # user datagram protocol
raw 255 RAW # RAW IP interface</PRE
></TD
></TR
></TABLE
></DIV
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="x-087-2-appl.tcpd.html"
>Prev</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="index.html"
>Home</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="x-087-2-appl.rpc.html"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>The tcpd Access Control Facility</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="x-087-2-appl.html"
>Up</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>Remote Procedure Call</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>