Free minecraft server on AWS with zero knowledge of linux

Hey Habr! More precisely, crooks who are looking for how to set up a minecraft server to play with friends.

The article is intended for non-programmers, non-sysadmins, in general, not for the main audience of Habr. The article contains step-by-step instructions for creating a minecraft server with a dedicated IP, adapted for people who are far from IT. If this is not about you, it is better to skip the article.

What is a server?

So what is a server? If we rely on the concept of "server" as a software component, then the server is a program that can receive, process and transmit data received from users (clients) that are connected to this server. On the example of a site - the site is located on some web server that you access through a browser. In our case, the minecraft server generates a world to which players (clients) connect, who can walk, break blocks, etc. The minecraft server is responsible for connecting players and any of their actions.

Obviously, the server must be running on the computer (machine). You can raise the server on your home computer, but in this case:

  • You are compromising the security of your own computer by opening ports on it
  • The server will load your computer, which may interfere with your work with it
  • You can't keep your home computer up and running 24/7: sometimes you turn it off, sometimes your computer loses its internet connection, and so on.
  • To access your server from the outside world, you will have to access your computer using IP address, which for "home" Internet providers is dynamic, that is, it can change every 2-3 days for reasons beyond your control.

And how do we solve these problems?

The solution to all these problems is to use virtual machine with static, that is, an immutable IP address.

Difficult terminology? Let's figure it out.
Turn to Wikipedia.

Π’ΠΈΡ€Ρ‚ΡƒΠ°Π»ΡŒΠ½Π°Ρ машина (VM, ΠΎΡ‚ Π°Π½Π³Π». virtual machine) β€” программная ΠΈ/ΠΈΠ»ΠΈ аппаратная систСма, ΡΠΌΡƒΠ»ΠΈΡ€ΡƒΡŽΡ‰Π°Ρ Π°ΠΏΠΏΠ°Ρ€Π°Ρ‚Π½ΠΎΠ΅ обСспСчСниС Π½Π΅ΠΊΠΎΡ‚ΠΎΡ€ΠΎΠΉ ΠΏΠ»Π°Ρ‚Ρ„ΠΎΡ€ΠΌΡ‹...

To put it in a very rough language, it is a computer within a computer. You can also install an operating system on it and work with it like with a regular computer.

Where will we take it?

The answer is simple - AWS. This is a platform that provides many different cloud services that are useful for everyone who works with the web and not only. To create a minecraft server, one of the AWS products is perfect - Amazon EC2 - a cloud virtual machine that is available 24/7. AWS offers a minimum virtual machine (10GB SSD, 1GB RAM) free for a year, moreover, it makes it possible to bind a free dedicated (static) IP address for permanent access to your VM (virtual machine) at the same address.

Creating and configuring VM

Go to the site AWS and register. Then go to the management console.

Free minecraft server on AWS with zero knowledge of linux

In the console, among the services, find EC2 and go to it.

It is important to choose a data center, in other words, the place where the amazon servers are located. You should choose depending on your location, because the speed of communication on the Internet is different, and you should choose a data center with which communication from your city will be as fast as possible.

Free minecraft server on AWS with zero knowledge of linux

To select a data center, I recommend using the service Wonder Network, which measures the rate at which packets are sent to other cities.
In my case (Moscow), I was approached by an Irish data center.

It's time to create a virtual machine. To do this, go to the tab launch instance

Free minecraft server on AWS with zero knowledge of linux

Let's start configuring the VM.

1) Select the image of the operating system. To raise servers, linux is very convenient, we will use the distribution kit CentOS7

It should be noted that there will be no graphical environment on your virtual machine, the machine will be accessed through the console. It involves controlling the VM using commands, not a computer mouse. Don't be afraid of it: it shouldn't stop you now or give up on the idea of ​​starting your own minecraft server as it's "too complicated". Working with the machine through the console is easy - you will soon see for yourself.

Free minecraft server on AWS with zero knowledge of linux

2) Now let's define the technical configuration of the VM. For free use, Amazon offers a configuration t2.micro, not enough for a full-fledged large minecraft server, but enough to play with friends.

Free minecraft server on AWS with zero knowledge of linux

3) The rest of the settings are left by default., But we stop on the tab Configure security groups.

Free minecraft server on AWS with zero knowledge of linux

Here we need to configure port access for the minecraft server.

In simple terms, a port is a non-negative number that indicates to whom incoming data from the outside world is addressed. There can be many different services and servers on a VM, so all incoming data packets store in their header the port (number) of the destination (service, server) inside the VM.

For minecraft servers, the de facto standard is to use the port 25565. Let's add a rule indicating that access to your VM through this port is allowed.

Free minecraft server on AWS with zero knowledge of linux

Free minecraft server on AWS with zero knowledge of linux

Go to the window for completing the creation of the VM by clicking the button Review and Launch

Setting up an SSH key pair for the VM

So, the connection to the machine will be carried out using the SSH protocol.

The SSH protocol works as follows: a key pair is generated (public and private), the public key is stored on the VM, and the private key is stored on the computer of the person connecting to the VM (client). When connecting, the VM checks that the client has a valid private key.

НаТмитС ΠΊΠ½ΠΎΠΏΠΊΡƒ Launch. The following window will appear in front of you:

Free minecraft server on AWS with zero knowledge of linux

Enter a name for the key pair (for your convenience) and click download key pair. You must download .pem a file containing your private key. Click the button Launch instances. You have just created a virtual machine that will host the server.

Getting a static IP

Now we need to get and bind a static IP to our VM. For this menu we find the tab Elastic IPs and go through it. On the tab, click the button Allocate Elastic IP address and get a static IP.

Free minecraft server on AWS with zero knowledge of linux

Now the received IP address must be tied to our VM. To do this, select it from the list and in the menu Actions choose Associate IP address

Free minecraft server on AWS with zero knowledge of linux

Next, bind the VM to our IP address

Free minecraft server on AWS with zero knowledge of linux

Done!

Go to VM

Now that the VM is configured and the IP address is bound, let's connect to it and install our minecraft server.

To connect to the VM via SSH, use the program PuTTY. Immediately install PuTTYgen from the same page

After installing PuTTY, open it. Now you need to set up the connection.

Free minecraft server on AWS with zero knowledge of linux

  1. The tab Session choose connection type SSH, port 22. Specify a name for the connection. The hostname for connecting via SSH is a string like: имя_ΠΏΠΎΠ»ΡŒΠ·ΠΎΠ²Π°Ρ‚Π΅Π»Ρ@ΠΏΡƒΠ±Π»ΠΈΡ‡Π½Ρ‹ΠΉ_dns.

The default username in AWS for CentOS is βˆ’ centos. Your public DNS can be viewed here:

Free minecraft server on AWS with zero knowledge of linux

I got a line [email protected]

  1. The tab SSH -> Auth provide your private SSH key. It is stored in a file .pem, which we downloaded earlier. But PuTTY can't work with files .pem, it needs the format .ppk. We will use PuTTYgen for the conversion. Instructions for converting from the PuTTYgen website. Received file .ppk Save and enter here:

Free minecraft server on AWS with zero knowledge of linux

  1. We connect to the VM by opening the connection with the button Open.
    Congratulations! We have just connected to the console of your VM. It remains to raise our server to it.

Installing and configuring a minecraft server

Let's start setting up our server. First, we need to install a few packages on our VM.

sudo yum install -y wget mc iptables iptables-services java screen

Let's figure out what each of the packages is for.

  • wget - a utility for downloading files in linux. With it, we will download the server files.
  • mc - console text editor. Differs in simplicity and convenience in use for the unprepared user.
  • iptables - a utility for managing and configuring a firewall, with the help of it we will open a port for a server on our VM.
  • Java - minecraft runs on java, so it is necessary for the server to work
  • screen is a window manager for linux. It will allow us to duplicate our console to raise the server. The fact is that the server must be started through the console, if you disconnect from your VM, the server process will be stopped. Therefore, we will run it in a separate console window.

Now let's configure the firewall.

A firewall is a software or hardware-software element of a computer network that controls and filters network traffic passing through it in accordance with specified rules. (Wikipedia)

Explaining in simple terms: imagine a walled city. It is constantly attacked from the outside, while ordinary life flows in the city. For access to the city, there is a gate in the wall of the fortress, at which guards stand and check according to the lists whether this person can be allowed into the fortress. The role of the wall and gate in computer networks is performed by the firewall.

sudo mcedit /etc/sysconfig/iptables

We have just created a firewall configuration file. Fill it with standard configuration data, including a rule for the port 25565, which is the standard port for the minecraft server.

*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 25565 -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT

Close the file by clicking F10, saving the changes.

Free minecraft server on AWS with zero knowledge of linux

Now let's start the firewall and enable it to autoload:

sudo systemctl enable iptables
sudo systemctl restart iptables

We will store the server files in a separate folder, create it, go to it and download the server files. For this you should use wget

mkdir minecraft
cd minecraft
wget <ссылка_Π½Π°_jar>

Need to find direct link for download .jar server file. For example, a link to the server file version 1.15.2:

wget https://launcher.mojang.com/v1/objects/bb2b6b1aefcd70dfd1892149ac3a215f6c636b07/server.jar

View the contents of a folder with the command ls, make sure the files are downloaded.

Free minecraft server on AWS with zero knowledge of linux

Let's start the server file. Now the server will not work: it will create all the files necessary for work, and will swear that you did not agree with the terms of the EULA license. Accept the terms by opening the file eula.txt

sudo mcedit eula.txt

Confirm your consent by changing the entry to:

eula=true

Open the file server.properties: This is your server's configuration file. Learn more about server settings

You need to make the following change to it:

online-mode=false

The rest of the settings are up to you.

Server start

It's time to start the server. As I said, the server starts directly from the console, but if we close the main console, the server process will be stopped. So let's create another console:

screen

In this console, start the server:

 sudo java -Xms512M -Xmx1024M -jar <Π½Π°Π·Π²Π°Π½ΠΈΠ΅_Ρ„Π°ΠΉΠ»Π°_сСрвСра>.jar --nogui

The server starts in about 45 seconds, do not interrupt the process. When the server is initialized and running, you will see something like:

Free minecraft server on AWS with zero knowledge of linux

Congratulations! You just got up and running your minecraft server. Now it is important to properly exit the second console so that it continues to work with the running server. To do this, click Ctrl+AThen D. You should be in the main console and see a message like [detached from 1551.pts-0.ip-172-31-37-146]. If you need to return to the console where the server is running, use screen -r

Now you can disconnect from your VM. Your server will be reachable at the static IP address we received earlier on port 25565.

Free minecraft server on AWS with zero knowledge of linux

It turns out that the address for entering the server will be <ваш_статичСский_IP>:25565.

Conclusion

Following this instruction, you can raise a free minecraft server with a dedicated IP without difficulty. The article was written in the most simple language and is designed for non-specialists. In this regard, it is interesting to hear the comments of those who have been hacked, because when simplifying the material, factual errors in terminology can be made.

Source: habr.com

Add a comment