您将如何为您的软件注册端口

您将如何为您的软件注册端口

这是一个关于Unix软件开发的问题。我看到了以下问题,这引起了我的问题:

假设您正在构建一个服务,稍后您想要打包并发布到 Linux 发行版,并且它涉及网络。您正在从头开始制作所有内容(例如不使用 ssh 或 HTTP 等),因此您将需要一些默认端口进行通信。社区(或负责人)如何决定使用哪个端口并将其保留?

答案1

阅读 的内容/etc/services。有一些评论可以阐明这一点。

例如

# Network services, Internet style
#
# Note that it is presently the policy of IANA to assign a single well-known
# port number for both TCP and UDP; hence, officially ports have two entries
# even if the protocol doesn't support UDP operations.
#
# Updated from https://www.iana.org/assignments/service-names-port-numbers/service-names-port-numbers.xhtml .
#
# New ports will be added on request if they have been officially assigned
# by IANA and used in the real-world or are needed by a debian package.
# If you need a huge list of used numbers please install the nmap package.

.
.
.

#=========================================================================
# The remaining port numbers are not as allocated by IANA.
#=========================================================================
.
.
.
# Services added for the Debian GNU/Linux distribution
.
.
.
# Local services

这些并不是文件中的唯一评论。

从中我看到了 IANA 分配的一部分端口。由 IANA 记录的部分(但未由其分配)、由 Debian 分配的部分(我正在运行 Debian Gnu/Linux)以及供我添加本地使用的端口的部分。

请参阅这些页面以获取更多信息

上面的第二个链接包含有关如何注册端口的信息。您还可以仅注册一个名称(可以使用 DNS 查找特定端点的端口)。

您将如何为您的软件注册端口

步骤1

变得流行:在您的软件流行之前,您无法说服任何人。

现在做什么。

选择一个未使用的端口。选择默认值,但使其可配置。

低编号端口(为根保留,或功能 CAP_NET_BIND_SERVICE)

如果您可以控制机器,则可以使用它们。在多用户计算机上的优点是其他用户无法使用该端口:窃取端口(DOS)、使用端口(假站点)等。

相关内容