1. This forum is obsolete and read-only. Feel free to contact us at support.keenswh.com

[Tutorial] Dedicated Server on Linux using Virtualbox (Step by Step)

Discussion in 'Groups & Dedicated Servers' started by Ch3ck3r, May 31, 2014.

Thread Status:
This last post in this thread was made more than 31 days old.
  1. Ch3ck3r

    Ch3ck3r Trainee Engineer

    Messages:
    9
    Hi guys!

    I spent the last 1.5 days installing and troubleshooting a space engineers dedicated server on a linux server with virtualbox. This is a step by step guide to save you some time. I decided to make this tutorial quite detailed. If you are an experienced linux user you may skip some of my explanations.

    This guide is far from optimal. Feel free to comment and improve this guide!


    First a word of warning
    Running a dedicated server in a virtualbox works fine! Anyway, don't expect your virtualbox to be extraordinally performant. To get acceptable performance you need to have a good server. So don't try this on your old single core linux box from your cellar.

    Prerequisits
    What you will need
    A linux server (i use ubuntu - commands in this guide will be for ubuntu)
    A licensed copy of SpaceEngineers
    A licensed copy of a Windows Operating System (e.g. Windows Server 2008)
    Some hours of free time

    Let's Go!

    -- Virtual Box stuff --

    First things first! We need to install virtualbox on the linux server. Run the following command to install virtualbox from the package repositories.
    Code:
    sudo apt-get install virtualbox
    Now let's create a new user on your linux box that runs the virtualbox.
    Code:
    sudo useradd -d /home/virtualbox -m virtualbox
    This creates a user virtualbox and its home directory in /home/virtualbox.
    Log in with your newly created user
    Code:
    sudo su - virtualbox
    We will now create the virtualbox and configure it. Because we will need to enter it several times, we will define our virtualbox name in a variable
    Code:
    VM=SpaceEngineers\ Dedicated\ Server
    Create a Disk for your operating system (e.g. 32 GB)
    Code:
    mkdir hdd
    cd hdd
    VBoxManage createhd --filename $VM.vdi --size 32768
    Create the virtualbox for Windows Server 2008 64 bit
    Code:
    cd ..
    mkdir vms
    cd vms
    vboxmanage createvm --name $VM --ostype "Windows2008_64" --register
    If you want to use a different operating system you can find the ostype by issuing the command
    Code:
    vboxmanage list ostypes
    Edit some of the settings of your virtualbox. You need to modify these to fit your needs
    Code:
    cd ..
    VBoxManage storagectl $VM --name "SATA Controller" --add sata --controller IntelAHCI
    VBoxManage storagectl $VM --name "IDE Controller" --add ide
    VBoxManage modifyvm $VM --ioapic on
    VBoxManage modifyvm $VM --boot1 dvd --boot2 disk --boot3 none --boot4 none
    VBoxManage modifyvm $VM --memory 2048 --vram 256
    VBoxManage modifyvm $VM --nic1 nat
    VBoxManage modifyvm $VM --natsettings1 1500,1024,1024,1024,1024
    VBoxManage modifyvm $VM --cpus 4
    VBoxManage modifyvm $VM --memory 4096
    vboxmanage storageattach $VM --storagectl "SATA Controller" --device 0 --port 0 --type hdd --medium hdd/$VM.vdi
    To be able to connect to your (soon to be installed) windows we need to enable the vrdp extension of virtual box. Download the extension pack and install it
    Code:
    wget https://download.virtualbox.org/virtualbox/4.3.12/Oracle_VM_VirtualBox_Extension_Pack-4.3.12-93733.vbox-extpack
    vboxmanage extpack install Oracle_VM_VirtualBox_Extension_Pack-4.3.12-93733.vbox-extpack
    rm Oracle_VM_VirtualBox_Extension_Pack-4.3.12-93733.vbox-extpack
    mkdir media
    Be sure to match your Virtualbox version to the extpack version! Find a list of all extpacks here: https://www.virtualbox.org/wiki/Downloads

    Now upload your Windows operating system ISO and save it to ~virtualbox/media/windows.iso
    Mount the iso file and start the virtualbox
    Code:
    VBoxManage storageattach $VM --storagectl "IDE Controller" --port 0 --device 0 --type dvddrive --medium media/windows.iso
    VBoxManage startvm $VM --type headless
    The rdp (Remote Desktop Protocol) is listening on port 3389. Forward port 3389 to any of your local ports using putty port tunneling or ssh port tunneling.
    Connect to your windows with your favourite Remote Desktop Client and install windows. Do some basic configuration of your windows system.
    Don't forget to install the .NET 4 Framework on your windows.

    Now remove the iso file from your vm
    Code:
    VBoxManage controlvm $VM poweroff
    VBoxManage storageattach $VM --storagectl "IDE Controller" --port 0 --device 0 --type dvddrive --medium none
    Now let's install the virtual box guest additions
    Code:
    sudo apt-get install virtualbox-guest-additions-iso
    VBoxManage storageattach $VM --storagectl "IDE Controller" --port 0 --device 0 --type dvddrive --medium /usr/share/virtualbox/VBoxGuestAdditions.iso
    VBoxManage startvm $VM --type headless
    Connect to the RDP and install the guest additions from the CD in the virtual CD Drive
    After installing the guest additions remove the iso
    Code:
    VBoxManage controlvm $VM poweroff
    VBoxManage storageattach $VM --storagectl "IDE Controller" --port 0 --device 0 --type dvddrive --medium none

    Now that your windows inside virtual box is up and running we can start installing the space engineers server. To do this, we will add a shared folder between your linux server and the windows guest and we will add another hard drive to your windows for the SpaceEngineers Data (Savegames, Configs etc)

    Code:
    mkdir -p shares/SE-Host
    VBoxManage sharedfolder add $VM --name "Host" --hostpath ~virtualbox/shares/SE-Host --automount
    cd hdd
    vboxmanage createhd --filename SE-Data.vdi --size 10240 --variant Fixed
    vboxmanage storageattach $VM --storagectl "SATA Controller 1" --device 0 --port 1 --type hdd --medium SE-Data.vdi
    cd ..
    You can now copy files between your host (linux server) and your guest (windows inside virtualbox) by putting files into ~virtualbox/shares/SE-Host on linux and into \\vboxsvr\Host on windows.


    -- Space Engineers Server --

    Now upload your SpaceEngineersDedicated.zip into the ~virtualbox/shares/SE-Host directory
    and start your virtualbox again
    Code:
    VBoxManage startvm $VM --type headless
    Log into your virtualbox, open the storage device manager and format your second HDD (10GB) and mount it with a drive letter of your choice (I chose S:\)

    Go to computer and map a new network drive.
    Map the network driver \\vboxsvr\Host to a drive letter of your choice (I chose H:\). Access the network drive and copy your spaceengineers.zip file. Extract the contents of the zip file to S:\.
    Create two additional folders: S:\ called "Data" and "DedicatedData". We will use these folders to the files of the space engineers server (configurations, savegames etc.)
    Create two links to your folders by opening a cmd on your windows and type

    Code:
    mklink /J C:\ProgramData\SpaceEngineersDedicated S:\Data 
    mklink /J C:\Users\Administrator\AppData\Roaming\SpaceEngineersDedicated S:\DedicatedData
    You can now start your SpaceEngineersDedicated.exe from one of the S:\DedicatedServer or S:\DedicatedServer64 folders. Select the console instance and start your first game.
    After your first game is started stop it again and look into the folders S:\Data and S:\DedicatedData. The server should have created some folders and files in one of them.
    Which one is used depends on the windows version you installed in the virtualbox. For Windows Server 2008 the data is in S:\DedicatedData.

    Configure your server settings to your needs and make sure that SpaceEngineers-Dedicated.cfg contains the line
    Code:
    <OnlineMode>PUBLIC</OnlineMode>
    Basically you can follow one of the available guides for hosting on windows to get your server up and running.

    Hint: I had some problems using the default port for SpaceEngineers. I used a different Port instead (42000). So this guide will assume you selected 42000 as your server port
    Hint: Do not enter your server's ip address into the ip address field. Keep it 0.0.0.0. The server will find the correct ip itself.

    -- Network Stuff --

    If you start your server now you will not be able to see the server in steam's list and you will not be able to join the game.
    We need to do some network configuration before your server is available for everyone.

    First disable the windows firewall inside virtualbox completely. This is no security problem because your virtualbox windows is protected behind its NAT Network adapter.
    The outside world (the internet) can't see your virtualbox and can't connect to it. That's one of the reasons why you needed to tunnel the rdp port 3389.
    I assume that your linux server has its own firewall like iptabes.

    Now shut down the virtualbox by shutting down your windows the old fashioned way or by typing this into your command line (on the linux server)
    Code:
    vboxmanage controlvm $VM poweroff
    We need to forward two ports from your host machine to your guest windows. These ports are 8766 and your selected server port (42000 in my case).
    8766 is used by steam and is defined in your SpaceEngineers-Dedicated.cfg
    Code:
    <SteamPort>8766</SteamPort>
    To do this issue the following commands
    Code:
    vboxmanage modifyvm $VM --natpf1 ,udp,,42000,,42000
    vboxmanage modifyvm $VM --natpf1 ,tcp,,42000,,42000
    vboxmanage modifyvm $VM --natpf1 ,udp,,8766,,8766
    vboxmanage modifyvm $VM --natpf1 ,tcp,,8766,,8766
    I have a quite strict firewall setup on my linux server using iptables. So i have to explicitely allow the traffic on these ports
    Code:
    sudo iptables -I INPUT -p tcp --dport 8766 -j ACCEPT
    sudo iptables -I OUTPUT -p tcp --sport 8766 -j ACCEPT
    sudo iptables -I INPUT -p udp --dport 8766 -j ACCEPT
    sudo iptables -I OUTPUT -p udp --sport 8766 -j ACCEPT
    sudo iptables -I INPUT -p udp --dport 42000 -j ACCEPT
    sudo iptables -I OUTPUT -p udp --sport 42000 -j ACCEPT
    Now boot your virtualbox again and start your SpaceEngineersServer
    Code:
    vboxmanage startvm $VM --type headless
    That's it! You can now play on your space engineers server!

    -- Problem 1 : Server not responding / Server not showing in server list --
    If your server is not visible in the list of servers and it says "server not responding" up on entering
    the ip address directly you need to modify how your virtualbox handles udp traffic.

    In this case the virtualbox NAT network adapter fails to masquerade the source and destination ips of the udp
    packages sent and received by your server. You can check this by running a packet sniffer on your windows.
    You will see a lot of udp packages with source or remote ip address 10.0.2.2 (where 10.0.2.2 is the gateway address of the virtualbox) which is obviously wrong.

    Solution: Change some network settings onyour virtualbox
    Code:
    vboxmanage controlvm $VM poweroff
    vboxmanage modifyvm $VM --nataliasmode1 proxyonly
    vboxmanage startvm $VM --type headless
    -- Problem 2 : Server host has left the game --
    You can see your server in steam and the ingame browser, but you can not join it.
    Everytime you try to join your game it says "The server host has left the game".

    This problem is related to the way that space engineers downloads the map from the server to the client.
    To do this, space engineers servers tries to "punch a hole" in the Network address translation of the server and the client.
    If you want to know more about this read up on STUN or STUNT protocol on wikipedia.

    The problem is that your firewall blocks these STUN packets.

    Solution: I have not yet found a satisfying solution for this.

    But meanwhile you can fix this problem by just allowing all outgoing udp packages from your server
    Code:
    sudo iptables -I OUTPUT -p udp -j ACCEPT
    This is not really satisfying as it opens way to big holes in your firewall but it works.

    -- Problem 3: Slow map download
    Again this seems to be related to STUN
    To speed up the download open your udp input in your firewall
    Code:
    sudo iptables -I INPUT -p udp -j ACCEPT

    -- You have reached the end --

    Thanks for reading. I hope this helps you guys. I hope i did not forget any important steps.
    Feel free to comment and give your feedback to improve this manual.
     
    • Like Like x 1
  2. Aridhol

    Aridhol Trainee Engineer

    Messages:
    38
    Hm I like this guide, I've gotten most of the way through.. but I am stuck at port forwarding / rdp, can you help me get past that? I just can't seem to connect no matter what I do to set that up...
     
  3. gimmilfactory

    gimmilfactory Junior Engineer

    Messages:
    523
    This does nothing for WINE being broken with ore and all the loose ends it throws out, it just sets up a virtual machine and gets the files "ready", it does not give you a working DS of Space Engineers.
    I just set up a virtual windows 2008 server on my Linux host, just because there is as of yet, no work-around for them to run under linux.

    It's a great tutorial don't get me wrong, and half of the forwarding is not needed if you set the NIC correctly.
    On your host (if its linux do ifconfig, if windows, use command prompt and do ipconfig ) to get your adapter name. And use vbox to set it accordingly.

    My nic is nammed p135p1. When I do ifconfig

    "p135p1 Link encap:Ethernet HWaddr 48:5b:39:0a:27:7c"

    is the first line after the "lo" local redirect adapter.

    So in vbox I use "vboxmanage modifyvm WinServ08 --nic1 bridged --bridgeadapter1 p135p1 --cableconnected1 on"
    You can assign the virtual machine's own IP once it is set up, and it will act just like a normal PC on your LAN connection with a 192.168.1.* address, able to also view shared folders over Network.
     
  4. Aridhol

    Aridhol Trainee Engineer

    Messages:
    38
    That seems incorrect sir, a virtual machine is in fact a full version of windows, there is no reason you cannot run the server perfectly fine in a virtual machine environment if setup correctly... how do I know? I work with them under totally different circumstances all the time... unfortunately, totally different lol, thus my problem making this guy work.. I hardly ever have to setup VMs on my dedicated hardware that is 3000 miles away from me... Makes it a little harder :p
     
  5. Ch3ck3r

    Ch3ck3r Trainee Engineer

    Messages:
    9
    To acces the virtualbox you need to connect to the vrdp port. Normally your virtualbox listens on port 3389. If you are not sure if your virtualbox listens on that port, start the virtual machine by issuing
    Code:
    vboxheadless -s <name of virtual machine>
    It will then prompt you the port it listens on. If this port is open on your server just connect to your server ip on this port with windows remote desktop. If it is not open either open it in your linux firewall or tunnel it to your computer using putty / ssh. Here is a tutorial for putty https://www.cs.uu.nl/technical/services/ssh/putty/puttyfw.html
    Specify a source port of your liking (e.g. 1234) and specify the remote address as "127.0.0.1:3389" (or any other port if your virtualbox listens somewhere else)
    You can then use Remotede Desktop to connect to "localhost:1234" (use the source port you specified in putty)

    Yes you are correct, and i have not stated anywhere that this tutorial is for wine or that it fixes any of the wine issues

    Yes this is correct. If you want a bridged network. I did not use a bridged network for several reasons. Some of them are
    • You will need an additional ip address, if you do this in a data center (this usually costs money)
    • If you don't want to buy an additional ip address you will need to configure an additional router on your linux server
    • This exposes the complete virtual machine to the internet. Making it vulnerable for attacks / hacks. Yes you don't need to do port forwarding, but instead you have to cope with a lot of security issues, and i don't like to cope with security issues on a windows server. It is (for me) much more comfortable to just deal with security issues on my linux box and have the windows virtual box behind my iptables firewall
     
  6. Aridhol

    Aridhol Trainee Engineer

    Messages:
    38
    Figured out what I was doing wrong..

    I had the wrong version of virtualbox + extpack.. My Machine downloaded an older virtualbox and your link for the extpack is new, so I had to line up versions and tada, good to go :)

    Thanks man, very helpful.. I'll report back on how it goes from here :)
     
  7. xrichard

    xrichard Trainee Engineer

    Messages:
    9
    Two things I've noticed:

    1. Map download speeds are relatively slow, about 200-250 kB/s. With larger maps (13MB in my case) this becomes more of an issue. I know game servers can be quite inefficient (and sometimes come with artificial limitations) when transferring files vs regular old http. What speeds are you people getting?

    2. Every now and then, the CPU usage spikes on the machine, clients are shown a "the server is not responding" message for ~5 seconds, and we think this might be the autosave kicking in. Has anyone else experienced this? The server is running on a 4770 with SSDs and 4GB of ram and 4 cores assigned to it. I/O performance shouldn't be an issue, but I know how slow VMs can be when it comes to this.
     
  8. Ch3ck3r

    Ch3ck3r Trainee Engineer

    Messages:
    9
    I have noticed slow map downloads and i have found two issues
    1. You need to modify buffer sizes for udp packages in the virtual machine
    Code:
    VBoxManage modifyvm $VM --natsettings1 1500,1024,1024,1024,1024
    I did a speedtest before and after this setting. Before speed was at ~2mbit/s. After those settings speed increased to ~140mbit/s. Still not the speed it should have (1gbit/s) but better than before.
    2. I have increased map download speed by opening more udp ports. Opening all of the udp ports led to a map download of app. 10 to 20 seconds for a ~8mb map file. Fast enough for me.

    For problem number 2: I have noticed something similar in regular time intervals. Approximately every 1,5 to 2 hours the server spikes and all clients lose connection until server restart. I don't know why yet.
     
  9. xrichard

    xrichard Trainee Engineer

    Messages:
    9
    I did that and it had no effect, at least not on transfer speeds in SE. The VM can reach speeds above 300Mbps on speedtest, but SE transfers are still just as slow.
     
  10. Aridhol

    Aridhol Trainee Engineer

    Messages:
    38
    Wahoo! My server is off to the races!

    Thanks a ton for your help.. this is much much better than using wine... I hate wine..

    Server is running like a champ, group id configured properly and I confirmed it only lets members of my group into the server!

    Highly recommend this guide, should get sticky since it actually works.. no issues with slow downloads noted on my end, but I will investigate that more later and report back.

    Thanks again
     
  11. ready

    ready Trainee Engineer

    Messages:
    14
    I have an issue.

    Server says its up and running it is also connected to steam (if i could trust the server log) but i cant find my server in the steam server browser.

    Ports are forwarded correctly to the VM and the server starts regullary maybe some bad config?

    What shall i add in the IP field? the actual public ip of the host or the one from the VM?

    [​IMG]
    i hope you guys can help me

    Thanks in advance
     
  12. Ch3ck3r

    Ch3ck3r Trainee Engineer

    Messages:
    9
    Keep the ip adress 0.0.0.0 the server will then figure out the correct public ip address itself. That is the only way it works for me.
     
  13. ready

    ready Trainee Engineer

    Messages:
    14
    Well i looked for the official config and then i saw the thing with the 0.0.0.0 so it is currently running with this configuration but still i cant see the server online :(


    EDIT: I've fired up a packet sniffer and i see bunch of UDP packets on Port 42000 with the source OR destination of 10.0.2.15 which is my VM's IP address is this correct?

    Because i already changed the nataliasmodel to proxyonly


    EDIT2: Im probably the stupidest person alive forgot to turn off windows firewall ... it works...

    Thanks for the support ^^
     
  14. Infected

    Infected Trainee Engineer

    Messages:
    5
    You can cut a lot of the command line stuff from this tutorial by installing phpvirtualbox. It's nice web front end for virtualbox on linux.

    https://sourceforge.net/projects/phpvirtualbox/

    [​IMG]
     
Thread Status:
This last post in this thread was made more than 31 days old.