Routing Various Domain Subnets To The Same IP But Changing The Port

I host a bunch of game servers that all route through one port by default, I can change the port each server uses and for example the port numbers are: 17701-17705

These five ports host their own server and what I want to do is to add a record or subnet name that will route to one of the five ports on this one IP. ex.

all records will go to say IP

server1.domain.suffix (.com or whatever) will route to port 17701
server2.domain.suffix (.com or whatever) will route to port 17702
server3.domain.suffix (.com or whatever) will route to port 17703
server4.domain.suffix (.com or whatever) will route to port 17704
server5.domain.suffix (.com or whatever) will route to port 17705

There is nothing different going on at Cloudflare here to make this work, just create 5 different “A” DNS records with their own subdomains.

The only thing you need to do is have your client software choose one port/subdomain each time it tries to connect to your server, ie. Cloudflare can’t automatically steer traffic to different ports or anything.

That’s exactly what I wanted to avoid really. I don’t want my clients to enter the ports rather that they just remember the subdomain name rather than a number. easier to remember than

That would require something like HaProxy, AWS network load balancer, etc. to load balance the TCP/UDP connections between your servers. Cloudflare only provides load balancing if it’s for HTTP(S) traffic.

It’s not load balancing, its routing.

that’s what i’m looking to do

the green ones are what I think I want the DNS records to do

I only have one IP address

“Routing” you show here is really proxying the traffic from one port to another, it’s not a feature of DNS. CF actually does provide this service, but it’s an enterprise feature. #security:spectrum.

CF doesn’t provide this to non-enterprise customers due to the amount of abuse that could be possible (inspecting non-HTTP traffic is a complicated issue for detecting abuse) and the pricing for it could get complicated. Vote on this IPv6 Spectrum for non‑Enterprise customers if you’re interested.


alright, i’ll have to think of alternatives then. ultimately if I got an IP for each server I wouldn’t have an issue but I can’t do that. hmm

I don’t really know how an mx record functions but from what I understand it if you have two domains mx records going to the same say exchange server navigates the traffic based on the domain is it possible to do something like this for server connections.

Or should I just stick with adding the ports onto the ip’s? lol

If the client supports SRV records, this would fix the problem by allowing your DNS to specify the correct port to connect to, but SRV record support has to be in the client.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.