services 中文man页面

系统
services 是一个普通的 ASCII 码文件, 它在 internet 服务的友好原文名以及这些服务预先分配的端口和协议类型之间提供了映射. 每个联网程序必须查找该文件以获取其服务的端口号(和协议). C 库例程 getservent(3), getservbyname(3), getservbyport(3), setservent(3), 和 endservent(3) 支持由程序查询该文件.

NAME(名称)

services - Internet 网络服务列表  

DESCRIPTION(描述)

services 是一个普通的 ASCII 码文件, 它在 internet 服务的友好原文名以及这些服务预先分配的端口和协议类型之间提供了映射. 每个联网程序必须查找该文件以获取其服务的端口号(和协议). C 库例程 getservent(3), getservbyname(3), getservbyport(3), setservent(3), 和 endservent(3) 支持由程序查询该文件.

端口号由 IANA(Internet Assigned Numbers Authority) 分配, 他们当前的工作是分配端口号时, 指定 TCP 和 UDP 协议. 这样, 大多数记录会包括两条子记录, 即使只是 TCP 的服务也是如此

端口号在 1024 之下的(也称作'低编码'端口)只能由 root (参见 bind(2),tcp(7),udp(7).) 绑定. 这样连接到低编码端口的客户可信任运行在该端口上的服务是标准的实现, 而不是由某台机器的用户运行的无聊的服务.由 IANA 确定的众所周知的端口号通常只在 root 的控制范围之内

services 文件中出现的一条服务记录并不表示该服务当前在机器上运行.参见 inetd.conf(5) 以获知提供的Internet服务的配置.注意不是所有联网服务都由 inetd(8) 启动,因而也不会出现在 inetd.conf(5) 之中. 特别地,news (NNTP)和mail (SMTP)服务程序通常由系统引导脚本初始化.

services 文件所存放的位置由 /usr/include/netdb.h 中的 _PATH_SERVICES 定义. 它通常设为 /etc/services.

每行描述了一个服务,其格式如下:

服务名   端口/协议   [别名 ...] 这里的
服务名
是给服务所起的可供查找的友好的名字.它是区分大小写的.通常,客户端程序都以 服务名 命名.
端口
为该服务所用的端口号(十进制格式).
协议
为所使用的协议类型.该字段应与 protocols(5) 文件中的一条记录相匹配.典型的值包括 tcpudp.
别名
可以空缺,或者是以tab分隔的该服务的其他名字的列表(不过请查看下面的BUGS章节).同样, 这些名字也是区分大小写的.

可以使用空格或者tab分隔这些字段.

注释以hash标识(#)开头,一直到该行末结束.空行可跳过.

服务名 必须是该文件的第一列,因为其前面的空格不会删去. 服务名 可以为任何可打印的字符,包括空格和tab,但是,应该使用字符的保守选择来最低限度地减少操作中的问题.例如:a-z,0-9,和连字符(-)看上去就是一个合理的选择.

不匹配该格式的行不应该在该文件中出现.(当前情况下, getservent(3),getservbyname(3),getservbyport(3) 可以忽略它们.不过,不应该依靠这种方法.)

为了向后兼容,在 端口 号和 协议 名之间的斜杠(/)实际可以为斜杠或者是逗号(,).在现代的安装中使用逗号是落后的.

该文件也可以通过使用网络级命名服务如黄页/NIS(Yellow Pages/NIS)或BIND/Hesiod来在一个网络中发布.

一个 services 的样本文件看上去如下:


netstat         15/tcp
qotd            17/tcp          quote
msp             18/tcp          # message send protocol
msp             18/udp          # message send protocol
chargen         19/tcp          ttytst source
chargen         19/udp          ttytst source
ftp             21/tcp
# 22 - unassigned
telnet          23/tcp

BUGS

最大只能有35个别名,这是由 getservent(3) 代码的写入方式决定的.

BUFSIZ (当前为1024)个字符更长的行, getservent(3),getservbyname(3),andgetservbyport(3) 会忽略掉. 不过,这也会导致错过下一行.  

FILES(相关文件)

/etc/services
Internet网络服务列表
/usr/include/netdb.h
_PATH_SERVICES 的定义

SEE ALSO(另见)

getservent(3), getservbyname(3), getservbyport(3), setservent(3), endservent(3), protocols(5), listen(2), inetd.conf(5), inetd(8).

#p#

NAME

services - Internet network services list  

DESCRIPTION

services is a plain ASCII file providing a mapping between friendly textual names for internet services, and their underlying assigned port numbers and protocol types. Every networking program should look into this file to get the port number (and protocol) for its service. The C library routines getservent(3), getservbyname(3), getservbyport(3), setservent(3), and endservent(3) support querying this file from programs.

Port numbers are assigned by the IANA (Internet Assigned Numbers Authority), and their current policy is to assign both TCP and UDP protocols when assigning a port number. Therefore, most entries will have two entries, even for TCP only services.

Port numbers below 1024 (so-called 'low numbered' ports) can only be bound to by root (see bind(2), tcp(7), and udp(7)). This is so clients connecting to low numbered ports can trust that the service running on the port is the standard implementation, and not a rogue service run by a user of the machine. Well-known port numbers specified by the IANA are normally located in this root-only space.

The presence of an entry for a service in the services file does not necessarily mean that the service is currently running on the machine. See inetd.conf(5) for the configuration of Internet services offered. Note that not all networking services are started by inetd(8), and so won't appear in inetd.conf(5). In particular, news (NNTP) and mail (SMTP) servers are often initialized from the system boot scripts.

The location of the services file is defined by _PATH_SERVICES in /usr/include/netdb.h. This is usually set to /etc/services.

Each line describes one service, and is of the form:

service-name   port/protocol   [aliases ...]
where:
service-name
is the friendly name the service is known by and looked up under. It is case sensitive. Often, the client program is named after the service-name.
port
is the port number (in decimal) to use for this service.
protocol
is the type of protocol to be used. This field should match an entry in the protocols(5) file. Typical values include tcp and udp.
aliases
is an optional space or tab separated list of other names for this service (but see the BUGS section below). Again, the names are case sensitive.

Either spaces or tabs may be used to separate the fields.

Comments are started by the hash sign (#) and continue until the end of the line. Blank lines are skipped.

The service-name should begin in the first column of the file, since leading spaces are not stripped. service-names can be any printable characters excluding space and tab. However, a conservative choice of characters should be used to minimize inter-operability problems. E.g., a-z, 0-9, and hyphen (-) would seem a sensible choice.

Lines not matching this format should not be present in the file. (Currently, they are silently skipped by getservent(3), getservbyname(3), and getservbyport(3). However, this behaviour should not be relied on.)

As a backwards compatibility feature, the slash (/) between the port number and protocol name can in fact be either a slash or a comma (,). Use of the comma in modern installations is depreciated.

This file might be distributed over a network using a network-wide naming service like Yellow Pages/NIS or BIND/Hesiod.

A sample services file might look like this:


netstat         15/tcp
qotd            17/tcp          quote
msp             18/tcp          # message send protocol
msp             18/udp          # message send protocol
chargen         19/tcp          ttytst source
chargen         19/udp          ttytst source
ftp             21/tcp
# 22 - unassigned
telnet          23/tcp

BUGS

There is a maximum of 35 aliases, due to the way the getservent(3) code is written.

Lines longer than BUFSIZ (currently 1024) characters will be ignored by getservent(3), getservbyname(3), and getservbyport(3). However, this will also cause the next line to be mis-parsed.  

FILES

/etc/services
The Internet network services list
/usr/include/netdb.h
Definition of _PATH_SERVICES

SEE ALSO

getservent(3), getservbyname(3), getservbyport(3), setservent(3), endservent(3), protocols(5), listen(2), inetd.conf(5), inetd(8)

责任编辑:韩亚珊 来源: CMPP.net
相关推荐

2011-08-24 16:48:36

man中文man

2011-08-15 10:21:09

man中文man

2011-08-11 16:11:49

at中文man

2011-08-25 10:21:56

man.conf中文man

2011-08-12 14:58:05

killall中文man

2011-07-15 16:58:36

ac中文man

2011-08-15 11:10:48

more中文man

2011-08-25 17:03:51

pclose中文man

2011-08-15 14:10:37

tar中文man

2011-08-16 10:42:30

rmmod中文man

2011-08-18 13:57:38

acct中文man

2011-08-23 17:49:36

zdump中文man

2011-08-15 15:10:49

wall中文man

2011-08-23 15:06:03

quotastats中文man

2011-08-15 17:35:50

ar中文man

2011-08-25 09:07:16

suffixes中文man

2011-08-18 15:21:37

autofs中文man

2011-08-25 15:19:39

dirname中文man

2011-08-25 17:34:50

setlinebuf中文man

2011-08-15 15:17:14

ac中文man
点赞
收藏

51CTO技术栈公众号