Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

Custom Domain for CS2 Server: Hostname & Port Guide

· 5 min read · Home Tech

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

This guide explains how to set up a custom domain name for your Counter-Strike 2 (CS2) dedicated server, so players can connect using a memorable address like play.yourclan.com instead of a raw IP and port. You’ll learn how to configure DNS records, adjust your server’s hostname, and ensure the port is correctly handled. Before starting, you’ll need a registered domain name, access to its DNS settings, and the ability to edit your server’s configuration files.

What You'll Need

  • A registered domain name (e.g., yourclan.com) with DNS management access.
  • A CS2 dedicated server that is already running and reachable via IP.
  • SSH or console access to the server (to edit config files and restart the service).
  • Basic knowledge of DNS records (A, CNAME, SRV).

Step-by-Step

  1. Determine your server’s public IP and port. Your CS2 server listens on a specific UDP port (default is 27015). Note the public IP address and the port you are using.
  2. Log in to your domain registrar or DNS provider. This is where you manage DNS records for your domain (e.g., Cloudflare, Namecheap, GoDaddy).
  3. Create an A record for your hostname. Add a new record with type A, name (host) play (or any subdomain you prefer), and point it to your server’s public IP address. If you want the domain root itself, use @ as the name. Save the record.
  4. Set up a port-forwarding rule (if needed). If your server is behind a router or firewall, forward UDP traffic on your chosen port to the server’s local IP. This is often already done if the server is publicly reachable.
  5. Configure the CS2 server hostname. In your server’s server.cfg file, set the hostname to a friendly name that includes your domain, e.g., hostname "My Clan Server - play.yourclan.com". This is optional but helps players identify the server.
  6. Add an SRV record for automatic port discovery (optional but recommended). Some game browsers and server lists can use SRV records to find the correct port. Create a new SRV record with service _cs2, protocol _udp, name play (or blank for root), target play.yourclan.com, port 27015, priority 0, weight 5. This is not strictly required for direct connection, but it helps with some launchers.
  7. Test the DNS propagation. After saving DNS records, wait a few minutes (or up to 24 hours for full propagation). Use a tool like nslookup play.yourclan.com to verify the A record resolves to your server’s IP.
  8. Restart your CS2 server. After making config changes, restart the server process to apply the new hostname. The server will continue to listen on the same port.
  9. Connect using the custom domain. In CS2, open the console and type connect play.yourclan.com:27015 (replace port if different). The game should connect to your server.

Common Mistakes

  • Using a CNAME for the root domain. CNAME records cannot be used at the domain root (e.g., yourclan.com). Use an A record for the root or a subdomain.
  • Forgetting the port. Even with a custom domain, players must specify the port unless you use SRV records and a compatible client. The default port is 27015, but if you changed it, include it.
  • Incorrect SRV record syntax. Many providers have specific fields for service, protocol, and name. Double-check that the service is _cs2 and protocol is _udp.
  • Not waiting for DNS propagation. DNS changes can take time. Testing immediately after saving may show the old IP.

Tips

  • Use a short, memorable subdomain like play or cs to make it easy for players to type.
  • Set a low TTL (e.g., 300 seconds) on your DNS records before making changes, so updates propagate faster. After it’s stable, you can increase TTL.
  • If you have multiple servers, use different subdomains (e.g., eu1.yourclan.com, eu2.yourclan.com) and different ports.
  • Keep your server’s hostname in sync with the domain so players see a consistent name.
  • Consider using a free DNS service like Cloudflare for better performance and DDoS protection, but ensure you keep your origin IP hidden if you do.

Troubleshooting

  • Domain doesn’t resolve to your IP. Check that the A record is correct and that you’re not using a CNAME where an A record is needed. Use nslookup or an online DNS checker to see what the record resolves to.
  • Connection times out. Verify that the server is actually listening on the port (use netstat -an | grep 27015 on Linux). Ensure the firewall allows UDP traffic on that port. Test connecting via IP first to isolate the issue.
  • SRV record not working. Not all clients support SRV records for CS2. Most players will need to include the port manually. Ensure the SRV record’s target is a fully qualified domain name ending with a dot (e.g., play.yourclan.com.) in some DNS providers.
  • Server shows as offline in the browser. The server browser may take time to update. Also, ensure your server is using the correct sv_visiblemaxplayers and that it’s not behind NAT without proper port forwarding.
  • Port is already in use. If you changed the port in the config, make sure you’re connecting to the new port and that the DNS SRV record (if any) matches.

Frequently Asked Questions

Do I need an SRV record for a custom domain?

No, it’s optional. Most players will connect by typing connect yourdomain.com:27015. SRV records are used by some server browsers and launchers to automatically find the port, but they are not universally supported.

Can I use a CNAME record for my CS2 server?

Yes, for a subdomain like play.yourclan.com, you can use a CNAME pointing to another hostname (e.g., your hosting provider’s hostname). However, you cannot use a CNAME for the root domain. Also, if you point to an IP, use an A record.

My domain is on Cloudflare. Do I need to proxy it?

No, you should set the DNS record to “DNS only” (grey cloud) because game traffic is not HTTP and the proxy can interfere with UDP packets. Proxying is meant for web traffic.

How long does DNS propagation take?

It can take from a few minutes to 24 hours, depending on your TTL and the DNS provider. Using a low TTL (e.g., 300 seconds) speeds up propagation.

Can I use a custom domain without changing the port?

Yes, the port is independent of the domain. You can keep the default port 27015 and just map the domain to your IP. Players still need to include the port unless they use a client that reads SRV records.

What if I want to use the root domain (e.g., yourclan.com) for my server?

You can create an A record for the root (@) pointing to your server IP. Then players can connect with connect yourclan.com:27015. Note that you cannot use a CNAME for the root.