Setting up a server

From Minetest
Revision as of 11:04, 30 July 2023 by >ROllerozxa


Choosing Hardware

It's recommended that you use a VPS or dedicated server to host a game server which you want to make publicly available. Residential Internet connections tend to be unreliable and also have less upload speed. You may also not be able to keep a server online 24/7 when hosting from home.

That being said, hosting from home will work fine if you have some hardware you can keep online, and you have a good enough Internet connection. Keep in mind that if you are behind CG-NAT, you are unable to host a public server as it won't be accessible to the wider internet. (check with your ISP if unsure)

Minetest does have a Host Server option in the main menu, which is fine for temporary servers for a couple of friends, but if you want to run a public server you would want to run it dedicated as it can be kept online independent of the client being active.

Obtaining a server binary

Linux

Note: If you are going to be running a Minetest server on a non-headless system, using the regular minetest binary with the --server argument works the same as minetestserver. If you are on a headless Linux system without a graphical environment minetestserver is recommended as it is smaller and does not have extra dependencies that are unnecessary for a server.

Usually your Linux distribution of choice will have minetestserver in its official repositories. However this package may be several releases outdated, so obtaining a server binary through other means is to be recommended.

You may choose to build from source, in which case you should specify -DRUN_IN_PLACE=TRUE -DBUILD_CLIENT=FALSE -DBUILD_SERVER=TRUE which will build a minetestserver binary running in place. When built, you can move bin/ and builtin/ to a new folder, or if you're building on a separate machine from the server, transfer them onto the server. See the README.md file for more information about compiling Minetest from source.

There also exist ready made Docker images for minetestserver, see the README file.

Windows

The regular Windows builds provided on the download page work fine, running it as minetest.exe --server to access the server portion of it.

Running the Server

Linux

  1. Open a terminal.
  2. Navigate to wherever you've put your Minetest server files (referred to as /Minetest/ from now on), and run the server with /bin/minetestserver. (PLEASE READ THE NOTES BELOW!)
    • If you want to specify a specific game ID, the game ID choices are located in /Minetest/games/. Add in --gameid thegameid to the end of the command.
    • If you get the error “Multiple worlds are available.”, the world choices are located in /Minetest/worlds/. Add in --worldname theWorld to the end of the command.
  3. If your server crashes, then look in the debug.txt log file in /Minetest/
  4. Make sure you make your server safe from damage.

For easier server management (and also automatically restarting the server when it crashes) you can create a file named run_server.sh or the like in the /Minetest/ folder with this:

#!/bin/bash

while true
do
	 ./bin/minetestserver --gameid minetest --worldname world
	sleep 5
done

If you're on a headless server you'd want to run the server in some kind of multiplexer like screen. Run screen bash run_server.sh, Ctrl+A Ctrl+D to detach, and screen -r to reattach at a later date.

Windows

  1. Open command prompt by going in the Minetest installation folder. Then in the “bin” folder, click the blue "File" icon in the top left of the screen. In the drop down menu click “Open Windows Powershell here”.
  2. Type this: .\minetest.exe --server.
    • If you get the error “Multiple worlds are available.”, use .\minetest.exe --server --worldname world_name instead, where world_name is the name of the world.
  3. If your server crashes, then look at the debug.txt in /Minetest/bin/
  4. Make sure you make your server safe from damage.

If you don't like to start the crashed server, simply start the server out of a batch file which contains the following code:

@echo off
:crash
minetest.exe --server --worldname world_name
goto crash

Allowing external players to connect

Firewall

On Linux, you most likely know if you have a firewall installed. Be sure to allow the Minetest server to communicate over UDP on the specified port.

On Windows, the firewall will prompt you whether Minetest should be allowed access. This may even pop up the first time you play singleplayer in the client, and if you did not grant it permission you will need to open the Windows Defender firewall and accept it from there.

Port forwarding

If you are self-hosting a server you will usually need to port forward the server in your router for it to be accessible to the outside internet. This isn't necessary for LAN play, as you'll simply provide the internal IP of the server accessible within the local network.

  1. Choose a port to run the server on. The default of 30000 is recommended, and if you host several it is recommended to increment upwards. (e.g. 30001, 30002...)
  2. Login to your router, and port forward UDP on the chosen port for your server computer. Depending on your router the port forwarding page may show you a list of devices connected with their hostname visible, otherwise:
    • Find out your internal IP of the computer you are running the server on.
      • Linux: open a terminal and type ip addr and hit enter. Look for "inet" near "wlan0", "eth0" or something similar. It's usually somewhere within 192.168.0.0/16.
      • Windows
        • Open command prompt: Start → Run …, enter cmd.exe and hit enter.
        • Type ipconfig and hit enter.
        • Look for IPv4 Address.
      • macOS: Open the terminal and enter netstat -nr.
  1. Alter any computer firewalls you may have to allow traffic to the port you choose

Server list

Make your server listed in the server list and by setting the following settings in minetest.conf:

  • server_announce = true - makes Minetest announce the server to the server list.
  • server_name - set the value of this to your server's name.
  • server_description - set the value of this to a longer description describing your server.
  • server_address - if you have a domain name for your server, then set this to the domain name (how to get a domain name if you want one for your server).
    • Should only be the domain name (e.g. coolserver.minetest.net, not https://coolserver.minetest.net/woah/). If you do not have a domain name pointed to your server then do not add this setting or write anything for it, or the server list will reject your server.
  • server_url - if you have a website for your server, then set this to the website URL.
  • motd - a message that is sent to the player when they join. Use this to welcome them.
  • Note: You need to restart to make changes in minetest.conf take effect.

Protecting your server

Protecting the Minetest world/server

When setting up a new server, you should consider which protections are needed. This is extremely important for public servers, because you cannot predict who will connect or what they will do on your server.

Common problems include:

  • Accidental or intentional damage to other players' work (griefing).
  • Chat spam (may include swearing or advertisements).
  • Aggression, harassment or other unwanted behaviours between players.
  • Trouble makers who evade bans.
  • Impersonation of well known people within the Minetest community.
  • Bugs, for example caused by mods, which allow a malicious player to execute arbitrary system commands.

Many of these problems can be removed or minimised by advanced planning and awareness:

  • Install a protection mod, such as areas or protectors. These allow players to protect areas, which cannot be changed by other players.
  • Enable rollback by adding enable_rollback_recording = true to minetest.conf. Rollback can tell you which player placed a node, and allows a player's actions to be reverted.
    • NOTE: The engine rollback functionality is very limited and can't roll back griefing caused by mod-made node changes (e.g. spawning a bunch of trees or covering things in water). In addition to rollback, you should also always make regular backups of the map database.
  • Install a mod to help you manage bans, such as xban2.
  • On the other hand, if you are setting up a private server, install a whitelist mod such as whitelist.
  • Create rules for your server and make sure you have enough time (or a team of moderators) to supervise your server and watch for players who breaks your rules.
  • Never grant privileges to a player just because they use a name you recognise. Player names are not reserved between servers, so you should always confirm who the player is.
  • Install and configure a chat filter mod like filter, to prevent swearing and/or sexual chat. This is useful to inform players of the rules rather than actual enforcement, as working around filters is fairly easy.

For more mods useful to server administration, see the Server Moderation and Tools tag on ContentDB.

Protecting the host machine

  • Standard advice on Linux/Windows server security applies.
  • On Linux you can add a dedicated user for running the minetest server.
  • Never, ever, disable mod security.
  • Make sure you trust mods you add to secure.trusted_mods

Managing your server

Server Configuration

For a detailed explanation of the server configuration file, see the minetest.conf page.

You may also want to consider to use a different database backend for your world.

Server Commands

See the Server commands page for a list of useful commands.

Also see Itemstrings for the itemstrings for use with the /give and /giveme commands.

Privilege System

See the privileges page for detailed information on the privilege system.

See also