Tuesday, January 15, 2019

Building a Minecraft 1.12.2 Forge Server on Ubutnu 18.04 Server Edition

Building and running a Minecraft server is fairly easy and gives you flexibility with all sorts of mods. There are a few decisions you'll need to make such as:
  • Do you want your Minecraft server to be public (anyone who learns your IP) or private (just you and your friends.)
  • What mods you want to install. You'll need to read carefully to see if a mod is client side or client and server. If it's client and server, you'll need to make sure your friends download the same mod versions you have installed on the server. They'll obviously need to be using Minecraft Forge as well as that's what we're using on the server.


x.x.x.x or Server: The Ubuntu 18.04 Server with Minecraft Server
y.y.y.y or Host: The IP of your computer with Minecraft game on it
z.z.z.z: IP(s) for friends you want to allow to play Minecraft on your server (optional for private server.)

Configuring the Minecraft Server

I'll assume you have a freshly built Ubuntu 18.04 Server built. This tutorial won't cover doing this, just the configuration of it.

Installing Java 8

$ sudo add-apt-repository ppa:webupd8team/java
$ sudo apt update
$ sudo apt install oracle-java8-installed

Verify Default Java Version

$ java -version

openjdk version "1.8.0_191"
OpenJDK Runtime Environment (build 1.8.0_191-8u191-b12-0ubuntu0.18.04.1-b12)
OpenJDK 64-Bit Server VM (build 25.191-b12, mixed mode)
If your openjdk version is not 1.8.0_191, type the below and select it from the list.
$ sudo update-alternatives --config java

Installing Minecraft

From your home folder on the Server, type the following:
$ mkdir minecraft
$ cd minecraft
Go to https://mcversions.net/ and click the link for the 1.12.2 Server Jar. Place the server.jar file into the minecraft folder you created above.

You'll need to accept the end user license agreement (EULA) so type the below.
$ echo "eula=true" > eula.txt
Now let's launch and install the Minecraft server
$ java -Xmx1024M -Xms1024M -jar server.jar nogui
After lots of text going by (look for anything in red which denotes an error) you'll know it's done and ready when you see text about preparing the spawn area and Unloading dimensions. The '>' is your Minecraft prompt. 
Type /help to get info about op'ing, banning, give etc. commands. Type the below command to stop the Minecraft server.
> /stop

Installing Forge

Go to http://www.minecraftforge.net/forum/forum/7-releases/ and find the latest version of forge for the version Minecraft 1.12.2. As of the writing of this tutorial, that's version Download that file into the minecraft folder. For purposes of the below, replace "forge-1.12.2-" with the filename of .jar you just downloaded.
$ chmod +x forge-1.12.2-
$ java -jar forge-1.12.2- --installServer
Now let's test that everything is working correctly. Again, replace "forge-1.12.2-" with the filename of Minecraft Forge .jar you downloaded.
$ java -Xmx1024M -Xms1024M -jar forge-1.12.2- nogui
After lots of text going by (look for anything in red which denotes an error) you'll know it's done and ready when you see text about preparing the spawn area and Unloading dimensions. The '>' is your Minecraft prompt. Type /help to get info about op'ing, banning, give etc. commands.
[22:40:12] [Server thread/INFO] [minecraft/MinecraftServer]: Preparing start region for level 0
[22:40:13] [Server thread/INFO] [minecraft/MinecraftServer]: Preparing spawn area: 18%
[22:40:14] [Server thread/INFO] [minecraft/DedicatedServer]: Done (3.795s)! For help, type "help" or "?"
[22:40:16] [Server thread/INFO] [FML]: Unloading dimension -1
[22:40:16] [Server thread/INFO] [FML]: Unloading dimension 1
[22:40:16] [Server thread/INFO] [FML]: Unloading dimension 20
[22:40:16] [Server thread/INFO] [FML]: Unloading dimension 7

Installing mods

I generally get all my mods from https://minecraft.curseforge.com/. Find mods you like and download them into the minecraft/mods folder. Remember, some mods are client only, like say, Journeymap and Inventory Tweaks. Client side mods will throw errors and prevent the Minecraft server from starting if put in the server mods folder.

Router config:

We're almost done! If you want your friends to connect to the server from their house, or you made it completely public, you need to set port forwarding in your internet modem (Comcast, Qwest etc.)

NOTE: If you and your friends will only be connecting to your Minecraft server from your network (your house), then you can skip to Configuring a Static IP.

I'll walk you through how to do this on a Comcast modem as that's what I have. If you have something different, you'll need to do a little Googling, or call their tech support. If you happen to have an all-in-one modem with wifi built in, then this will be much simpler as you won't be dealing with two different subnets.

The easiest way is to now plug your Minecraft server directly into your Comcast modem. Then you need to check what IP address it gives you. Let's say it gave you, then the Comcast modem's web interface is going to be the same first three octets (10.1.15) with a '1' as the last octet. i.e.

Assuming your IP was, in a browser, go to At the login page enter the following credentials:

- Username: cusadmin
- Password: highspeed

and login.

The first thing we want to do is figure out what your DHCP pool is so we can static the IP of your Minecraft server to an IP outside that range. Click on LAN on the left side and look at the DHCP Start IP and DHCP End IP. Let's assume these values are and respectively. We're going to want to pick an IP address either above or below that range. For purposes of this tutorial, let's go with as the IP we want to give our Minecraft server.

On the left, click on Firewall, then at the top, click on the Port Configuration tab.

Click on the Add New button and enter the following information like the screenshot, replacing x.x.x.x with the IP of your Minecraft Server (we used as an example previously).

Click on apply and give it a few moments to write the configuration. At this point, we're done with the modem and we will now move on to configuring the static IP on the Minecraft server.

Configuring a Static IP:

On the Minecraft server, type the below:
$ sudo nano /etc/netplan/50-cloud-init.yaml
Enter in the below information, replacing the with the Minecraft server IP (make sure to keep the /24) and with the Comcast modem IP. You can also replace the, with DNS servers of your choice. These happen to be the ones for Google DNS servers:

NOTE: Consistent spacing is important. Everything below should line up the way it shows. eno1 is the name of my network interface, if yours is different, leave it alone.
# This file is generated from information provided by
# the datasource.  Changes to it will not persist across an instance.
# To disable cloud-init's network configuration capabilities, write a file
# /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:
# network: {config: disabled}
              addresses: [,]
            dhcp4: false
    version: 2
Hit CTRL-O, Enter, CTRL-X and then type:
$ sudo netplan apply

If everything goes right, you should have no errors.

Configuring Universal Firewall (UFW):

Whether your Minecraft server is public or private, we want to configure the firewall just as a good practice.
$ sudo ufw enable
Now we need to configure some rules to allow connections to the Minecraft server default port 25565. Depending on how "private" you want your server, we'll start out with the most restrictive and open it up as we go along. I'm going to assume that since you're setting up a Minecraft server, you want to play with some friends. Let's take care of you first, then the friends.

Let's create a rule that says anyone on your home network with the Minecraft server on it is going to be able to connect and play.
$ sudo ufw allow from x.x.x.0/24 to x.x.x.x proto any port 25565
We're basically saying, any IP on your network can connect to the Minecraft server over port 25565. So you and any friends at your house on your network can play together.

Now, let's say you want your friends to be able to play from their house. Ask them to go to https://whatismyip.com and tell you the numbers after the text "Your Public IPv4 is:". Type the below command, replacing z.z.z.z with the IP they gave you. x.x.x.x is going to be the IP address you set up in Configuring a Static IP
$ sudo ufw allow from z.z.z.z to x.x.x.x proto any port 25565
If instead, you want your Minecraft server to be completely public, then instead of the last two rules we entered, you can type:
$ sudo ufw allow from any to x.x.x.x proto any port 25565

Let's Test it Out!

Launch Minecraft on the host and go to Multiplayer

Then click on Add Server

Then Enter server information in the form of SERVER-IP:PORT. Port 25565 is the default port for the Minecraft server. Server name can be anything you want. Mine is called PCWize in the previous screenshot.

Click Done when finished. If everything is going right, you should see something like the PCWize entry two screenshots above.

Click on the little picture to the left of your newly added server and you should get spawned into a new world.

Your friends, if they are at their house, will need to put in your public IP address (go to https://whatismyip.com) and they'll put that in place of the x.x.x.x in the screenshot above.

Well, that should just about do it. Happy mining!