前言
前段时间为了和网络环境不是很好的朋友联机MC玩耍,所以我在简幻欢开了一个50积分的超级小服,作为和朋友的联机手段,但是每一次进入的时候都要用play.simpfun.cn:端口的方式来进入,而简幻欢又不支持25565作为端口,所以每次换设备连接的时候每次都要去后台复制地址这样子就显得很麻烦,即使是通过CNAME也还是要添加端口,每次用带端口号的形式地址总显得有点长,也有点low,所以我们可以用一种DNS类型来实现对端口的隐藏,而只需要输入域名就可以连入指定端口的服务器
如何隐藏端口呢?这里如果是http网页可以通过基于nginx的反向代理来进行使用,但是很显然,这并不是个网页,所以我们就需要使用另外的方式了
最终我了解到,可以通过 DNS 解析中的 SRV 功能,实现不需要端口连接我的世界服务器
了解SRV
在使用该技术前,我们先来了解了解什么是SRV
根据CloudFlare的文章《什么是 DNS SRV 记录?》中我们可以了解到:
DNS“服务” (SRV) 记录为特定的服务(如 IP语音 (VoIP))、即时通讯等)指定主机和端口。大多数其他 DNS 记录只指定一个服务器或一个 IP 地址,但 SRV 记录还包括该 IP 地址的一个端口。一些互联网协议需要使用 SRV 记录才能运作。

实现
准备工作
首先,你要有一个域名,然后需要一个支持SRV解析的DNS域名提供商,这里我使用CloudFlare和DNSPod来举例
CloudFlare
首先进入CloudFlare控制台首页https://dash.cloudflare.com/,选择你的域名
进入解析页面后,选择SRV

名称那里的命名规则是_服务名称._网络协议(为TCP或者UDP).你想要的自定义前缀,这里我是给MC JAVA版开服,而我的自定义前缀想要mc,所以我就填写_minecraft._tcp.mc(*如果你是使用基岩版开服,需要解析为_minecraft._udp.mc)
优先级0-65535都可以,这里推荐是0,当然你有其他的需求可以修改为0-65535之内的任意数字,数字越大越好,0为最大
权重也是要求填写0-65535之间的数字,这里推荐为5,数字越大越好,0为最大
TTL是缓存时间,CloudFlare的TTL设置为自动缓存刷新很快,所以自动就好
端口就填写连接服务器的时候”:“后面填写的端口,简幻欢给我分配的是23786,所以我就填写23786,这里要按照实际的情况来写
目标就填写分配给你的域名,我这里是play.simpfun.cn,我就填写为play.simpfun.cn(*重点提醒,这里必须是域名,因为使用SRV作为解析方式是不支持通过IP解析的,所以没有分配域名的可以自己用A记录解析一下)

点击保存
过段时间后,可以使用系统自带的nslookup查询解析是否生效(*直接使用nslookup或ping是查询不出来解析的,需要使用我下面的命令)
(*CF的解析其实挺快的,2分钟左右就好了)
nslookup -q=srv _minecraft._tcp.mc.sdcom.asia (这里要用你刚刚自定义解析的域名)
出现和下图大概相似的输出时,那么就是成功了


现在我们来验证下是否能用这个域名不带端口直接进入服务器

DNSPod
首先进入DNSPod控制台首页https://console.dnspod.cn/,选择你的域名
进入解析页面后,解析类型依旧选择SRV

主机记录那里还是和刚刚的CloudFlare一样,命名规则是服务名称.网络协议(为TCP或者UDP).你想要的自定义前缀,由于我这里时相同的服务器,所以我还是使用_minecraft._tcp.mc
线路类型就选择默认不用修改
记录值的记录格式为如下
记录值:优先级 权重 端口 主机名(可以和上面的CloudFlare来对照着写)
这里按照我的服务器填写格式就为0 5 23786 play.simpfun.cn
权重这里就不需要填写
MX 优先级也是不需要填写
TTL为缓存时间,数值越小,修改记录各地生效时间越快,DNSPod免费版本默认为600秒

出现如下提示就是在DNSPod添加解析成功了

就和刚刚一样,也是使用nslookup查询解析生效情况
nslookup -q=srv _minecraft._tcp.mc.sdcom.*** (这里要用你刚刚自定义解析的域名)
出现和下图大概相似的输出时,那么就是成功了


现在我们来验证下是否能用这个域名不带端口直接进入服务器

可以进入服务器
尾声
通过以上的文章,想必作为服主的你一定学会SRV该怎么使用了吧(没域名的当我没说)
但是,本教程仅能隐藏端口号,并不能阻止他人获取到你的真实IP地址和端口号,也不能防范DDoS攻击!
所以这个操作也只是少记几位数字的端口号而已,不过服主拿出去宣传的时候也是一种非常方便让人记住的一种方法
最后,我想说一句:文章经供参考,不是人人的环境都能做到完全相同,文章中的理解均为作者本人自己的理解,也是作者本人自己的环境,文章需要自行辨别,根据自己的环境作出更改
那我们下一篇文章见!
Great article, thank you for sharing these insights! I’ve tested many methods for building backlinks, and what really worked for me was using AI-powered automation. aistudiodrive.com we can scale link building in a safe and efficient way. It’s amazing to see how much time this saves compared to manual outreach.
Great article, thank you for sharing these insights! I’ve tested many methods for building backlinks, and what really worked for me was using AI-powered automation. aistudiodrive.com we can scale link building in a safe and efficient way. It’s amazing to see how much time this saves compared to manual outreach.
Great article, thank you for sharing these insights! I’ve tested many methods for building backlinks, and what really worked for me was using AI-powered automation. aistudiodrive.com we can scale link building in a safe and efficient way. It’s amazing to see how much time this saves compared to manual outreach.
Great article, thank you for sharing these insights! I’ve tested many methods for building backlinks, and what really worked for me was using AI-powered automation. aistudiodrive.com we can scale link building in a safe and efficient way. It’s amazing to see how much time this saves compared to manual outreach.
Great article, thank you for sharing these insights! I’ve tested many methods for building backlinks, and what really worked for me was using AI-powered automation. aistudiodrive.com we can scale link building in a safe and efficient way. It’s amazing to see how much time this saves compared to manual outreach.
Great article, thank you for sharing these insights! I’ve tested many methods for building backlinks, and what really worked for me was using AI-powered automation. aistudiodrive.com we can scale link building in a safe and efficient way. It’s amazing to see how much time this saves compared to manual outreach.
Great article, thank you for sharing these insights! I’ve tested many methods for building backlinks, and what really worked for me was using AI-powered automation. aistudiodrive.com we can scale link building in a safe and efficient way. It’s amazing to see how much time this saves compared to manual outreach.
Great article, thank you for sharing these insights! I’ve tested many methods for building backlinks, and what really worked for me was using AI-powered automation. aistudiodrive.com we can scale link building in a safe and efficient way. It’s amazing to see how much time this saves compared to manual outreach.
Great article, thank you for sharing these insights! I’ve tested many methods for building backlinks, and what really worked for me was using AI-powered automation. aistudiodrive.com we can scale link building in a safe and efficient way. It’s amazing to see how much time this saves compared to manual outreach.
Great article, thank you for sharing these insights! I’ve tested many methods for building backlinks, and what really worked for me was using AI-powered automation. aistudiodrive.com we can scale link building in a safe and efficient way. It’s amazing to see how much time this saves compared to manual outreach.
Great article, thank you for sharing these insights! I’ve tested many methods for building backlinks, and what really worked for me was using AI-powered automation. aistudiodrive.com we can scale link building in a safe and efficient way. It’s amazing to see how much time this saves compared to manual outreach.
Great article, thank you for sharing these insights! I’ve tested many methods for building backlinks, and what really worked for me was using AI-powered automation. aistudiodrive.com we can scale link building in a safe and efficient way. It’s amazing to see how much time this saves compared to manual outreach.
Great article, thank you for sharing these insights! I’ve tested many methods for building backlinks, and what really worked for me was using AI-powered automation. aistudiodrive.com we can scale link building in a safe and efficient way. It’s amazing to see how much time this saves compared to manual outreach.
Great article, thank you for sharing these insights! I’ve tested many methods for building backlinks, and what really worked for me was using AI-powered automation. With us, we can scale link building in a safe and efficient way. It’s amazing to see how much time this saves compared to manual outreach.
Great article, thank you for sharing these insights! I’ve tested many methods for building backlinks, and what really worked for me was using AI-powered automation. With us, we can scale link building in a safe and efficient way. It’s amazing to see how much time this saves compared to manual outreach.
Great article, thank you for sharing these insights! I’ve tested many methods for building backlinks, and what really worked for me was using AI-powered automation. With us, we can scale link building in a safe and efficient way. It’s amazing to see how much time this saves compared to manual outreach.