Setup Teamspeak 3 Server on Linux

A quick guide to setup Teamspeak 3 server on Ubuntu 16.04, Ubuntu 14.04, CentOS 6, CentOS 7, Debian 7 & Debian 8.

Introduction

A Teamspeak server is a piece of VoIP software which allows users to communicate with each other via speech. Teamspeak consists of two applications: a client and a server.

The client application is the program that you use on your computer to log into teamspeak. It can be downloaded from the download page on the official website. Download the client for the operating system that you are using.

The server application is the application that brings each client together. It is in charge of processing the VoIP data and handling messages between you and your friends.

This guide will explain the basics of setting up a TeamSpeak 3 server on Linux (Debian, CentOS & Ubuntu Distributions).

Prerequisites

  • A VPS running Ubuntu / Debian / CentOS.

  • Teamspeak client software installed on your computer.

  • An initial server setup for:

Step 1 - Adding User For Teamspeak 3 Server

First, create a new user with your desired name, we will use the name "teamspeak" for this guide.

Ubuntu / Debian

adduser --disabled-login teamspeak

CentOS

useradd teamspeak
passwd teamspeak

Step 2 - Downloading Latest Version of Teamspeak 3 Server

Get the latest TeamSpeak 3 server files for 64-bit Linux. Check their website, a new version may be available for all the distributions.

wget http://dl.4players.de/ts/releases/3.3.0/teamspeak3-server_linux_amd64-3.3.0.tar.bz2

Step 3 - Extracting the tar.bz2

Extract the archive for all the distributions.

tar xvf teamspeak3-server_linux_amd64-3.3.0.tar.bz2

This will create a new folder in the root directory called: teamspeak3-server_linux_amd64

Step 4 - Moving the Files to Home Directory of Teamspeak

Move the extracted files to the teamspeak user's home directory then remove the extracted folder and downloaded archive.

cd teamspeak3-server_linux_amd64 && mv * /home/teamspeak && cd .. && rm -rf teamspeak3*

Accept the license agreement:

touch /home/teamspeak/.ts3server_license_accepted

Step 5 - Setting up Ownership for user Teamspeak

Change ownership of the TeamSpeak 3 server files.

chown -R teamspeak:teamspeak /home/teamspeak

Step 6 - Setting up start script

Ubuntu 16.04 / Debian 8 / CentOS 7 or Higher

Make the TeamSpeak 3 server start on boot. Use your favorite editor to make a new file called teamspeak.service in /lib/systemd/system/.

nano /lib/systemd/system/teamspeak.service

Paste this content into it:

/lib/systemd/system/teamspeak.service
[Unit]
Description=TeamSpeak 3 Server
After=network.target
[Service]
WorkingDirectory=/home/teamspeak/
User=teamspeak
Group=teamspeak
Type=forking
ExecStart=/home/teamspeak/ts3server_startscript.sh start
ExecRestart=/home/teamspeak/ts3server_startscript.sh stop
ExecStop=/home/teamspeak/ts3server_startscript.sh stop
PIDFile=/home/teamspeak/ts3server.pid
RestartSec=15
Restart=always
[Install]
WantedBy=multi-user.target

Once you are done, save the file and close the editor. Now we will activate the script so that it will start on boot.

This makes to systemd recognize the file we just created.

systemctl --system daemon-reload

Enable the service.

systemctl enable teamspeak.service

Start the TeamSpeak server.

systemctl start teamspeak.service

Once you've started the server, you can check that it's running with this command.

systemctl status teamspeak.service

Ubuntu 14.04 / Debian 7 or Lower

Make Teamspeak3 start on boot up. For this, we will need to create a symlink to the script which was included in the archive that we downloaded earlier.

sudo ln -s /usr/local/teamspeak/ts3server_startscript.sh /etc/init.d/teamspeak
sudo update-rc.d teamspeak defaults

Now all that is left to do is to start your Teamspeak server!

sudo service teamspeak start

On your terminal, you will see a screen with the query username/password and a privilege key - be sure to write this information down as you will need it to administer your server.

CentOS 6 or Lower

Now we need to create the script in the /etc/init.d folder:

nano /etc/init.d/teamspeak

Once you are in the file paste the following code into the file by right clicking the mouse.

/etc/init.d/teamspeak
#!/bin/sh
# chkconfig: 2345 99 10
USER="teamspeak"
TS3='/home/teamspeak/'
STARTSCRIPT="$TS3/ts3server_startscript.sh"
cd $TS3
case "$1" in
'start')
su $USER -c "$STARTSCRIPT start"
;;
'stop')
su $USER -c "$STARTSCRIPT stop"
;;
'restart')
su $USER -c "$STARTSCRIPT restart"
;;
'status')
su $USER -c "$STARTSCRIPT status"
;;
*)
echo "Usage $0 start|stop|restart|status"
esac

Click Ctrl + O to save the file then Ctrl + X to exit the file. We can then set the file permission so it will work properly.

chmod 755 /etc/init.d/teamspeak

Now we need to add the service so it will restart when the server is restarted. Enter the following commands and then restart the server.

chkconfig --add teamspeak
chkconfig --level 2345 teamspeak on

Once the server restarts connect to teamspeak and make sure everything restarted. You can also check the status through command line by using the following command.

service teamspeak status

Step 7 - Retrieving Privilege Key

When you first try to connect to your TeamSpeak server, you may be prompted to use a privilege key. This privilege key allows to administrate your TeamSpeak server. To get this privilege key, use the following command:

cat /home/teamspeak/logs/ts3server_*

At bottom you'll see something that looks like this:

--------------------------------------------------------
ServerAdmin privilege key created, please use the line below
token=****************************************
--------------------------------------------------------

Replace the stars with your unique token, and enter it into your TeamSpeak client. You'll see a prompt telling you that the privilege key was successfully used.

Optional: Firewall

If you are using the built-in firewall that was included with the Ubuntu installation then iptables is your firewall. You may need to forward the following ports to allow connections to your TeamSpeak 3 Server.

iptables -A INPUT -p udp --dport 9987 -j ACCEPT
iptables -A INPUT -p udp --sport 9987 -j ACCEPT
iptables -A INPUT -p tcp --dport 30033 -j ACCEPT
iptables -A INPUT -p tcp --sport 30033 -j ACCEPT
iptables -A INPUT -p tcp --dport 10011 -j ACCEPT
iptables -A INPUT -p tcp --sport 10011 -j ACCEPT

Conclusion

Congratulations! You've successfully created a Teamspeak Server. You can connect to it with the Teamspeak Client.

Have fun!