Today I’ve tried to configure it with a TURN server.
Download and install a TURN server (here we use coturn).
wget http://coturn.net/turnserver/v22.214.171.124/turnserver-126.96.36.199-CentOS7.4-x86_64.tar.gz # check coturn's release page for latest version
tar xvfz turnserver-188.8.131.52-CentOS7.4-x86_64.tar.gz
chmod +x install.sh
Prepare some information to configure coturn:
openssl rand -hex 32 # generate an static-auth-secret; example: de187fd1cefc7cd6dade0eee65dfc3c242affe6027574597344be43c467a54ef
config show pki # get certificate information, otherwise consider generating a specific certificate for turnserver.
Edit turnserver configuration, uncommenting the following settings (not all of them are required):
# port for plain connection (no TLS)
# TURN listener port for TLS
# Uncomment to use fingerprints in the TURN messages
# Uncomment to use long-term credential mechanism.
# By default no credentials mechanism is used (any user allowed).
# If lt-cred-mech and user-auth-secret are used at the same time, the latter will override the former.
# TURN REST API flag for secret-based authentication
# This feature can be used with the long-term authentication mechanism, only.
# secret defined either by static-auth-secret, or found in the turn_secret table in the database
# 'Static' authentication secret value (a string) for TURN REST API only.
# If not set, then the turn server will try to use the 'dynamic' value in turn_secret table
# The database-stored value can be changed on-the-fly by a separate program.
#The default realm to be used for the users when no explicit origin/realm
#relationship was found in the database. Must be used with long-term
#credentials mechanism or with TURN REST API.
# Total allocation quota.
# Maximum server capacity.
# Total bytes-per-second bandwidth the TURN server is allowed to allocate for the sessions
# Uncomment if extra security is desired
# Certificate file (for TLS)
# Private key file (for TLS)
# Allowed OpenSSL cipher list for TLS/DTLS connections
# (optional) tweak as you need
# prevent stdout log messages (uncommented by default)
# (optional) set the log file name
# warning: set proper file permissions for turnserver
# redirect all log output into system log (uncommented by default)
# no log file rollover will be used, and the log file name
# will be constructed as-is, without PID and date appendage.
# This option can be used, for example, together with the logrotate tool.
# disallow peers on the loopback addresses
# disallow peers on well-known broadcast addresses
# File name to store the pid of the process. (uncommented by default)
# Turn OFF the CLI support.
# By default it is always ON.
# (optional) Do not allow an TLS/DTLS version of protocol
Open port(s) for turnserver (and forward them if necessary):
config set fw_turnserver service status enabled TCPPort 5349 UDPPort 5349 access public
Start and enable turnserver service:
systemctl enable --now turnserver
Configure Nextcloud Talk:
- STUN servers: server.domain.tld:5349
- TURN server: server.domain.tld:5349
- TURN secret: YOUR_SECRET
- UDP and TCP
When using TLS, make sure the certificate and private key have the right file permissions for turnserver user.
It’s easier to start without TLS to check it is working. Then change to TLS and troubleshoot if problems arise.
WebRTC uses long-term authentication mechanism, so you have to use -a option (or
–lt-cred-mech). WebRTC relaying will not work with anonymous access. With -a option, do
not forget to set the default realm (-r option). You will also have to set up the user
accounts, for that you have a number of options:
a) command-line options (-u).
b) a database table (SQLite or PostgreSQL or MySQL or MongoDB)
c) Redis key/value pair(s)
d) You also can use the TURN REST API. You will need shared secret(s)
Assorted things for your consideration:
- Can this interfere with FreePBX (does it have a similar feature)?
- Try if calls are sustained for long time (>30 minutes)
- Try it through VPN
- Try internal/external calls
- Integation with NethServer: make nethserver-coturn package?
- Security considerations?
- turnadmin interface?