May 19, 2011

How to Open and Run a Great Minecraft Server

Minecraft is one of the most popular PC games to come out in the last few years, and with the semi-recent additions to SMP mode, it’s more fun than ever to host your own custom Minecraft server. Getting the basic server up and running isn’t that difficult, but that’s a only part of the picture. Once the software is running, you’ve still got to set up dynamic DNS, port forwarding, and user control. And when THAT’S done, you’ve got to configure the game itself. In this guide, we’re going to cover all of that in enough detail to get you and your server up and running with as little hassle as possible. Note: The exact step-by-step procedure can vary from one OS to another. Whenever possible we will include details enough to work everywhere, but it’s possible your system may not behave exactly as indicated here. Additionally, Minecraft is still in development and is currently in Beta 1.5. Some of this information may change over time.

Basic Server Startup

While there is a Windows-format .exe file to run the server, all platforms can use the .jar file identically, therefor this guide will cover the .jar method. You will of course need a working Java installation on the machine which will be running Minecraft. For best performance and stability, Linux users are encouraged to use the official Java runtime instead of an open alternative.
If Java is installed and the .jar file is downloaded to an appropriate location, open up your command prompt/terminal to the location where you saved the .jar file. You’ll want to make sure the file is in its own directory, as it will generate several other files and directories the first time it is run.
To launch the server, enter the following command (all OSes):
#The -X options are recommended memory settings for improved performance
java -Xmx1024M -Xms1024M -jar minecraft_server.jar nogui
#The "nogui" option can be omitted if you'd like a GUI,
At this point, the server will generate the needed config files as well as a base world for players to join.
minecraftserver-firstrun

Configuring the Server

You may be tempted to load up the client and play right away, but at this point, nothing is configured. Shut down the server and take a look at the .jar file’s directory again, and you’ll see several new files.
minecraftserver-afterfirstrun
Most are pretty self-descriptive. But for the sake of being thorough, here’s a summary:
  • world – Directory containing map data
  • banned-ips.txt – List of IP addresses specifically banned from connection
  • ops.txt – List of Operator (admin) names
  • server.properties – Main server configuration file
  • banned-players.txt – List of banned players by name
  • server.log – Server’s log file
  • white-list.txt – List of players specifically allowed via  whitelisting
The one we’re most concerned with is server.properties. This file holds pretty much all the configuration options the server allows. The default one looks something like this, but with comments added for clarity.
#Changing this will generate a new world folder with this name
level-name=world
#Toggles whether or not The Nether is active on this server
hellworld=false
#Enable or disable mob spawning at night
spawn-monsters=true
#Whether or not to verify logins.  Better security if left to 'true'
online-mode=true
#Enable or disable cows, pigs, etc
spawn-animals=true
#Maximum number of concurrent players
max-players=20
#Bind to particular IP.  It is STRONGLY recommended this be left blank in most circumstances
server-ip=
#Whether or not to allow players to harm eachother
pvp=true
#If you want to be able to reproduce your level, you can specify a seed number
level-seed=
#Which port to bind the server.  Take note of this, you'll likely need it later.  
server-port=25565
#Whether or not to enable whitelisting.  See link in section above for details on whitelisting.  
white-list=false

External Access

If you’re attempting to run this on a home broadband connection, you likely have a few extra steps you’ll need to take before anyone but you can access your server. First, you’ll need to know if you need  port forwarding. In short, anything running as a server on your computer binds itself to a certain port number. That way, any data coming into that computer labeled with that port number will be routed to the correct program. If you’re behind a home router, the router must be made aware that you’re running a server so that all incoming data on that port goes to the right computer.
Still with me? Port forwarding can be tricky but here’s a summary of how to get the job done. If it’s not enough, here’s a great site devoted entirely to helping with this task.
For starters, we’ll need to know the IP address of the Minecraft server. There are a dozen ways to do that graphically depending on your OS, so here are two ways that’ll work on any major OS from the command line:
#Windows
ipconfig
#Linux/OSX/Any UNIX-type
ifconfig
On home networks, it’ll likely start with 192.168.x.x. Take note of this as the server’s IP. Your router’s IP is likely very similar, but replace the final number in the set with a 1. For example, if ifconfig showed you 192.168.1.50, your router’s IP is likely to be 192.168.1.1.
Now that we’ve got the server IP and a good guess at the router’s IP, open a new tab in your web browser and enter the router’s IP into the address bar (once again, likely 192.168.1.1 or 192.168.0.1). Chances are you’ll face a login screen. If you don’t know the password, try using the factory login.
Once you’ve got logged into your router, look around for NAT, Virtual Server, or Port Forward settings and enter the IP and port of your server as required.
minecraftserver-portforward
Once again I highly recommend PortForward.com if you run into any trouble.

Dynamic DNS

Most home broadband users have a dynamic IP address, meaning it changes every so often. For people to be able to easily access your server, you’ll need to have a good name they can always access instead of an ever-changing IP. That’s where dynamic DNS comes in. When you sign up with a (often free) dynamic DNS provider, they give you a name like myserver.dyndnsprovider.com. You run a small client program on your server that connects to the provider every so often and informs them of any changes to your IP. Whenever someone accesses the name, they forward the request to your current IP.
There are several such providers out there, but this author has always had good luck with No-IP.com. Signup is quick and free and they provide client software for every major OS.
Additionally, some routers and modems have built-in support for many popular dynamic DNS providers. It may be worthwhile to check your device before trying to install local client software, as it could save you a lot of headache.

Conclusion

It may have taken a little bit of time, but hopefully at this point you’ve got a solid server up and running. Setting up any server can be a hassle. This one, at least, is all but guaranteed to keep you and your friends entertained for quite some time.