Private
Protection
Special Offers
Catalog
Auto donation
Practical notes for anyone running a Lineage 2 server on Ubuntu or Debian: managing MariaDB/MySQL, safe remote access to the database, accurate time and basic protection against floods and overload.
Modern Ubuntu and Debian manage services with systemd, so use systemctl instead of the old /etc/init.d/mysql scripts. The MariaDB service is called mariadb (on Debian and Ubuntu the mysql alias works too); the MySQL service is called mysql.
sudo systemctl status mariadb # service state and the latest log lines
sudo systemctl restart mariadb # restart after editing the config
sudo systemctl stop mariadb # stop
sudo systemctl start mariadb # start
sudo systemctl enable mariadb # start automatically at bootIf the database will not start, the reason is almost always in the log:
sudo journalctl -u mariadb -n 100 --no-pager # last 100 lines
sudo journalctl -u mariadb -f # follow in real time
sudo tail -n 100 /var/log/mysql/error.log # if a separate error log is configuredCommon reasons for a crash:
df -h;sudo ss -ltnp | grep 3306;The main config files are /etc/mysql/mariadb.conf.d/50-server.cnf for MariaDB and /etc/mysql/mysql.conf.d/mysqld.cnf for MySQL. Server options go into the [mysqld] section. Installing a web server and database from scratch is covered in the guide on installing Apache, MySQL and PHP on Ubuntu.
Working with the database from your home PC is convenient, but opening port 3306 to the whole internet and letting root log in from any address (as older guides often suggested) is dangerous: bots constantly try to guess passwords on exposed databases. There are two proper ways to do it.
Option 1. SSH tunnel (recommended). The database keeps listening on 127.0.0.1 only, and the client connects to it over SSH. In HeidiSQL choose a connection type with an SSH tunnel; in Navicat fill in the SSH tab of the connection settings. From the command line the tunnel looks like this:
ssh -L 3307:127.0.0.1:3306 user@server_ip
# while the session is open, point your client to 127.0.0.1, port 3307Option 2. Open the port for your IP only. Use a separate user with rights to the server database only, not root:
[mysqld] section of the MariaDB/MySQL config, change bind-address = 127.0.0.1 to bind-address = 0.0.0.0 and restart the service.sudo mariadb or sudo mysql) and create a user bound to your public IP.CREATE USER 'l2admin'@'203.0.113.10' IDENTIFIED BY 'strong_password';
GRANT ALL PRIVILEGES ON l2jdb.* TO 'l2admin'@'203.0.113.10';sudo ufw allow from 203.0.113.10 to any port 3306 proto tcpHere 203.0.113.10 is your public IP and l2jdb is the server database name.
UPDATE mysql.user SET host = '%' ... from old guides are not supported in MySQL 8 and MariaDB 10.4+ and can break user accounts. Create and change users with CREATE USER, GRANT and ALTER USER. The game server itself does not need the database port to be open to the outside: it connects via localhost.The Olympiad, sieges, raid boss respawns, daily resets and events all depend on the system time. If your server is rented in another country, its clock follows that country's time zone. The right approach is not to set the clock by hand, but to choose the correct time zone and enable automatic time synchronization.
timedatectl # time, zone and sync status
timedatectl list-timezones | grep Europe # list available zones
sudo timedatectl set-timezone Europe/Berlin # set the zone
sudo timedatectl set-ntp true # enable sync (systemd-timesyncd)
timedatectl timesync-status # sync detailsInstead of the built-in systemd-timesyncd you can install chrony: it keeps time more precisely and corrects drift faster. Installing chrony usually removes or disables systemd-timesyncd automatically; never run two time sync services at once.
sudo apt install chrony
chronyc tracking # current offset and time source
chronyc sources -v # list of time serversSELECT NOW(), @@system_time_zone;. If the game time must differ from the system time, pass a zone to the Java server with the -Duser.timezone=Europe/Berlin startup option.Treat the old methods, date -s 23:45:30 and ntpdate, as legacy. With time sync enabled, a manually set clock is corrected back, and newer distributions have replaced ntpdate with time sync services.
The netstat tool from the net-tools package is outdated and not always installed; its replacement is ss. Default pack ports are 2106 for the login server, 7777 for the game server and 3306 for the database (your pack may use different ports).
sudo ss -ltnp # listening ports and their processes
ss -tn state established '( sport = :7777 )' # active connections to the game server
ss -Htn state established '( sport = :7777 )' | wc -l # how many of themIn the output, Recv-Q and Send-Q are the data waiting in the receive and send queues (usually close to zero), Local Address:Port is your address and port, and Peer Address:Port is the client's address and port. To find addresses with a suspicious number of connections, group them by IP:
ss -Htn state established '( sport = :7777 )' \
| awk '{sub(/:[0-9]+$/, "", $4); print $4}' \
| sort | uniq -c | sort -rn | head -20Dozens of connections from one address to the login or game server port deserve a closer look: a normal client keeps one connection per game window. Keep in mind, though, that several players may share one IP (a shared network or mobile internet).
To check the load on the machine itself:
htop # processes, CPU and memory usage (sudo apt install htop)
uptime # load average over 1, 5 and 15 minutes
nproc # number of CPU cores
free -h # memory and swap
df -h # free disk spaceIf the load average stays above the number of cores for a long time, the server is short on CPU. If the Java process is actively swapping, the game will lag: add memory or reduce the heap size.
The simplest and most useful step is to close everything except the ports you need. Ubuntu ships ufw for this (on Debian install it with sudo apt install ufw); it works on top of the kernel firewall (nftables or iptables).
sudo ufw allow 22/tcp # SSH - always before enabling!
sudo ufw allow 2106/tcp # login server
sudo ufw allow 7777/tcp # game server
sudo ufw default deny incoming
sudo ufw default allow outgoing
sudo ufw enable
sudo ufw status numberedufw enable; if SSH runs on a non-standard port, allow that port instead. If a website runs on the same machine, open ports 80 and 443 as well.To block a specific address, insert the rule at the top of the list: ufw checks rules in order, and a deny rule added after a port has been allowed will not take effect.
sudo ufw insert 1 deny from 198.51.100.50 # block an address
sudo ufw status numbered # check the rule order
sudo ufw delete 1 # remove a rule by its numberTo limit the number of simultaneous connections from one IP to the game ports (no more than 10 here):
sudo iptables -I INPUT -p tcp --syn -m multiport --dports 2106,7777 \
-m connlimit --connlimit-above 10 --connlimit-mask 32 -j REJECT --reject-with tcp-resetThis rule lasts until the next reboot. To keep it together with ufw, add the line below to /etc/ufw/before.rules just before the COMMIT line and run sudo ufw reload. Leave some headroom in the limit: players with several game windows or behind a shared IP open several connections.
-A ufw-before-input -p tcp --syn -m multiport --dports 2106,7777 -m connlimit --connlimit-above 10 --connlimit-mask 32 -j REJECT --reject-with tcp-resetA few more hygiene rules:
127.0.0.1 is enough for them;sudo ufw limit 22/tcp helps against SSH password guessing;sudo apt update and sudo apt upgrade;If you would rather not deal with all this yourself, take a look at our turnkey projects and server packs.
Published 6 November 2026
We help with the server pack, setup, protection and launch — one-off or on an ongoing basis.
Get L2‑Scripts news by email
And 5% off all studio services while you stay subscribed.
The discount is valid while you are subscribed: when ordering, tell the manager your subscription address on Telegram.
Search
News