How to install TeamSpeak server on Ubuntu 16
TeamSpeak is a voice over internet protocol (VoIP) software that allows users to communicate with each other over the internet. It is often used in computer gaming, but it is also used in business and for general communication between friends and family. This step-by-step article explains how to create and administrate a secure TeamSpeak server on your Ubuntu 16.04 LTS system.
Getting Started
Confirm that you have the following before you follow this guide:
• 1 Node (Cloud Server or Dedicated Server) running Ubuntu 16.
• Root access to the node or one sudo non-root user
• A TeamSpeak client on your platform of choice in order to test things out.
• The following utilities: nano, wget, tar, perl, bzip2 (in case you don’t have them, but they should be installed by default on Ubuntu)
Tutorial
Start by running these commands on your Ubuntu 16.04 server. These commands will automatically get the latest update for your server.
apt-get update && apt-get upgrade -y
Ubuntu should include the nano, wget, perl and bzip2 binaries, but if they aren’t included then you’ll need to install the necessary packages.
apt-get install nano wget tar perl bzip2
Teamspeak User Creation
First we will create a dedicated user that will be used to execute the TeamSpeak server software. This is important from a security standpoint; running daemon programs as root can be dangerous. Creating a new user will allow us to run TeamSpeak with limited privileges. This is done by executing the following command as root:
adduser --disabled-login teamspeak
You can leave the info fields empty and validate the information in the end by pressing Y or simply by pressing enter. It is required that you validate the information when creating the new user.
Now we will install the latest version of the TeamSpeak server software by executing the following command:
wget http://dl.4players.de/ts/releases/3.0.12.4/teamspeak3-server_linux_amd64-3.0.12.4.tar.bz2
tar xvf teamspeak3-server_linux_amd64-3.0.12.4.tar.bz2
cd teamspeak3-server_linux_amd64
cp * -R /home/teamspeak
cd ..
rm -rf teamspeak3-server_linux_amd64*
chown -R teamspeak:teamspeak /home/teamspeak
Startup Script
By default, the TeamSpeak server will not start when your system boots. You will need to create a startup script so that your system will automatically start the TeamSpeak server software on boot. To do this, we will create the following file:
nano /lib/systemd/system/teamspeak.service
Copy the following content into the startup script file:
[Unit]
Description=Team Speak 3 Server
After=network.target
[Service]
WorkingDirectory=/home/teamspeak/
User=teamspeak
Group=teamspeak
Type=forking
ExecStart=/home/teamspeak/ts3server_startscript.sh start inifile=ts3server.ini
ExecStop=/home/teamspeak/ts3server_startscript.sh stop
PIDFile=/home/teamspeak/ts3server.pid
RestartSec=15
Restart=always
[Install]
WantedBy=multi-user.target
When you are done, save the file and exit the editor.
Now we will start the TeamSpeak server and enable it to start when your system boots:
systemctl --system daemon-reload
systemctl start teamspeak.service
systemctl enable teamspeak.service
You can check that your server is actually running with the following command:
systemctl status teamspeak.service
Firewall Rules Addition
If you are using Ubuntu’s firewall service (iptables), you may need to open ports to allow access to your TeamSpeak server. This can be done by executing the following command:
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
For your reference, these are the ports that are used by TeamSpeak:
9987 UDP : TeamSpeak Voice service
10011 TCP : TeamSpeak ServerQuery
30033 TCP : TeamSpeak FileTransfer
If you are using the iptables-services package, you can open these ports by adding this set of rules to your iptables file:
-A INPUT -p udp --dport 9987 -j ACCEPT
-A INPUT -p udp --sport 9987 -j ACCEPT
-A INPUT -p tcp --dport 30033 -j ACCEPT
-A INPUT -p tcp --sport 30033 -j ACCEPT
-A INPUT -p tcp --dport 10011 -j ACCEPT
-A INPUT -p tcp --sport 10011 -j ACCEPT
Administrate Your TeamSpeak Server
When you first connect to your TeamSpeak server using the client software, you will be prompted to enter a privilege key. Entering this key will give you administrative access to the server from the client software. Note that this key can only be used one time.
The privilege key has already been generated when the TeamSpeak server first started. To retrieve the key, run the following command:
cat /home/teamspeak/logs/ts3server_*
This command will return similar to the following:
2********* ********.520940|INFO |ServerLibPriv | |TeamSpeak 3 Server 3.0.12.4 (2016-04-25 15:16:45)
2********* ********.521029|INFO |ServerLibPriv | |SystemInformation: Linux 4.4.0-22-generic #40-Ubuntu SMP Thu May 12 22:03:46 UTC 2016 x86_64 Binary: 64bit
2********* ********.521064|INFO |ServerLibPriv | |Using hardware aes
2********* ********.521891|INFO |DatabaseQuery | |dbPlugin name: SQLite3 plugin, Version 2, (c)TeamSpeak Systems GmbH
2********* ********.521935|INFO |DatabaseQuery | |dbPlugin version: 3.8.6
2********* ********.522295|INFO |DatabaseQuery | |checking database integrity (may take a while)
2********* ********.548703|INFO |SQL | |db_CreateTables() tables created
2********* ********.724410|WARNING |Accounting | |Unable to find valid license key, falling back to limited functionality
2********* ********.946351|INFO | | |Puzzle precompute time: 1193
2********* ********.947038|INFO |FileManager | |listening on 0.0.0.0:30033
2********* ********.948636|INFO |VirtualSvrMgr | |executing monthly interval
2********* ********.948799|INFO |VirtualSvrMgr | |reset virtualserver traffic statistics
2********* ********.020816|INFO |CIDRManager | |updated query_ip_whitelist ips: 127.0.0.1,
2********* ********.021840|INFO |Query | |listening on 0.0.0.0:10011
2********* ********.015755|INFO |VirtualServer |1 |listening on 0.0.0.0:9987
2********* ********.016218|INFO |VirtualServer |1 |client 'server'(id:0) added privilege key for servergroup 'Server Admin'(id:6)
2********* ********.016251|WARNING |VirtualServer |1 |--------------------------------------------------------
2********* ********.016272|WARNING |VirtualServer |1 |ServerAdmin privilege key created, please use the line below
2********* ********.016290|WARNING |VirtualServer |1 |token=******************************************************
2********* ********.016318|WARNING |VirtualServer |1 |--------------------------------------------------------
What you are looking for here is the token. Copy and paste it into your TeamSpeak client. If everything is successful, you will get this message:
Privilege Key successfully used.
Your newly-connected user will then be granted full administrative rights over your TeamSpeak server.
Conclusion
You’ve now successfully installed and configured a TeamSpeak server on your Ubuntu 16.04 LTS system. You have also created a startup script for the server so that it is executed automatically when your system boots and configured your iptables firewall to allow external users to connect using TeamSpeak’s ports. You can now enjoy all of the features of your TeamSpeak server and start communicating with your friends and colleagues.
If you found this article helpful, feel free to share it with your friends and let us know in the comments below!