stun / turn server deployment

I. Introduction

Through installed on the server coturn this software, set up STUN server and TURN servers.

coturn Description: is a free open source TURN / STUN server. coturn server complete implementation of STUN / TURN / ICE protocol, supports P2P penetrate the firewall.

 

 

STUN Server for detecting NAT type .

TURN server after a failure of a communication relay point.

 

coturn of Github Source:

https://github.com/coturn/coturn

 

coturn of wiki use:

https://github.com/coturn/coturn/wiki

 

 

Q:

stun server and turn on the server deployment steps, what's the difference?

 

A:

Because TURN is a STUN extension, so TURN server can be used as STUN server to use.

There is no difference in the software configuration.

In the hardware configuration, STUN server 2 needs to have a public IP network on the server, turn the server only needs to have a public IP network.

So, if you want:

Configuring only stun server: step as described herein, also need to have a table with two public IP network server.

Configuring only turn the server: step as described herein.

1 server configure and turn stun server: step as described herein, also need to have a table with two public IP network server.

 

 

Second, the installation

Installation process is divided into two parts

  1. Mirror without coturn source, here to ubuntu14.04 LTS 64 bit Case
  2. Mirror comes with coturn source ( recommended, this is convenient ), here to ubuntu16.04 LTS 64 bit Case

 

1.  Mirror without coturn source , here to ubuntu14.04 LTS 64 bit Case

1. Install the relevant environmental

sudo apt-get install libssl-dev

sudo apt-get install libevent-dev

sudo apt-get install libpq-dev

sudo apt-get install mysql-client

sudo apt-get install libmysqlclient-dev

sudo apt-get install libhiredis-dev

sudo apt-get install git

sudo apt-get install make

2. Download and install the relevant code

git clone https://github.com/coturn/coturn

coturn cd /

./configure

make

sudo make install

See the chart below it shows already installed, this is a matter of some description, if you want to set it in daemon can look

 

 

 

 

 

 

2.  Mirror with coturn source , here to ubuntu16.04 LTS 64 bit Case

Enter the apt-get install coturn

 

 

 

 

 

Third, the configuration and operation

stun server and turn the server's default port is 3478 .

stun server requires a server, and the server bindings have 2 public network IP ( if there is only 1 public network IP , will appear NAT type detection inaccurate! ).

turn server needs a server, and the server has bound . 1 public network the IP .

stun server set up:

stun server needs a server, and the server has bound 2 public network the IP .

High performance requirements should not, after all, a user creates a call request, and need only stun communication server once, then no communication, the communication time only needs to send several packets verify whether communication.

 

There are 2 kinds of solutions program:

1. The use someone else ready-made stun server (recommended)

2. he made himself a stun server ( 2 public network IP of spending too much money, but the result was just a NAT type detection functionality, cost is not high, not recommended)

 

1. The use someone else ready-made stun server

The following three test Available pro:

stun.ekiga.net

stun.schlund.de

stun.voxgratia.org

 

How to test whether it is available?

Search NAT type detection tool, then download

 

 

 

 

Find a few available server

 

 

 

 

 

Fill in the server address in the box

This is available

 

 

 

 

 

 

This is not take

 

 

 

 

 

 

2. made himself a stun server

Hardware, Tencent cloud and a man named Ali cloud elasticity card technology allows a server To bind a two Ge ip , if the server only 1 Ge IP , will appear NAT type detection inaccurate!

 

Software, server installed coturn after both stun server, but also turn the server, so stun configuration steps with the server turn configuration steps are the same server .

 

 

turn the server set up:

coturn supports three configurations: the command line, conf files and databases (according to the Internet that there is a database in this way, but all the examples are the first two, so I do not know how to use database configuration).

 

Database supports SQLite , MySQL , PostgreSQL , MongoDB , Redis . Here refers to the database should be stored user information database, instead of configuring coturn database used.

 

STUN defines two authentication: Long-Term the Credential  and  Short-Term the Credential  . But for WebRTC , the only support for Long-Term Credential  .

 

 

 

 

Example herein command line:

turnserver -o -v -f -a -m 2 --max-bps=100000 --min-port=32355 --max-port=65535 --user=phz:1 -r phzled.cn -L your.ip

 

 

 

 

Section Parameter Description:

-o in daemon mode (running in the background)

-v log will be "moderately detailed" level to record

-f   increase fingerprint mechanism.

-a long-term authentication mechanism

-m to x a process to handle the request relaying

--max-bps of bandwidth

--min-port    smallest port starting with

--max-port   maximum number of ports

--user = Name: Password

-r   field (just write and consequently the line). If you turn the server does not use any database / command line / conf file configuration, you need to add this option, and to tie Long-Term Credentials ( -a option) Use

-L monitor IP (turn the server ip) this ip is your ifconfig found in ip , not your public network ip

 

 

 

Note : Turn server is the need for user authentication mechanisms, from the account, password, domain constitute a complete account of three parts.

Figure fancy, if you want to use in your code turn the server, you need to enter the correct account and password, it can be used normally turn the server, and the field is to turn the server to use, does not require input.

So, if you want to command line configuration turn server, --user -r -a three options is essential .

 

If you want to know more details, please refer to the instructions on their own wiki:

https://github.com/coturn/coturn/wiki

 

Or use the man page View:

man turnserver

 

After running the command line will have the following information, a lot of information, most less than, remember log location information of the file just fine , usually placed under / var / log, in order to turn + date + number naming process.

 

 

 

 

Fourth, run the test

URL detection

https://webrtc.github.io/samples/src/content/peerconnection/trickle-ice/

 

 

If you want to test stun server, only fill out your public IP

 

 

 

If you want to detect turn server, fill out your public IP, as well as the time to fill in when configuring a user name and password, as is the need to turn certified, (- fill in the information user option)

 

 

 

 

Fill out the relevant information, click the button, verify

 

 

 

 

If you want to set to boot from the start

Write a script that will copy your script to the  /etc/init.d directory

This is the beginning of the script to add a few lines

 

 

### BEGIN INIT INFO

# Provides:          scriptname

# Required-Start:    $remote_fs $syslog

# Required-Stop:     $remote_fs $syslog

# Default-Start:     2 3 4 5

# Default-Stop:      0 1 6

# Short-Description: Start daemon at boot time

# Description:       Enable service provided by daemon.

### END INIT INFO

 

 

like this

 

 

 

 

Then set permissions script file ( here assuming that the script name for the Test )

sudo chmod 755 /etc/init.d/test

 

Set the script startup script

sudo update-rc.d test defaults 95

Note: where the number 95 is a script to start the sequence number, according to their needs can be modified accordingly. In you have multiple startup script, but when there are dependencies between them has started you will know the specific role of this figure.

 

Uninstall startup script:

sudo update-rc.d -f test remove

Fifth, Q links

 

Q1:

After successfully running my server is not detected on the web site of detection.

 

A1:

You can see if it is because of this two reasons:

ip address 1.-L option fill is found ifconfig ip address

 

 

 

 

 

 

2. Check the server's security policy, if it is Tencent Ali clouds or clouds, look at whether the open port security group

stun server and turn the default server port is 3478 .

 

Tencent cloud, for example, to open port

 

Guess you like

Origin www.cnblogs.com/ledphz/p/11518755.html