Introduction
More and more cloud providers are offering IPv6-only VPS plans or adding IPv6 addresses to their servers. The reason is straightforward: IPv4 addresses are exhausted, while IPv6 resources are plentiful and significantly cheaper
IPv6-only VPS instances are typically very affordable, making them an attractive option for hosting private game servers
Meanwhile, a server tucked behind an IPv6 address is far less susceptible to DDoS attacks
The reality, however, is that the vast majority of game servers do not natively support pure IPv6 connections — and CS2 is no exception
That’s why I built PortRelay — a lightweight port relay tool
With it, you can run a CS2 server on an IPv6-only VPS and let completely unmodified CS2 clients connect over IPv6 without any extra configuration
Architecture Overview
The core idea is simple: the CS2 server listens only on the local loopback address, while PortRelay-Server handles the public-facing IPv6 endpoint
On the player’s machine, PortRelay-Client runs locally, simulating a CS2 server address — all traffic is forwarded through an IPv6 tunnel
1 | CS2 Client |
| Component | Location | Description |
|---|---|---|
| CS2 Server | IPv6-only VPS | Listens only on 127.0.0.1:27015, never exposed to the public |
| PortRelay-Server | Same VPS | Listens on [::]:9000, forwards tunnel traffic to the local CS2 |
| PortRelay-Client | Player’s machine | Listens on 127.0.0.1:27015, establishes an IPv6 tunnel to the server |
Prerequisites
- An IPv6-only VPS to run the CS2 server and PortRelay-Server
- IPv6 network access on the player’s machine
Step 1: Deploy the CS2 Server on the VPS
We won’t walk through the standard CS2 dedicated server installation here. Just make sure of two things:
- The CS2 server binary is installed and starts correctly on your VPS
- Add
-ip 127.0.0.1to the startup parameters so it listens only on the loopback address, never directly exposed to the public
Step 2: Deploy PortRelay-Server on the VPS
2.1 Download
Grab the latest release for your platform from Releases and extract it to any directory
You can also fork the source and build it yourself (requires Go 1.24+)
2.2 Configure PortRelay-Server
Create server.json:
1 | { |
Key fields:
| Field | Value | Description |
|---|---|---|
listen_port |
9000 |
Public listening port, awaits client connections |
listen_protocol |
all |
Accept both TCP and UDP connections |
service_target |
127.0.0.1:27015 |
Forward target: the local CS2 server |
passwd |
your choice | Clients must present the same password |
2.3 Start PortRelay-Server
1 | # Foreground (testing) |
When the server starts successfully, you should see logs similar to:
1 | User@LinuxServer:~/portrelay$ ./portrelay-linux-amd64 |
Once confirmed working, consider setting it up as a systemd service for automatic restart on boot
Step 3: Configure PortRelay-Client on the Player’s Machine
3.1 Download
Download the version for your operating system from Releases
3.2 Create the Configuration File
Create client.json:
1 | { |
| Field | Value | Description |
|---|---|---|
listen_local |
127.0.0.1:27015 |
Local listen address — CS2 connects here |
server_ip |
[VPS IPv6]:9000 |
Server’s IPv6 address and port |
server_passwd |
your choice | Must match the server-side configuration |
transport |
auto |
Automatic transport protocol selection |
3.3 Start PortRelay-Client
1 | ./portrelay --config client.json |
A Connected log entry means the tunnel is established:
1 | 2026/05/26 21:18:03 [Tunnel "cs2-tunnel"] Connected | server=[IPv6-Address]:9000 | transport=UDP | listen=all |
Keep this process running (or set it up as a background service)
Step 4: Connect to the Server
Launch CS2, open the developer console with ~, and enter:
1 | connect 127.0.0.1:27015 |
CS2 sends traffic to the local PortRelay-Client, which forwards it through the IPv6 tunnel to the CS2 server on your VPS. The player never needs to be aware of any intermediate layers
Summary
PortRelay goes beyond this demo. In addition to the IPv6-over-IPv4 scenario covered here, it also supports:
- Encapsulating UDP traffic inside a TCP tunnel (or vice versa), improving connectivity in restricted network environments
- Accepting configuration via Base64-encoded JSON passed directly as a CLI argument, making it easy to integrate with third-party programs or wrap in custom scripts
- Embedding into custom clients to take advantage of cheap IPv6 resources while shielding your server from DDoS attacks
If you have any questions or suggestions, feel free to open an issue on GitHub