How to create a dedicated 7 Days to Die server on Linux

Post Reply
User avatar
LHammonds
Quality 2 - Faulty
Quality 2 - Faulty
Posts: 27
Joined: Wed Jun 07, 2017 1:31 am

How to create a dedicated 7 Days to Die server on Linux

Post by LHammonds » Wed Jun 07, 2017 3:52 am

Overview

These instructions will show you how to create an unmodded (a.k.a. vanilla) dedicated "7 Days to Die" server with a web-based map. It will also host two instances of the game.

Assumptions

These instructions will make the following assumptions. Your server will (should) vary at least in these specific variables.
  • Server IP: 192.168.1.100
  • Server Install Path: /opt/sdtd
  • User account: sdtd
  • User group: sdtd
  • Backup location: /bak/sdtd
  • Instance #1 Name: nav
  • Instance #1 Map: Navezgane
  • Instance #1 Base Port: 25000
  • Instance #1 Control Panel Port: 8080
  • Instance #1 Telnet Port: 8081
  • Instance #1 Web Port: 8082 (automatically set to control panel port +2)
  • Instance #2 Name: rand
  • Instance #2 Map: RandomGen
  • Instance #2 Base Port: 25010
  • Instance #2 Control Panel Port: 8090
  • Instance #2 Telnet Port: 8091
  • Instance #2 Web Port: 8092 (automatically set to control panel port +2)
Tools utilized in this process
Last edited by LHammonds on Thu Jun 15, 2017 2:27 am, edited 1 time in total.

User avatar
LHammonds
Quality 2 - Faulty
Quality 2 - Faulty
Posts: 27
Joined: Wed Jun 07, 2017 1:31 am

Create an Ubuntu Server

Post by LHammonds » Thu Jun 15, 2017 2:18 am

I will assume you built an Ubuntu Server according to these instructions.

You don't need to do all the scripting and automation sections but should at least have the LVM partitions configured so they can grow where needed such as the /opt and /bak volumes.

User avatar
LHammonds
Quality 2 - Faulty
Quality 2 - Faulty
Posts: 27
Joined: Wed Jun 07, 2017 1:31 am

Prep Work

Post by LHammonds » Thu Jun 15, 2017 7:41 am

Install software prerequisites

Used to compile start daemon

Code: Select all

apt-get install gcc
Used to manipulate serverconfig.xml

Code: Select all

apt-get install xmlstarlet
32-bit library

Code: Select all

apt-get install lib32stdc++6
Required by SteamCmd (might be included with lib32stdc++6)

Code: Select all

apt-get install lib32gcc1
Create server folder path

Code: Select all

mkdir -p /opt/sdtd/templates
Create group account

Code: Select all

groupadd -r sdtd
Create low-rights user account

Code: Select all

useradd --comment "7 days to Die Server" -d /opt/sdtd -m -r -s /bin/bash -g sdtd sdtd
Set folder ownership

Code: Select all

chown sdtd:sdtd -R /opt/sdtd

User avatar
LHammonds
Quality 2 - Faulty
Quality 2 - Faulty
Posts: 27
Joined: Wed Jun 07, 2017 1:31 am

Install Management Scripts

Post by LHammonds » Wed Aug 23, 2017 6:50 pm

Code: Select all

mkdir /tmp/t
cd /tmp/t
wget http://illy.bz/fi/7dtd/management_scripts.tar.gz
tar xvzf management_scripts.tar.gz

Code: Select all

vi /tmp/t/etc/7dtd.conf
Line 19: export SDTD_BASE=/opt/sdtd
Line 25: export SDTD_BACKUP_ROOT=/bak/sdtd

Copy files to their final destination

Code: Select all

chown root:root -R /tmp/t/*
chmod 0600 /tmp/t/etc/*
cp -R /tmp/t/etc/* /etc/.
cp -R /tmp/t/usr/* /usr/.
cp /tmp/t/home/sdtd/templates/* /opt/sdtd/templates/.
chown sdtd:sdtd -R /opt/sdtd
Compile the daemon

Code: Select all

cd /usr/local/lib/7dtd/start-stop-daemon
make
Uninstall the compiler

Code: Select all

apt-get remove gcc
Install the game engine

Code: Select all

7dtd.sh updateengine
Install the server fixes

Code: Select all

7dtd.sh updatefixes
Create the Navezgane game instance

Code: Select all

7dtd.sh instances create
Answer the questions however you like but make sure the following are set as follows to avoid conflicts with the other instances:
  • Instance name: nav
  • Base port 25000
  • Control panel port: 8080
  • Telnet port: 8081
Create the RandomGen game instance

Code: Select all

7dtd.sh instances create
Answer the questions however you like but make sure the following are set as follows to avoid conflicts with the other instances:
  • Instance name: rand
  • Base port 25010
  • Control panel port: 8090
  • Telnet port: 8091
List of all instances before startup

Code: Select all

root@ubuntu:/opt# 7dtd.sh instances list
Instance name        | Running  | Players | Port
---------------------+----------+---------+------
nav                  |       no |    -/ 4 | 25000
rand                 |       no |    -/ 4 | 25010
Start all instances

Code: Select all

7dtd.sh start nav
7dtd.sh start rand
List of all instances after startup

Code: Select all

root@ubuntu:/opt# 7dtd.sh instances list
Instance name        | Running  | Players | Port
---------------------+----------+---------+------
nav                  |      yes |    ?/ 4 | 25000
rand                 |      yes |    ?/ 4 | 25010

User avatar
LHammonds
Quality 2 - Faulty
Quality 2 - Faulty
Posts: 27
Joined: Wed Jun 07, 2017 1:31 am

Web Map

Post by LHammonds » Wed Aug 23, 2017 7:55 pm

Make the web map visible

Code: Select all

vi /opt/sdtd/instances/nav/webpermissions.xml
Line 13: <permission module="web.map" permission_level="1000" />

Code: Select all

vi /opt/sdtd/instances/rand/webpermissions.xml
Line 13: <permission module="web.map" permission_level="1000" />

Restart all instances

Code: Select all

7dtd.sh kill nav
7dtd.sh kill rand
7dtd.sh start nav
7dtd.sh start rand
Visit each instances web map

Let's assume your server's IP is 192.168.1.100 for this example. Use a web browser and check each instances web server map:

Web map before login
7dtd-webmap1.jpg
7dtd-webmap1.jpg (28.96 KiB) Viewed 276 times
Web map after login
7dtd-webmap2.jpg
7dtd-webmap2.jpg (81.2 KiB) Viewed 276 times

User avatar
LHammonds
Quality 2 - Faulty
Quality 2 - Faulty
Posts: 27
Joined: Wed Jun 07, 2017 1:31 am

Firewall Rules

Post by LHammonds » Wed Aug 23, 2017 7:59 pm

Raise shields! (add firewall rules)

Reset Firewall to factory default

Code: Select all

echo y | ufw reset
ufw default deny incoming
ufw default allow outgoing
Allow SSH from only LAN connections (set as appropriate)

Code: Select all

ufw allow from 192.168.1.0/24 to any port 22 comment 'SSH for LAN'
Add Steam rules

Code: Select all

ufw allow proto udp to any port 27000:27015 comment 'Steam game client'
ufw allow proto tcp to any port 27000:27015 comment 'Steam game client'
ufw allow out proto udp to any port 27016:27030 comment 'Steam matchmaking'
ufw allow proto udp to any port 27031:27036 comment 'Steam in-home stream'
ufw allow proto tcp to any port 27036:27037 comment 'Steam in-home stream'
ufw allow proto tcp to any port 27015 comment 'Steam SRCDS rcon'
ufw allow out proto udp to any port 3478 comment 'Steam P2P Net / Voice'
ufw allow out proto udp to any port 4379 comment 'Steam P2P Net / Voice'
ufw allow out proto udp to any port 4380 comment 'Steam P2P Net / Voice'
Add 7DTD rules

Code: Select all

ufw allow proto tcp to any port 25000 comment '7dtd base nav'
ufw allow proto udp to any port 25000 comment '7dtd base nav'
ufw allow proto udp to any port 25001:25005 comment '7dtd base+5 nav'
ufw allow proto tcp to any port 25010 comment '7dtd base rand'
ufw allow proto udp to any port 25010 comment '7dtd base rand'
ufw allow proto udp to any port 25011:25015 comment '7dtd base+5 rand'
ufw allow proto tcp to any port 8082  comment '7dtd web map nav'
ufw allow proto tcp to any port 8092  comment '7dtd web map rand'
Enable firewall

Code: Select all

echo y | ufw enable

User avatar
LHammonds
Quality 2 - Faulty
Quality 2 - Faulty
Posts: 27
Joined: Wed Jun 07, 2017 1:31 am

Crontab Schedule

Post by LHammonds » Wed Aug 23, 2017 8:02 pm

Edit the crontab schedule for the root user

Code: Select all

crontab -e -u root

Code: Select all

########################################
# Name: Crontab Schedule for root user
# Author: LHammonds
############# Update Log ###############
# 2017-08-20 - LTH - Created schedule
########################################

SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

## Crontab SYNTAX:
## minute(0-59) hour(0-23) day-of-month(1-31) month(1-12) day-of-week(0-6) command-to-execute

## Backup 7dtd instances
0 22 * * * /usr/local/bin/7dtd.sh backup > /dev/null 2>&1
## Remove 7dtd backups older than 10 days
0 23 * * * find /bak/sdtd/* -type d -ctime +10 -exec rm -rf {} + > /dev/null 2>&1
## 7dtd: Make sure the expected instances are running after a reboot.
@reboot /usr/local/bin/7dtd.sh start nav
@reboot /usr/local/bin/7dtd.sh start rand

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest