What do you think for this guide I made with chatgpt is it enough for protecting the server? It also recommends to do not use SYNPROXY+IPSET if the server does not have many players as it is not luckily it will attract serious attacks and the rest are enough as it can cause login issues to 1-2% of players and it will be needed to find a manually solution for them. If you have something extra to suggest I would be glad to here.
bash
ΑντιγραφήΕπεξεργασία
Create Admin User:
bash
ΑντιγραφήΕπεξεργασία
Secure SSH Access:
bash
ΑντιγραφήΕπεξεργασία
Edit:
bash
ΑντιγραφήΕπεξεργασία
bash
ΑντιγραφήΕπεξεργασία
Allow Only Proxy VPS and Website VPS:
bash
ΑντιγραφήΕπεξεργασία
Default Policies:
bash
ΑντιγραφήΕπεξεργασία
Now only trusted servers can talk to your GameServer and Database.
ΑντιγραφήΕπεξεργασία
ΑντιγραφήΕπεξεργασία
bash
ΑντιγραφήΕπεξεργασία
Add:
ini
ΑντιγραφήΕπεξεργασία
Apply:
bash
ΑντιγραφήΕπεξεργασία
This will optimize your server for hundreds of players.
bash
ΑντιγραφήΕπεξεργασία
Secure MariaDB:
bash
ΑντιγραφήΕπεξεργασία
Allow External Trusted Access:
Edit:
bash
ΑντιγραφήΕπεξεργασία
Change:
ini
ΑντιγραφήΕπεξεργασία
Restart MariaDB:
bash
ΑντιγραφήΕπεξεργασία
Database will now allow trusted external connections.
bash
ΑντιγραφήΕπεξεργασία
Create CMS Web User:
sql
ΑντιγραφήΕπεξεργασία
CMS can access only login DB with limited rights.
ini
ΑντιγραφήΕπεξεργασία
server.properties
ini
ΑντιγραφήΕπεξεργασία
Proper HAProxy v2 connection.
Hides real IP addresses.
ΑντιγραφήΕπεξεργασία
Players connect through your proxy securely.
Install needed packages:
bash
ΑντιγραφήΕπεξεργασία
IPSet Creation:
bash
ΑντιγραφήΕπεξεργασία
Kernel Optimization (Extra /etc/sysctl.conf entries):
bash
ΑντιγραφήΕπεξεργασία
Apply:
bash
ΑντιγραφήΕπεξεργασία
Firewall Raw Table (Pre-filtering attackers early):
bash
ΑντιγραφήΕπεξεργασία
SYNPROXY Setup (catch fake TCP SYN attacks):
bash
ΑντιγραφήΕπεξεργασία
Your firewall now handles SYN flood, botnet TCP floods, bad packets, and spoofed traffic!
Save All Rules:
bash
ΑντιγραφήΕπεξεργασία
After setup and testing, create a VPS snapshot.
If anything happens, you restore in 5 minutes — no need to redo setup.
2. Basic System Hardening
Update System:bash
ΑντιγραφήΕπεξεργασία
Code:
sudo apt update && sudo apt upgrade -y
bash
ΑντιγραφήΕπεξεργασία
Code:
sudo adduser gameserveradmin
sudo usermod -aG sudo gameserveradmin
bash
ΑντιγραφήΕπεξεργασία
Code:
sudo nano /etc/ssh/sshd_config
PermitRootLogin no
PasswordAuthentication no
(use SSH keys)
bash
ΑντιγραφήΕπεξεργασία
Code:
sudo systemctl restart sshd
3. UFW Strict Firewall Setup
Install UFW:bash
ΑντιγραφήΕπεξεργασία
Code:
sudo apt install ufw -y
bash
ΑντιγραφήΕπεξεργασία
Code:
sudo ufw allow from PROXY_VPS_IP to any port 2121 proto tcp
sudo ufw allow from PROXY_VPS_IP to any port 7778 proto tcp
sudo ufw allow from WEBSITE_VPS_IP to any port 3306 proto tcp
sudo ufw allow ssh
bash
ΑντιγραφήΕπεξεργασία
Code:
sudo ufw default deny incoming
sudo ufw default allow outgoing
sudo ufw enable

4. Fail2Ban Setup
bashΑντιγραφήΕπεξεργασία
Code:
sudo apt install fail2ban -y
sudo cp /etc/fail2ban/jail.conf /etc/fail2ban/jail.local
sudo systemctl enable --now fail2ban
5. CrowdSec Setup
bashΑντιγραφήΕπεξεργασία
Code:
curl -s https://install.crowdsec.net | sudo bash
sudo systemctl enable --now crowdsec-firewall-bouncer-nftables
6. System Network Tuning
Edit /etc/sysctl.conf:bash
ΑντιγραφήΕπεξεργασία
Code:
sudo nano /etc/sysctl.conf
ini
ΑντιγραφήΕπεξεργασία
Code:
# Performance tuning
net.core.somaxconn = 4096
net.ipv4.ip_local_port_range = 1024 65000
net.ipv4.tcp_fin_timeout = 15
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_max_syn_backlog = 4096
net.ipv4.tcp_window_scaling = 1
net.ipv4.tcp_rmem = 4096 87380 6291456
net.ipv4.tcp_wmem = 4096 65536 6291456
net.ipv4.tcp_congestion_control = cubic
bash
ΑντιγραφήΕπεξεργασία
Code:
sudo sysctl -p

7. MariaDB Installation and Hardening
Install MariaDB:bash
ΑντιγραφήΕπεξεργασία
Code:
sudo apt install mariadb-server -y
sudo systemctl enable --now mariadb
bash
ΑντιγραφήΕπεξεργασία
Code:
sudo mysql_secure_installation
Edit:
bash
ΑντιγραφήΕπεξεργασία
Code:
sudo nano /etc/mysql/mariadb.conf.d/50-server.cnf
ini
ΑντιγραφήΕπεξεργασία
Code:
bind-address = 0.0.0.0
bash
ΑντιγραφήΕπεξεργασία
Code:
sudo systemctl restart mariadb

8. Database User Setup
Login to MySQL:bash
ΑντιγραφήΕπεξεργασία
Code:
sudo mysql -u root -p
sql
ΑντιγραφήΕπεξεργασία
Code:
CREATE USER 'cmswebuser'@'WEBSITE_VPS_IP' IDENTIFIED BY 'yourstrongpassword';
GRANT SELECT, INSERT, UPDATE ON login.* TO 'cmswebuser'@'WEBSITE_VPS_IP';
FLUSH PRIVILEGES;
EXIT;

9. Lucera Server Files Configuration
authserver.propertiesini
ΑντιγραφήΕπεξεργασία
Code:
LoginServerPort = -1
HAProxyLoginserverHostname = 127.0.0.1
HAProxyLoginserverPort = 2121
ini
ΑντιγραφήΕπεξεργασία
Code:
GameserverPort =
HAProxyGameserverPort = 7778

10. Cloudflare DNS Setup
Create two DNS Records in Cloudflare:Type | Name | Content (IP) | Proxy Status |
---|---|---|---|
A | login.yourservername.com | Proxy VPS IP | DNS Only |
A | game.yourservername.com | Proxy VPS IP | DNS Only |

11. Client Patch Configuration (l2.ini)
iniΑντιγραφήΕπεξεργασία
Code:
[URL]
LoginServerIP=login.yourservername.com
LoginServerPort=2106

12. Industrial Firewall Setup (SYNPROXY + IPSet)
This section brings 99% Anti-DDoS protection!Install needed packages:
bash
ΑντιγραφήΕπεξεργασία
Code:
sudo apt install ipset iptables-persistent conntrack
bash
ΑντιγραφήΕπεξεργασία
Code:
sudo ipset create ipset_allowed_ports hash:net
sudo ipset create ipset_whitelist hash:net
sudo ipset create ipset_players_whitelist hash:net
sudo ipset create ipset_blacklist hash:net
sudo ipset create banned_limit_conn hash:net timeout 300
sudo ipset create banned_limit_synproxy_ack hash:net timeout 300
sudo ipset create banned_limit_syn hash:net timeout 300
bash
ΑντιγραφήΕπεξεργασία
Code:
net.netfilter.nf_conntrack_max = 2000000
net.netfilter.nf_conntrack_tcp_timeout_established = 1800
net.netfilter.nf_conntrack_tcp_timeout_close = 10
net.ipv4.tcp_syncookies = 1
bash
ΑντιγραφήΕπεξεργασία
Code:
sudo sysctl -p
bash
ΑντιγραφήΕπεξεργασία
Code:
sudo iptables -t raw -A PREROUTING -m set --match-set ipset_whitelist src -j ACCEPT
sudo iptables -t raw -A PREROUTING -m set --match-set ipset_blacklist src -j DROP
sudo iptables -t raw -A PREROUTING -m set --match-set banned_limit_conn src -j DROP
sudo iptables -t raw -A PREROUTING -m set --match-set banned_limit_synproxy_ack src -j DROP
sudo iptables -t raw -A PREROUTING -m set --match-set banned_limit_syn src -j DROP
sudo iptables -t raw -A PREROUTING -i enp3s0f0 -p tcp --syn -m multiport --dports 2106,7777 -j CT --notrack
bash
ΑντιγραφήΕπεξεργασία
Code:
sudo iptables -A FORWARD -i enp3s0f0 -p tcp -m multiport --dports 2106,7777 -m state --state INVALID,UNTRACKED -j SYNPROXY --sack-perm --timestamp --wscale 7 --mss 1460
sudo iptables -A FORWARD -i enp3s0f0 -p tcp -m multiport --dports 2106,7777 -m state --state INVALID -j DROP

Save All Rules:
bash
ΑντιγραφήΕπεξεργασία
Code:
sudo netfilter-persistent save
13. Emergency Snapshot Plan

If anything happens, you restore in 5 minutes — no need to redo setup.
Final Status: Your Server Is Production-Ready!
Component | Status |
---|---|
OS Hardened | ![]() |
SSH Secured | ![]() |
Firewall (Proxy + Website Only) | ![]() |
Fail2Ban Installed | ![]() |
CrowdSec Installed | ![]() |
MariaDB Secured | ![]() |
Lucera HAProxy v2 Setup | ![]() |
Industrial Firewall (SYNPROXY + IPSet) | ![]() |
Cloudflare DNS Protection | ![]() |
Emergency Snapshot Ready | ![]() |