Skip to main content

In this video we'll be looking at how to create a Minetest server on a Linux system. I do not use Windows or Mac so I can't explain the process required to setup a server on either of those platforms. Whether you are creating a local or public server the same basics apply. A local game is only join-able by people on the same network, whereas a public server can be joined by anybody in the world.

The easiest way to create a server is by using the GUI, but this isn't really great for a public server. Here are the steps; Create a new world, or select an already existing world then you can start a server by checking the Host Server box. We get a few more options the big one being Announce Server. If you are hosting a local server you should uncheck this. Name/Password should be filled with your name and password and the Server Port can be left at the default value. Then click the Host Game button. The world will load and you'll have a working local server running. You be the admin so you can grant yourself or others privileges. The downside to this method is you have to keep the game running for anybody to connect to it, and you're running a client which uses more processing power than just a server, as the server doesn't need to run any graphics.

To join the newly created local server we just need to know the IP. On linux you can find this by running the ifconfig command in a terminal, or by looking at the connection information. Make sure you are getting the local IP, it will likely start with 192. Take that IP and input it as the address on the other clients using the same port as you chose when starting the server. Input a username and password and click Connect. The loading time will vary depending on how many mods the server is running and your local connection speeds.

This method is okay for short term servers, but if you want something that runs 24/7 you'll want to run a dedicated server. Fortunately a server can run on most any old computer you might have lying around.

To create a headless server, that is to say one that runs without any graphics we can first create a world with the GUI, selecting mapgen, mapgen seed, and enabling mods, and setting the mod configurations. Start the game to make sure everything loads properly and then exit. With a world created we can launch the minetest server. Open a terminal and navigate to the Minetest/bin directory and run ./minetestserver an error should come up because no world is specified, but the help information is very useful letting us know how to select a world, and listing all available worlds. Run the command again but this time include either the --worldname or --world flag and type the name of your world or path. If you've done everything correctly you'll see the server starting. 

This method works fine if you're using a machine that you have a monitor, keyboard, and mouse hooked up too, but if you're running a server in a docker container, on a raspberry Pi, a VPS, or some other hardware that you don't have peripherals hooked up to you'll need to change things a bit. We can still create a world on a machine with the GUI and then copy over the world files, the Game, and all the mods being used to the machine that will host the server. At this point you technically have a working server, but you really need to do a few more things before it's really finished.

In the Minetest.conf file you'll want to set a few things; the server_name, this will be listed in the server list.
the server_description, just a short bit about the server, what makes it special.
server_address, if you have a web address that you are using to forward to your machine.
server_URL, you can link to your website, blog, youtube channel...
motd, Message of the Day, just a bit of text that will be displayed to people upon joining the server.
default_privs, privileges that all players have when joining

You'll also want to setup an admin account, add a line saying name = <admin_name> The player that joins with this name will be the admin and have all privs. You'll want to make sure that you log in with that name right away to prevent anybody else from getting access. Should that happen you can change the admin name in the conf file.

Right now if the server happens to crash for any reason you'll have to manually restart it, which is lame, so it's a good idea to create a script that will automatically start the server back up if it should happen to go down. A simple bash script should be sufficient. I use the this script. Obviously name should be replaced with the worldname. After a crash or manual shutdown the script waits three seconds and then launches the server again.

#!/bin/bash
for (( ; ; ))
do
   ./minetestserver --worldname name
   sleep 3
done

If you ever want to add or remove mods it's as simple as copying the new mods into the mod directory and then editing world.mt in the world directory. To disable a mod just change true to false. The mods will dynamically update over server restarts. If you add a bunch to the mod directory, and then restart the server the file will list all the new mods and you can just change the false to true. Of course you could also just type load_mod_mod-name = true.

There is a lot of other stuff you can change in the minetest.conf files that relates to a server, I won't cover them all though, as different types of servers are going to want different settings. I highly recommend looking through it and changing anything that needs to be changed.

At this point the server should be fully functional, but likely you won't be able to connect to it from outside your local network. To make that work we need to change a few router settings. Due to differences in Router firmware I can't give exact steps, unless you happen to be using dd-wrt. Firstly you'll need to log into your router, the IP will probably be 192.168.1.1 unless you've changed it. Look for a section called Port Forwarding, in DD-wrt it's under the NAT/QoS tab. You'll want to add an application name, port from and to should be the port you have the server listening on. The IP address is going to be the IP of the machine that the server is running on. We found that information earlier, but likely your router will have a table with all the connected clients and their IPs listed as well. Once added you'll need to save, and apply changed. Some routers may require you to restart them as well, look at your specific routers documentation if you have any troubles. So are we done yet? well yes and no. Right now the server will be accessible from the outside, so you can stop here, but why stop when you can continue and add a custom address. If you have a domain you can create a subdomain and have that forward to your public IP, if you don't have a domain you can get a free domain name from several DNS services. I have a domain, and a sub-domain that I'll be using. The steps will likely vary with hosts. First I'll create a new subdomain, and then change the DNS settings so it points to my local IP address. If you were using a VPS you'd set it to the VPS' IP address. Residential IP can change every so often, so you may want to consider setting up something to automatically update the IP that the subdomain points to. That's outside of the scope of this tutorial though. It also doesn't apply to me, so I have no idea how to do it.

The last thing to cover is making a public server private. What I mean by that is a server that can be reached from anybody on the web, but only let's certain people join. It's a three step process. Change Server_announce to false, so it doesn't get listed in the serverlist, share the public IP of the server with the people you want to be able to join, and for added security a whitelist mod so anybody that happens to discover the IP won't be able to join unless you've added their username to the list of allowed players.

Further reading:
https://wiki.minetest.net/Setting_up_a_server
https://wiki.minetest.net/How_to_get_a_domain_name_for_your_server
whitelist mod: https://forum.minetest.net/viewtopic.php?id=8434