Create a custom (sub-)domain for your MC Server¶
I'm in the process of creating a Minecraft Server. And at one point in that process did I had to setup a custom subdomain for it.
Since I was not running a server for such a long time did I had to look up tutorials, bud sadly, these tutorials either didn't explain how you set up a DNS entry with Cloudflare, showed outdated pictures and info on Cloudflare or explained it so poorly, that it didn't help.
So after figuring it out did I now decide to create my own quick guide to explain things. Enjoy.
Note¶
- This Guide will only cover how you setup the necessary DNS Entries using Cloudflare. Other DNS Services such as Namecheap or GoDaddy may have different setups for adding new DNS Entries. It's therefore important to do your own research where necessary.
- I will use the IP
192.0.2.0and the Domainexample.comthroughout this Guide which are both examples1 and should be replaced with the IP of your server and the Domain you want to use. - To keep the Guide simple to read will I use "domain" to cover both Apex (main) and Sub-Domains, unless where a separation is required for clarity.
1. Choice of Domain and if it should be a Sub-Domain¶
The first and most important step is to decide what Domain you would like to use and whether it should be a Sub-Domain or not.
The Domain you chose is important, as not only will it be the address players use to join your server, but it will also have an influence on the A- and SRV-Records of your Domain itself.
2. Creating the DNS Entries¶
Once you've selected the Domain you would like to use is it time to implement the necessary DNS-Entries.
For your custom Domain to work will you need an A-Record and a SRV-Record.
2.1 A-Record¶
Your Domain requires an A-Record that points to your server's IP.
The Entry may look different depending on if you chose an Apex-Domain or Sub-Domain, with the later having the sub-domain set as the domain's name value, and the former either having no value set, or an @ to indicate it as root.
Here are examples of A-Records for an Apex-Domain and a Sub-Domain respecively:
| Type | Name | IPv4 address | Proxy Status2 | TTL |
|---|---|---|---|---|
A |
@ |
192.0.2.0 |
DNS only |
Auto |
A |
mc |
192.0.2.0 |
DNS only |
Auto |
Keep in mind you only need ONE of these entries, depending on whether you want to use a sub-domain or not.
2.2 SRV-Record¶
The SRV-Record is important for when your server is NOT using the default port 25565, but it also doesn't hurt creating one for the default port to avoid possible issues or conflicts.
Creating a SRV-Record shows a lot of fields to fill out and it's not quite easy to understand what field requires what value.
I'll give you the SRV-Record - again both for an Apex-Domain and a Sub-Domain and explain each part after:
| Type | Name | Priority | Weight | TTL | Port | Target |
|---|---|---|---|---|---|---|
SRV |
_minecraft._tcp |
0 |
0 |
Auto |
25566 |
example.com |
SRV |
_minecraft._tcp.mc |
0 |
0 |
Auto |
25566 |
example.com |
SRV |
_minecraft._tcp |
0 |
0 |
Auto |
25566 |
mc.example.com |
SRV |
_minecraft._tcp.mc |
0 |
0 |
Auto |
25566 |
mc.example.com |
You may have noticed that these entries can have either _minecraft._tcp or _minecraft._tcp.mc and point either to example.com or mc.example.com.
This is due to how SRV-Records work, which are in the most basic explanation instructions to serve a specific (sub-)domain on a specific port, if a request for a specific service on a specific protocol for a specific (sub-)domain is received.
Either way, let's quickly cover the different parts:
Nameis used to define the Service, Port and optionally Sub-Domain in the format_<service>._<protocol>[.<sub-domain>].
This means, if you want to use a sub-domain you will need to add the sub-domain.<service>and<protocol>are alwaysminecraftandtcp.PriorityandWeightshouldn't need any modifications and can usually stay at 0.TTLcan stay onAuto, but you can also adjust it to some value such as1 hour.Portwould be the Port your server uses. In my example did I use25566, but you should use your server's port.Targetneeds to be the full domain of the A-Record you've created earlier. This means if your domain isexample.comand you've made an A-Record with namemc, the entry needs to bemc.example.com
3. Testing connection¶
Once you've saved your entries and made sure you've filled them out correctly should you test whether it works or not.
One site you can use is mcsrvstat.us. Just enter the Domain you've setup and see if your server appears. If it doesn't, check that your domain returns the right DNS-Entries i.e. by using some tool.
It may also take up to 48 hours for DNS entries to get refreshed, so if it doesn't work, try again a few days later. If it still doesn't work, then you may have some wrongly configured DNS.
Conclusion¶
I hope this small guide helped you in configuring a Domain for your MC-Server.
If something is unclear to you, can you ask me via Mastodon (Handle is @andre_601@swiss.social) or on my personal Discord Server.
Footnotes
Comments
Comment system powered by Mastodon.
Leave a comment using Mastodon or another Fediverse-compatible account.