~/Blog

Brandon Rozek

Photo of Brandon Rozek

PhD Student @ RPI studying Automated Reasoning in AI and Linux Enthusiast.

Starbound Server using LXC

Published on

4 minute reading time

I recently had a gaming session with old friends and we played the game Starbound. In hopes of continuing our session in the near future, I set up a Starbound server for us all to connect to.

However, since I’ve recently learned how to setup LXC containers, my host OS is Fedora, and the steamcmd provides instructions for Debian, Ubuntu, and Arch. I’ve decided to set up a system container using LXC.

Also who knows how secure these game servers are. It’s likely a good idea to virtualize them when possible…

This guide assumes you have a Ubuntu Jammy (22.04) amd64 system container configured and that you’re within the root shell of that container. For help with that, check out my post.

Installing Starbound

Since we start off with a root account, let’s create another user which we’ll call steam.

adduser steam

We’ll give sudo privileges to our steam user. You can always remove this privilege after setting it up.

usermod -aG sudo steam

Now let’s go into our steam user

su steam

Before using apt, it’s always a good idea to make sure our system is up to date.

sudo apt update && sudo apt upgrade

Steam requires 32-bit libraries to work properly, so we’ll need to setup the multiverse repository and add i386 support.

sudo apt install software-properties-common
sudo add-apt-repository multiverse
sudo dpkg --add-architecture i386

Finally, we can update our local cache and install steamcmd.

sudo apt update
sudo apt install steamcmd

Now let’s open our steam shell.

steamcmd

We should now see a steam> at the beginning of our prompt. We’ll tell steam to install Starbound under the Starbound folder of our $HOME directory.

force_install_dir /home/steam/starbound

I’m unsure if we need to login or do this anonymously. When I set this up, I’ve logged into my steam account. Write to me if you were able to get this to work anonymously.

login <username> <password>

After logging in (it might ask for a 2FA code), we can install Starbound using the following command.

app_update 211820

We can then leave the steam shell.

quit

At this point, we should check to see if the server binary runs as expected.

/home/steam/starbound/linux/starbound_server

If this works, great! I didn’t face any issues at this step, but feel free to write in if you did.

Configuring Networking

We now have a Starbound server running from within our LXC container. Since we want players outside of the host system to access the Starbound server, we’ll need to setup some firewall rules and TCP forwarding.

First we’ll need to allow traffic to go into our container network.

sudo ufw allow in on lxdbr0
sudo ufw route allow in on lxdbr0

On the host, we need to open up the Starbound port

sudo ufw allow 21025

Then we need to route TCP traffic back and forth. For this I used nginx.

sudo dnf install nginx

We need to get the container IP.

lxc-ls --fancy

Add the following to the end of /etc/nginx/nginx.conf

stream {
    upstream starbound {
        server CONTAINERIP:21025;
    }

    server {
        listen 21025;
        proxy_pass starbound;
    }
}

Start and enable the nginx service

sudo systemctl enable --now nginx

If you face an error here, it might be because of selinux. Either disable that or configure it to allow for binding of 21025.

At this point, you can try to connect to the Starbound server using the game! I didn’t face any unexpected issues at this part, but feel free to write in if you did.

Locking down Starbound (Optional)

This part is optional, but if you don’t want any arbitrary person to connect to your Starbound server, you’ll need to lock it down.

Inside your container exit the /home/steam/starbound/storage/starbound_server.config

Disallow anonymous connections

"allowAnonymousConnections": false

Add users with usernames and passwords

"serverUsers" : {
  "user1" : {
    "admin" : false,
    "password" : "somethinghere"
  },
  "user2" : {
    "admin" : false,
    "password" : "somethinghere2"
  }
}

Keep in mind that we didn’t set up TLS so I wouldn’t put a password here that gets used anywhere else.

Automatically Starting up the Starbound server

First make sure the container autostarts on boot.

Then within the container, we can set up a systemd service to start the starbound server.

Edit /etc/systemd/system/starbound.service

[Unit]
Description=StarboundServer
After=network.target

[Service]
WorkingDirectory=/home/steam/starbound/linux
User=steam
Group=steam
Type=simple
ExecStart=/home/steam/starbound/linux/starbound_server
RestartSec=15
Restart=always
KillSignal=SIGINT

[Install]
WantedBy=multi-user.target

Then start and enable the service

sudo systemctl enable --now starbound
Reply via Email Buy me a Coffee
Was this useful? Feel free to share: Hacker News Reddit Twitter