How to install Turn/Stun server on AWS Ubuntu 20.04

Updated 7 February 2023

What is a Stun server?

STUN (Session Traversal Utilities for NAT) and TURN (Traversal Using Relays around NAT) servers are both used in the signaling process.

Before creating a peer-to-peer connection, servers must determine each participant’s IP address. The majority of the time, webRTC applications use STUN servers.

They are straightforward, quick, and, most importantly, do not generate a lot of loads.

Furthermore, they are only used during connection setup to discover and exchange external host port pairs.

Media will be exchanged directly between participants once the session has been established. STUN is, however, occasionally blocked by firewalls.

As a result, when STUN fails, developers must “turn” and use a TURN server.

What is a Turn server?

Access to the IP address might be restricted by firewalls and secure business settings. It becomes impossible for two networks to find one another without distinctive identifiers.

By acting as an intermediary, TURN servers can be used to solve this issue. A TURN server, in contrast to STUN, stays in the media path after the connection has been made.

We will use coturn, a free open-source implementation of TURN and STUN Server that grew from the rfc5766-turn-server project and includes more advanced capabilities.

Step 1- Run the below command for updating the packages

Step 2- Now run the below command for installing the coturn

Make sure the service is running to confirm it runs the below command

You should get below output

To start/stop the coturn service use the below commands

Step 3- Let’s enable the Turn server in the coturn configuration file.

Open the file using the above command and un-comment the last line. The file should look like this save and exit.

Step 4- Now make some changes in the configuration file present in the /etc directory.

First, we will take a backup of the existing default configuration file. For this run the below command

Now make the new file by the below command

Now open the file using vim or nano editor and paste the below data:

Make sure that port no. 5349 and 3478 for the UDP and TCP Protocol are open for both IPv4 and IPv6 (incoming connection). See the below attached Screen Shot.

Step 5- Restart the service

Now restart the service once so that the changes that we have made will get reflected

Step 6- Testing Stun and Turn Server

We can test our STUN and TURN server from the tool on Trickle ICE

Now add the details of your TURN and STUN server

Now click on the Gather candidates button and you should receive the below output.

When testing a STUN server, if you can assemble a candidate with the type “srflx,” it works. If you test a TURN server, it works if you can gather a candidate of type “relay”.

For Magento 2 Elastic search, please follow the –

Our Cloudkul Blogs

Elasticsearch, Fluentd, and Kibana (EFK) 

Setting up Elasticsearch, Logstash, and Kibana for centralized logging

Managing and Monitoring Magento 2 logs with Kibana

Our store modules –

Magento 2 Elasticsearch

EFK Setup for Magento 2

You may also visit our Magento development services and quality  Magento 2 Extensions.

For further help or query, please contact us or raise a ticket.

Category(s) AWS cloud ecommerce
. . .

Leave a Comment

Your email address will not be published. Required fields are marked*

Be the first to comment.

Start a Project

    Message Sent!

    If you have more details or questions, you can reply to the received confirmation email.

    Back to Home