My Home Minecraft Server Setup

Posted on March 22, 2022 with tags:
In this post:

Minecraft is the best selling video game of all time for its unique and diverse gameplay, but a more important legacy will be the impact it had on a generation of young computer scientists, programmers, and tech nerds. I’ve been playing Minecraft ever since I started using a computer regularly, and for much of that I've hosted my own server.

Like so many other players, Minecraft introduced me to the world of computer programming. First, I explored in-game programming language, redstone (which is my favorite gameplay element to this day). Next, I began experimenting with 3rd party modifications (or mods, for short). Nowadays, most common mods come with a one-click installer, but back in the days of Minecraft beta, mods were installed by manually adding .jar files to the game's executables. Trying to install Optifine was the first time I explored the capabilities of Finder. Eventually, I set my sights on hosting my own Minecraft server. Fed up with paying for cheap, low quality hosting services, I figured I could and should learn how to do it on my own. In high school, setting up a server exposed me to the terminal, executables, and networking, all topics which my CS education didn’t cover till years later.

To this day, I still have a love for Minecraft. A group of college buddies and I went on a Minecraft binge over the 2021 holiday break, and I hosted our server on an extra PC I had. Here’s an overview of the setup process.

0. Requirements

Functional Requirements for my server:

  • Handle 10+ concurrent players on a vanilla Minecraft server
  • Require no 3rd party software to connect (no hamachi)
  • Admin access to server from outside my local network (Start, stop, backup from abroad)

Services needed to replicate this set up

  • Internet connection - you’ll need connection to the internet via an ISP
  • Minecraft Java Edition - you must be able to play Minecraft (legally!)

1. Hardware

PC/server, Raspberry Pi, Network switch

My home server setup includes a few pieces of hardware. At a bare minimum you’ll need a computer on which to run the server. I’m using a mid-tier gaming PC that I built a few years ago which was collecting dust after I upgraded to more powerful hardware. I’ll refer to this machine as the server. If you don’t have access to a separate computer to host the server, you can host and play from the save device (albeit with performance ramifications).

Additionally, I use wifi router which acts as a wireless access point, ethernet switch, and firewall all-in-one. This device handles the physical connection of my server to the internet via an ethernet cable and allows Minecraft connections through my network firewall (i.e. port forwarding).

Furthermore, I set up an always-on raspberry pi connected to my home network. This is totally optional and I’ll explain more later.

2. Setting up Ubuntu server

After hardware assembly, I installed ubuntu server on my server’s primary ssd. This required downloading an Ubuntu image and using Rufus to create a bootable usb drive from the image. Ubuntu.com has some fantastic tutorials which I followed through this process:

After installing the OS, I installed Java 17 and Screen, and downloaded the minecraft server. This DigitalOcean article has more details: https://www.digitalocean.com/community/tutorials/how-to-create-a-minecraft-server-on-ubuntu-18-04

To make the server accessible to other computers on the network, I opened port 25565 for Minecraft connections with $ sudo ufw allow 25565.

At this point I can launch the Minecraft Server in a new Screen session and connect from a client on my local network.

3. Port forwarding

To access the server from outside my local network, I created a few port forwarding rules on my router. These rules take a port range and protocol and “forward” any incoming packets on those ports to a specific client on my local network. In this case I’m sending all incoming packets on port 25565 to my server box.

4. No-ip Client

As a non-business customer, I don’t have the option to receive a static public IP from my ISP. Instead, my modem is assigned a dynamic IP address, which could change at any time upon reassignment from the ISP. Instead of sending out my public IP to all players every time that it changes, what if I could use a domain name and update the DNS records when my IP changes? That is the solution which no-ip.com provides. A lightweight client running on the ubuntu box pings my dynamic public IP to the no-ip servers. When the IP changes they update the DNS records to point a domain name of my choosing at my network’s public IP.

I installed the no-ip client on my ubuntu server and set it up to launch on boot and run as a daemon in the background.

5. Raspberry Pi for SSH

Initially, I added a port forwarding rule to direct incoming ssh connections to my ubuntu box, meaning I could configure, restart, and backup the server remotely. This approach worked until the power flickered at my house. My modem and router restarted immediately when the power came back on, but since I don’t have a UPS for my server it hard-stopped and required a manually boot by pushing the power button. The server was out-for-the-count until I returned home from my trip. Clearly, I needed a more robust method of disaster recovery.

To solve this issue, I wanted to add lightweight server to my network, and set it up to restart automatically on power loss. Luckily, I had a raspberry pi 2 laying around which is perfect device for my needs. Using a RPi to act as an always-on intermediary between my server and the outside world has the benefit of better energy efficiency. My model RPi only draws 1.1 watts at idle, a massive reduction compared to the server running a desktop cpu.

Lastly, I enabled wake-on-lan in the ubuntu server’s bios and put together a simple shell script to wake the ubuntu server from the raspberry pi. Now, when I know no one is using the Minecraft server, I can shut it down and bring it back online at will.

6. Future Enhancements

With the end of winter break our Minecraft bender faded to conclusion. The server is offline but standing by for the next Minecraft update. I’ve come up with a few potential enhancements that I’ll implement when the time comes. (I’ll admit at this point I enjoy the Minecraft server administration work more than playing the game.)

  • Automated off-site backups - I hacked together a rudimentary backup script to copy the world file daily to a different drive on the server, but it leaves much to be desired. Optimally, the backup service would handle deletion of old backups and store backups on a different server or site (in the cloud, perhaps?).
  • Improved monitoring - A dashboard to view CPU/Disk utilization, player list, and dynmap. Would be useful for admins and players

Thanks for reading!

Comments

Sign in to leave a comment.