主机名查询的端口是什么?
我想查询 IP 以获取其主机名。这个的标准端口是什么?它可能是 /etc/services 中“主机名”下列出的端口 101 吗?
I want to query an IP to get its hostname. What is the standard port for this ? Could it be port 101 listed under "hostnames" in /etc/services ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
UDP端口101用于提供“主机名”服务,但原始RFC(RFC811 ) 已被 RFC953 废弃,并且 RFC953 被标记为“历史性”。
如今,您会查阅DNS(域名系统),它还有许多其他列出的相关 RFC 正在更新它。您通常会使用适合您所使用的语言的库函数来查询 DNS(问题之一是您应该查询的 DNS 服务器的 IP 地址是什么)。
在这两种情况(主机名和 DNS)中,您咨询的机器不是具有您感兴趣的特定 IP 地址的机器。从您的问题中不清楚您是否希望询问具有感兴趣的 IP 地址的主机的名称是,或者您是否希望向另一台机器询问这个问题。实际上,您最终会询问其他机器 - DNS 服务器。
UDP port 101 used to provide the 'hostname' service, but the original RFC (RFC811) is obsoleted by RFC953, and RFC953 is marked 'historic'.
These days, you would consult the DNS (Domain Name System), which has many other relevant RFCs listed as updating it. And you would normally use the appropriate library functions for the language you are using to consult the DNS (one issue being what is the IP address of the DNS server you should consult).
In both these cases (hostname and DNS), you consulted a machine other than the one with the specific IP address you are interested in. It is not clear from your question whether you expect to ask the host with the interesting IP address what its name is, or whether you are expecting to ask another machine the question. In practice, you will end up asking other machines - the DNS server(s).
/etc/services
中发现的大多数“众所周知的端口”都是历史实现的残余——这些“历史协议”的实现已不再使用。您找到的端口 101 被注释为“NIC Host Name Server”。我发现 RFC 811 和 RFC953 描述了端口 101 上服务的协议。最有趣的是,RFC 811 时唯一的实现(1982) 在 SRI International 的一台特定机器上运行。 “端口 101 协议”不是现代互联网上可以找到的服务。
我能想到的唯一旨在提供您需要的信息的服务是 SNMP,并且不能保证您会找到正在运行的 SNMP 服务,或者您会知道查看该服务所需的访问关键字(“社区名称”)。通过 SNMP 服务的远程主机名。
许多特定的服务实现都会使用主机名进行响应,例如:
编辑:其他一些答案建议您查看 DNS 端口。 DNS(域名系统)并不是您真正想要的。但是,如果您确实想使用 DNS 查找,请查看 Windows、MacBSD 和 Linux 下 C 语言中提供的
gethostbyaddr()
函数。Most of the "well known ports" found in
/etc/services
are remnants of historic implementations -- implementations of these "historic protocols" are no longer in use.The port 101 you found is commented "NIC Host Name Server". I found that RFC 811 and RFC953 describe the protocol served on port 101. Most interesting to note is that the only implementation at the time of RFC 811 (1982) was running on a particular machine at SRI International. The "port 101 protocol" is not a service that you will find on the Internet in the modern time.
The only service I can think of which is designed to provide information like you need is SNMP, and there is no guarantee you will either find an SNMP service running or that you will know the access keyword required ("community name") to see the remote hostname via the SNMP service.
Many specific implementations of services respond with the hostname, for example:
Edit: A few other answers are suggesting you look into the DNS port. DNS (Domain Name System) is not really what you asked for. If you do want to use a DNS lookup, however, check into the
gethostbyaddr()
function available from C under Windows, MacBSD and Linux.好的 dns 在端口 53 上运行
well dns runs on port 53