FiveM DDoS Protection Guide: Hosting, VPS Firewall and Proxy Setup

Published on | Updated

How DDoS attacks hit a FiveM server on port 30120, what to ask a host, and the server.cfg, firewall and proxy settings from the Cfx.re docs, on a game server plan or a VPS.

fivem ddos protection guide

When your FiveM server grows, it becomes a target. Sometimes it is random. Sometimes it is a rival city or a player you banned. Sometimes it is just bored people.

The point is not to be scared. The point is to host in a way where an attack does not take your city offline, and to know which settings on your own side actually help.

Security

Table of Contents

  1. What an attack on a FiveM server looks like
  2. Layer 1: protection at the host
  3. Game server plan or VPS
  4. Layer 2: server.cfg settings
  5. Layer 3: firewall rules on a VPS
  6. Layer 4: a proxy in front of the server
  7. What does not work
  8. Spotting an attack early
  9. DDoS protection on Space-Node

1. What an attack on a FiveM server looks like

The server is fine, then everyone lags at the same moment, then players time out. That pattern is common.

FXServer listens on one port, 30120 by default, over both TCP and UDP. The example server.cfg in the Cfx.re setup guide opens both:

endpoint_add_tcp "0.0.0.0:30120"
endpoint_add_udp "0.0.0.0:30120"

The TCP side is a small web server that serves info.json, players.json and dynamic.json. A client that joins first fetches info.json and then sends a POST to /client, and the server list backend queries this side too. The UDP side carries the game itself. Cfx.re's proxy setup page walks through the whole connection process.

That gives an attacker two main targets:

  1. Floods that fill the line. So much traffic at your IP, usually UDP, that the network link in front of the server is full. Nothing that runs on the server can stop this, because the link is already full by the time the packets reach your machine. It has to be filtered before it gets there.
  2. Request floods on the TCP side. Large numbers of HTTP requests against the .json endpoints. FXServer has a setting for this, sv_requestParanoia, covered in the server.cfg section below.

Crash exploits, where a cheater sends malformed packets, spams entities or abuses a broken script until the server falls over, are a different problem with different fixes. Our FiveM crasher protection guide covers those.

2. Layer 1: protection at the host

Floods that fill the line can only be stopped upstream, in the network your host runs on. Many providers write "DDoS protected" on every plan, so ask before you buy:

  • Is protection included, or is it a paid add-on?
  • Does it filter game traffic over UDP, or only web traffic? FiveM's game traffic is UDP on port 30120.
  • What happens during a large attack? If the answer is that they null route your IP, that is not protection. A null route drops all traffic to the IP, real players included, so the attacker gets what they wanted.
  • How do you reach support during an attack, and at what hours?

Clear answers to these questions tell you more than a capacity number on a sales page.

3. Game server plan or VPS

Both work for FiveM. The difference is who handles which layer.

  • A game server plan comes with the panel, txAdmin and the host's DDoS filtering already set up. You look after resources, the database and server.cfg.
  • A VPS gives you root access. You install FXServer and txAdmin yourself, run the database yourself, keep the system patched and write your own firewall rules. FXServer runs on Windows and Linux, though Cfx.re calls the Linux build "a courtesy port" and says issues are more likely to get fixed on the Windows version.

The host's filtering sits in front of both. A VPS is worth it when you want your own firewall, a proxy or other services next to FXServer. If you would rather spend the time on your city, a game server plan is less work.

4. Layer 2: server.cfg settings

Two settings from the Cfx.re server commands reference help here:

# hide player IP addresses in the server's public reports
set sv_endpointPrivacy true

# block IPs that send HTTP requests with a 'Via' header
set sv_requestParanoia 1

sv_endpointPrivacy hides player IP addresses from the public reports the server outputs, so nobody can read them from your server and go after individual players.

sv_requestParanoia "helps counter proxy-based HTTP floods", in Cfx.re's words. Level 1 blocks IPs that send requests with a Via header. Level 2 also blocks requests with an Upgrade-Insecure-Requests header, which includes every browser request to the .json endpoints, and from level 2 up the info.json, dynamic.json and players.json endpoints answer "Nope." Level 3 also closes the socket. Start with 1, and check that players can still join and that your server list entry still looks right before you go higher.

5. Layer 3: firewall rules on a VPS

On a VPS you can add rules of your own. Two warnings first. Rules on the server do nothing against a flood that already fills the line, so they only help against smaller floods from a few addresses. And a wrong rule can lock you out of SSH, so keep your host's console open while you change them. Whatever firewall you use, keep SSH allowed and port 30120 open for both TCP and UDP.

A per source rate limit on the game port, with the dynamic set syntax from the nftables wiki:

nft add table inet fivem
nft add chain inet fivem input '{ type filter hook input priority 0; policy accept; }'
nft add set inet fivem udp_rate '{ type ipv4_addr; timeout 60s; flags dynamic; }'
nft add rule inet fivem input udp dport 30120 update @udp_rate '{ ip saddr limit rate over 200/second }' drop

Each IPv4 source address gets its own counter. Packets above 200 a second from one address are dropped, and an address that sends nothing for 60 seconds drops out of the set. The rule does not cover IPv6. 200 is a starting value, not a measured one: if real players start to time out, raise it. Rules added with nft add are gone after a reboot unless you also put them in your distribution's nftables config.

An older version of this guide also had a rule that dropped ip frag-off != 0. Do not use it. nftables reads frag-off as the whole 16 bit field, flags included, so the rule also matches ordinary packets that only carry the "don't fragment" flag, and that can include your own SSH session.

6. Layer 4: a proxy in front of the server

For a server under repeated attack, Cfx.re documents a reverse proxy setup on its proxy setup page. It has two parts, and you can set up either one on its own:

  • a connect proxy: any HTTPS reverse proxy on port 443 that forwards to FXServer's TCP port. Cfx.re's example uses nginx, with the hostname proxied through Cloudflare.
  • a server proxy: a raw TCP and UDP proxy on the game port that forwards to the real server, for example with the nginx stream module.
players  ->  server1.example.com (your proxies)  ->  FXServer on its real IP

In server.cfg you then tell FXServer about the proxies. These lines follow the Cfx.re example:

# do not advertise the server with its real IP
set sv_forceIndirectListing true
# the server list contacts https://server1.example.com/ instead
set sv_listingHostOverride "server1.example.com"
# proxies that may send X-Real-IP and skip the rate limiter
set sv_proxyIPRanges "100.64.1.1/32"
# the server endpoint players connect to: the server itself or your server proxy
set sv_endpoints "100.64.1.2:30120"

Players then join with connect "https://server1.example.com/" or a join link. The Cfx.re page notes that in this setup the client does not look up a bare domain as a URL.

Three things decide whether this actually helps:

  • The proxy needs DDoS filtering of its own. Otherwise the attack simply moves to the proxy.
  • The real IP has to stay unknown. If it was public before, attackers can keep hitting it directly, so let only the proxy reach FXServer, or move the server to a new IP.
  • The proxy runs on a machine you control, so this fits a VPS better than a game server plan.

7. What does not work

  • Cloudflare's normal proxy for the game traffic. A proxied (orange cloud) DNS record routes HTTP and HTTPS through Cloudflare, as its proxy status docs explain. That covers the connect proxy above, but FiveM's game traffic is UDP. Cloudflare Spectrum can carry UDP, but its protocols per plan table lists UDP only as a paid add-on with Spectrum Enterprise.
  • Anti DDoS resources from forums. A FiveM resource runs inside FXServer. By the time it sees anything, the traffic has already crossed your link, so it cannot stop a flood.
  • A null route as the plan. It ends the attack by taking your server offline, which is what the attacker wanted.

8. Spotting an attack early

If you run your own VPS, set up Prometheus with node_exporter and alert on:

  • inbound bandwidth above 80% of your uplink for a minute,
  • a UDP packet rate far above your normal peak,
  • one CPU core above 95% for five minutes.

If you see it while it happens, you can send your host the start time and the graphs. If you only hear about it from players the next morning, the evening is already lost.

9. DDoS protection on Space-Node

  • Every Space-Node FiveM plan includes DDoS protection in every region, at no extra cost. txAdmin comes pre-installed, and the server is provisioned automatically after checkout, in 2 to 5 minutes.
  • Every Space-Node VPS includes DDoS protection, NVMe storage and a 1 Gbps uplink, with full root access for your own firewall rules or a proxy. Ask us before you order if you need Windows, so we can confirm compatibility, licensing and any extra cost.
  • If you think your server is under attack, reach us through live chat, Discord or email, between 08:00 and 20:00 UTC.

Build your city on a Space-Node FiveM server with DDoS protection included. Browse our FiveM hosting plans to find the right fit for your community.