Creating a server updated Sat, 05/25/2019 - 22:12

In this video we'll be looking at how to create a Minetest server. 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 easy way to start a server is 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 super easily 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. On windows you can run ifconfig in the command prompt or by looking at your connection information. On a mac you'll find it under network 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, there are even some public servers running on Raspberry Pi's.

If you want to go all hardcore you can create a server entirely from a terminal and never use a GUI, but if you want to go that route you probably won't need this video so I'll cover a more hybrid approach.

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. With a world created we can launch the minetest server. This step will vary depending on OS and installation method. I build Minetest from source frequently so I just need to run ./minetestserver in the directory that the bin file is located. In my case this is home/Minetest/bin I get an error because I haven't specified a world, 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. If you don't see the Announcing to Servers.minetest.net line, and you want your server to be announcing you just need to add 'server_announce = true' to the minetest.conf file.

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. To create this lesson I created a server on a Raspberry Pi. I compiled the server myself, but was unable to get a client to work, so using the GUI to set things up was completely impossible. I created the world on my desktop and copied the world files to the Pi. The world files DO NOT INCLUDE the mods or game, YOU NEED TO COPY THOSE AS WELL. The Mods should go into the Mods directory, the game to the games directory, and the world to the worlds directory. Running the ./minetestserver command with worldname flag everything works. 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.

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.

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.

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 net, 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 add 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
white list: https://forum.minetest.net/viewtopic.php?id=8434

Add new comment

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.