networking - 如何将DNS重定向到不同的端口

标签 networking dns minecraft

TL;DR:
域的 DNS 解析必须映射到 IP:port(s) ,而不仅仅是 IP
例子,sub1.example.com 🡲 192.0.2.4:4567sub2.example.com 🡲 192.0.2.4:5678我可以修改 DNS 记录。

我拥有“Arboristal.com”域。我还在 arboristal.com 上私下拥有所有子域。例如 lg.arboristal 或 ft.arboristal.com。
在我的 DNS 设置下,Arboristal.com 设置为访问我们当前托管我们网站的网络主机。
我家有三台服务器运行在一个公共(public) IP 地址下。 (71.82.237.27)
我还有 Arboristal.com 的三个子域指向我的 IP 地址。
三台服务器中的每台都在各自的端口上运行(25565、25566、25567)
我希望每个子域都指向我的 IP 地址上的每个开放端口。
不幸的是,当您尝试使用其中一个子域连接到其中一台服务器时,它只会连接到您为其键入端口的服务器。
我的情况:
三台服务器,每台运行在不同的端口上。 (所有端口转发并作为服务器工作)

  • Minecraft 服务器一 (25565)
  • Minecraft 服务器二 (25566)
  • Minecraft 服务器三 (25567)

  • 我的 DNS 提供商 (webs.com) 上运行了三个子域
  • mc.arboristal.com
  • tekkit.arboristal.com
  • pvp.artboristal.com

  • 当您使用 Minecraft 连接到其中一个时,它会通过端口 25565 自动连接,这意味着无论您尝试连接什么 URL,它始终会使用端口 25565 访问我的 IP。将您连接到 Minecraft 服务器一。您可以手动输入端口,但我宁愿让它尽可能美观和专业。
    那么,既然你知道了我的情况,有什么方法可以让 mc.arboristal.com、tekkit.arboristal.com 和 pvp.arboristal.com 都在不同的端口下访问我的 IP 地址,而无需指定每个端口在提供的 URL 中连接到用户端?
    我可以将 MX、A(使用此连接到服务器)、CNAME 和 TXT 记录添加到 DNS 设置
    如果我需要使用第三方作为我的 DNS 提供商,我还可以将名称服务器添加到 DNS 设置中。 (如有必要我愿意做)
    如果需要在 192.168.0.1 上配置任何内容,我还可以完全访问我的路由器。
    我只是在上周才了解互联网的真正运作方式,所以我不确定这里是否真的有任何可能。我也可能没有关于互联网实际运作方式的正确信息。请原谅我可能假设的有关互联网的任何虚假信息。

    最佳答案

    您可以使用SRV records :

    _service._proto.name. TTL class SRV priority weight port target.
    

    Service: the symbolic name of the desired service.

    Proto: the transport protocol of the desired service; this is usually either TCP or UDP.

    Name: the domain name for which this record is valid, ending in a dot.

    TTL: standard DNS time to live field.

    Class: standard DNS class field (this is always IN).

    Priority: the priority of the target host, lower value means more preferred.

    Weight: A relative weight for records with the same priority.

    Port: the TCP or UDP port on which the service is to be found.

    Target: the canonical hostname of the machine providing the service, ending in a dot.


    例子:
    _sip._tcp.example.com. 86400 IN SRV 0 5 5060 sipserver.example.com.
    
    所以我认为你正在寻找的是在你的 DNS hosts file 中添加这样的东西。 :
    _minecraft._tcp.arboristal.com. 86400 IN SRV 10 40 25565 mc.arboristal.com.
    _minecraft._tcp.arboristal.com. 86400 IN SRV 10 30 25566 tekkit.arboristal.com.
    _minecraft._tcp.arboristal.com. 86400 IN SRV 10 30 25567 pvp.arboristal.com.
    
    (Minecraft 支持 SRV 记录,从 1.3.1 开始,服务名称为 minecraft )
    附带说明一下,我强烈建议您与托管公司合作,而不是自己托管服务器。它只是要求您的家庭连接(DDoS 和带宽/连接速度)出现问题,但这取决于您。

    关于networking - 如何将DNS重定向到不同的端口,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19015138/

    相关文章:

    linux - 在具有多个接口(interface)的服务器上接收多播 (linux)

    java - 如何在java中获取wifi网络接口(interface)名称

    c# - 是否可以使用 Bind 构建我自己的 DDNS?

    amazon-web-services - 我们可以在 Route 53 AWS DNS 服务中创建多少个子域?

    c++ - 并行使用主 DNS 服务器和辅助 DNS 服务器进行名称解析

    java - Minecraft Forge 方法数据类型

    java - .jar 文件无法在我的 Mac 上打开

    java - 创建 Gui 的实例(使用 ModLoader 进行 Minecraft 模组)

    java - 通过网络发送数据时触发 Android 事件。检测网络使用情况

    java - 重复使用 readUTF() 后,ObjectInputStream 抛出 EOFException