Skip to content
Platform status
Servergilde
Guides · Security

Metin2 DDoS protection for private servers

No setting on your server stops an attack that fills your uplink. With SYN floods, connection floods and login spam it's different, a lot of that you can handle yourself with pf on FreeBSD or nftables on Linux.

Updated November 26, 2026 · 11 min read

Pretty much every Metin2 server gets attacked at some point, usually around the opening, after a big update or when there is drama in the scene. It is rarely a professional. Most of the time someone paid a few euros for a service that sends traffic at your IP for a couple of minutes. What you can do about it depends on where the attack lands.

What kind of attacks you see

A volumetric flood is about raw volume. So much traffic hits your IP that the server's uplink is full, usually UDP packets amplified through open DNS or NTP servers. They do not need to match an open port, they just fill the line. You notice it because the whole server is gone, SSH and everything else on the same IP included.

A SYN flood is a huge number of TCP connection requests (SYN), usually from spoofed source addresses. The server keeps track of every half open connection and waits for a reply that never comes. Once that queue is full, real players can't get in, even though the uplink still has room.

In a connection flood, real machines or rented proxies open complete connections to auth and the channels and keep them open, or open new ones in quick succession. Each one takes a descriptor and some memory in the core, and with a few thousand of them the process hits its open files limit or spends all its time on connections that never start a game. Players then get kicked at login or when changing channels.

Login spam goes straight for the auth core. A script sends logins with made up or stolen credentials, every attempt is a lookup in the account database, and logins get slow for everyone. Often it is password guessing at the same time.

Before you change anything, look at what is actually coming in while it happens. These commands count half open connections and connections per source address. Take the port from your channel's CONFIG. On FreeBSD:

# netstat -s -p tcp | grep -iE "syncache|cookie" # sockstat -4c -p 13000 | awk 'NR>1 {split($7,a,":"); print a[1]}' | sort | uniq -c | sort -rn | head

On Linux:

# ss -tn state syn-recv | wc -l # ss -Htn state established '( sport = :13000 )' | awk '{print $4}' | cut -d: -f1 | sort | uniq -c | sort -rn | head

One address with hundreds of connections is a connection flood. Syncache and cookie counters climbing fast, or thousands of entries in syn-recv, is a SYN flood. Server unreachable and your host's panel shows a saturated port: volumetric.

If the server is reachable but slow and nothing looks odd, it is probably something else. Have a look at Metin2 server lag then.

What you can stop yourself

If your server has a 1 Gbit/s port and 50 Gbit/s arrive, the port is full before a single packet reaches your firewall. pf and nftables can only drop what already made it to your network card. Volume like that has to be filtered further upstream by something with more capacity than the attack, at your host or by a shield in front of your server. During large attacks many hosts also protect their own network first and null route the attacked IP for a while. You are offline either way.

What is left for your own server is SYN floods, connection floods and login spam. SYN cookies handle SYN floods, together with your host's filter. Connection floods and login spam need per address limits in the firewall, and login spam also needs login throttling in the source.

Almost every larger host advertises DDoS protection, but many filters are built for websites. Metin2 uses its own protocol over TCP on ports like 11002 or 13000, and a generic filter often reacts too late there or drops real players when in doubt. That is why some hosts sell game servers with a dedicated filter profile, where you tell them which ports and protocol you use. What we would ask before renting:

  • Is filtering always on, or does it start after an attack is detected, and how many seconds does that take?
  • Is there a profile or custom rules for TCP game traffic on ports you pick?
  • Can you put a firewall in front of the server that drops all UDP?
  • What happens when an attack is bigger than the filter? Null route, and for how long?

With common server files the game traffic is TCP only. Check it with sockstat -4l on FreeBSD or ss -ulnp on Linux. If your cores do not listen on any UDP port, an upstream rule that drops UDP to that IP is one of the most effective things you can do. Just keep the replies to your own DNS and NTP queries open (source ports 53 and 123), otherwise name resolution and time sync break.

Hide the real IP

The fewer people know the real IP of your game server, the less often it gets hit. Start with DNS: a record like play.yourserver.com shows the IP to anyone who looks it up, and services that collect DNS history keep old records after you delete them. If the website runs on the same IP, a ping on the domain is enough. So website, forum and patcher go on a different server, especially since the patcher's web server address sits in the launcher.

Default error pages from nginx or Apache, PHP error output and emails sent straight from the game server leak the address too, in emails it is in the Received header. Same for client changelogs, Discord, screenshots and console output you paste somewhere while asking for help. If a website on another server needs access to account, use a tunnel or a rule for that one address, see how to secure a Metin2 server.

You can't hide it completely that way, though. Anyone who plays connects straight to your cores and can see the IP with netstat. The client has the address in its config (in many clients serverinfo.py), and when a player warps to a map on another core, the server sends that core's address. Without a shield, the IP is only hidden from casual attackers, not from someone who makes an account.

If it is known and the attacks keep coming, get a new IP from your host, some charge a fee for it. Move to a shield at the same time, or the new address is public again after the first login.

Limits per source address

Connection floods and login spam are handled with a limit per source address. pf has max-src-conn for simultaneous connections and max-src-conn-rate for new connections in a time window, 10/10 means 10 in 10 seconds. Whoever goes over ends up in a table through overload, and flush global kills all their existing connections. Only connections with a completed handshake count, so this does nothing against SYN floods with spoofed sources.

An example /etc/pf.conf. Adjust the interface name (check ifconfig) and the ports from your cores' CONFIG:

ext = "vtnet0" auth = "11002" channels = "{ 13000, 13001, 13002, 13003 }" table <abusers> persist set skip on lo0 block in all pass out all keep state block in quick from <abusers> pass in on $ext proto tcp to port 22 keep state pass in on $ext proto tcp to port $auth keep state \ (max-src-conn 10, max-src-conn-rate 10/10, overload <abusers> flush global) pass in on $ext proto tcp to port $channels keep state \ (max-src-conn 30, max-src-conn-rate 20/10, overload <abusers> flush global)

Keep a second SSH session open while you work on the firewall, a broken rule can lock you out otherwise. If pf is not running yet, enable it with sysrc pf_enable=YES and service pf start. Then test, load, look at the block list and unblock an address:

# pfctl -nf /etc/pf.conf # pfctl -f /etc/pf.conf # pfctl -t abusers -T show # pfctl -t abusers -T delete 203.0.113.7

So nobody stays blocked forever, this line in /etc/crontab runs every ten minutes and removes addresses that have been in the table for more than an hour:

*/10 * * * * root /sbin/pfctl -t abusers -T expire 3600

Don't set the limits too tight. Several players often share one address, a family for example, or mobile users behind carrier grade NAT (CGNAT), and every channel change or warp to another core opens a new connection. Watch the table during the first days and raise the numbers if real players end up in it.

On Linux you do the same with nftables, the default on current Debian and Ubuntu: dynamic sets that count open connections per address with ct count and measure new ones with limit rate, plus a set with a timeout as the block list. Test the file with nft -c -f before loading it. On older systems with iptables, connlimit and hashlimit do the same job, but for a block list with expiry like in pf you need ipset or the recent module on top.

SYN cookies

With SYN cookies the server can still accept connections when the queue of half open connections overflows during a SYN flood. FreeBSD and the common Linux distributions have it on by default. Check anyway, on FreeBSD:

# sysctl net.inet.tcp.syncookies net.inet.tcp.syncookies: 1

If it says 0, enable it with sysctl net.inet.tcp.syncookies=1 and add net.inet.tcp.syncookies=1 to /etc/sysctl.conf so it survives a reboot. On Linux:

# sysctl net.ipv4.tcp_syncookies net.ipv4.tcp_syncookies = 1

That only helps as long as the uplink is not full. Against a flood that saturates the port, SYN cookies are as useless as any other rule on the server.

Protection in the source

A firewall only sees addresses and connections. What a client sends inside a connection is only handled by the core, so some of the protection belongs in the source. How much of it you already have depends on your server files.

Packet limits, for one. A client that sends more packets per second than a player could ever need gets disconnected, otherwise a single connection can put heavy load on a core by spamming chat or movement packets. The core should also close connections that have not logged in after a few seconds, so a connection flood does not leave dead connections hanging around. The auth core needs login throttling: after several wrong passwords for one account or from one address, add a waiting period, and log the failed attempts so you can spot patterns. A per address limit inside the core is worth having on top of the firewall, because it keeps working when a shield passes the real player IP through.

Also run ulimit -n in the shell you start the cores from to see how many connections a process may hold at all. On FreeBSD sysctl kern.maxfilesperproc applies as well.

Always test this kind of change on a test server with several clients first. Packet limits that are too strict disconnect real players, when they pick up drops quickly or when a whole group uses skills at once.

A shield with a tunnel

The best protected game server is one players never reach directly. For that you put a second server at a host with strong filtering in front of it, the shield. Only the shield's address is in the client and the launcher, and it forwards the auth and channel ports through a tunnel to the game server, over WireGuard (encrypted) or GRE (not encrypted, and your host has to allow the protocol). The game server only accepts game connections from the tunnel. When the shield is attacked, its host filters the traffic, and if it goes down anyway you move to a second shield without touching the game server. Pick one close to the game server, ideally in the same country, every detour adds to the ping.

A plain proxy like haproxy or nginx in stream mode does work, but then every player seems to come from the shield's address, and IP bans, multi client limits and the rules above stop doing anything. The PROXY protocol, which such proxies use to pass on the real address, is not understood by the cores unless you change the source. Forwarding works better than proxying: the shield only rewrites the destination address (DNAT) and sends the packets through the tunnel with the original source address. The replies from the cores then have to go back through the tunnel too, not out the normal route.

Before you switch, check which address your cores send to the client during a warp. Depending on the source it comes from the CONFIG (often PUBLIC_IP) or from the network interface. It has to be the shield's address, otherwise the client gets the real IP on the first map change. So test a warp between two cores, and close the game ports on the public interface after that.

What not to do

Don't hit back. Attacking other servers is a crime in Germany (computer sabotage, § 303b StGB) and in most other countries, and you would usually hit the wrong target anyway: the addresses in your logs often belong to hijacked devices or to servers abused as amplifiers.

Stay away from "bypass" or "anti DDoS" tools from forums that claim to stop every attack. They run as root on your server, and quite a few of them come with a backdoor. You should be able to read and understand every rule you load. Same for long lists of sysctl values from the internet, they often do nothing or cause new problems.

Don't pay. If you pay once, they usually come back. Keep the messages and timestamps and report it to the police. And don't hand out the IP, not to partners, not to server list sites, not to new team members who don't need it.

DDoS shield and monitoring at Servergilde

The DDoS shield from Servergilde works on the principle above, with your own protected address, an encrypted tunnel and real player addresses for bans. Per address limits and a block list with expiry are part of the base protection package, set up on your server for FreeBSD and Linux. You can start for free with the monitoring on the platform, which tells you on Discord and by email when a core crashes, and the daily server check for open database and P2P ports. Still planning your server? Read how to start a Metin2 server too.

Frequently asked questions

Can a firewall stop DDoS on a Metin2 server?
Only part of it. pf and nftables only drop packets that already reached your network card. If 50 Gbit/s hit a 1 Gbit/s port, the port is full before the firewall sees anything, and only your host's filter or a shield helps. Connection floods and login spam you can stop yourself with per address limits, SYN floods with SYN cookies.
Does Metin2 use UDP?
With common server files the game traffic is TCP only. Check with sockstat -4l on FreeBSD or ss -ulnp on Linux. If your cores don't listen on any UDP port, having your host drop UDP to your IP upstream is one of the most effective steps. Keep the replies to your own DNS and NTP queries open (source ports 53 and 123).
How do I hide my Metin2 server IP?
No A records on the game server, website, forum and patcher on another machine, and keep the address out of error pages, emails, changelogs, Discord and screenshots. That only stops casual attackers, though. Anyone who plays can see the IP, and a warp sends the target core's address to the client. Only a shield with a tunnel fixes that.
How many connections per IP should I allow?
A starting point for pf: 10 simultaneous and 10 new per 10 seconds on auth, 30 and 20 per 10 seconds on the channels. On Linux the same works with ct count and limit rate in nftables, or connlimit and hashlimit in iptables. Don't go too low, several players often share one address.

Free monitoring

Monitoring is free and tells you on Discord when a core crashes or your server goes down.