Coturn Sets up the STUN/TURN server
Share experience summary, welcome to join
Wechat official account: He Xiao
Introduction to the
STUN, first defined in RFC3489, is a complete NAT Traversal solution (Simple Traversal of UDP Through NATs).
STUN (Simple Traversal of User Datagram Protocol Through Network Address Translators) is a lightweight Protocol that allows users to use UDP to penetrate NAT. Is based on UDP complete NAT penetration solution. It allows applications to discover NAT and firewall and other types that exist between them and the public Internet. It also allows applications to determine the public IP address and port number assigned to them by NAT. STUN is a Client/Server protocol and a Request/Response protocol. The default port number is 3478.
Traversal :Relay Extensions to Session Traversal Utilities for NAT That is, the extension of NAT:STUN using a relay. To put it simply, what TURN and STURN have in common is that NAT penetration is achieved by modifying private network addresses in the application layer. The difference is that TURN achieves NAT penetration through the “middle man” mode of communication between the two parties.
STUN was renamed Session Traversal Utilities for NAT in RFC5389. Here, NAT session penetration utility is positioned as a protocol for other protocols that address NAT penetration issues. It can be used by the terminal device to check the IP address and port number assigned to the terminal by the NAT. It is also used to check connectivity between two terminals, as a keepalive protocol to maintain NAT binding entries. STUN can be used with multiple NAT types without requiring them to provide special behavior.
STUN is no longer a complete NAT penetration solution in itself, but rather a tool within a NAT penetration solution. This is the most significant change from the RFC3489/STUN version.
Unlike STUN and TURN, ICE is not a protocol, but a Framework that integrates STUN and TURN.
Coturn structures,
Link: github.com/coturn/cotu…
After the code is pulled, install the required dependency packages first
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 gcc
sudo apt-get install pkg-config
Copy the code
Compile coturn
source ./configure
make -j 8
sudo make install
Copy the code
Installation Screenshot
Edit the configuration file after the installation is complete
Path: / usr/local/etc/turnserver. Conf. Default
Necessary configuration items. Other items can be viewed on Baidu
Listening-port =3478 # Specify the listening port external-ip=39.121.185.185 # Specify the public IP address of the cloud host user=aaaaaa: BBBBBB # Username and password for accessing the STUn /turn service Realm =stun.xxx.cn # domain name, cli-password=123456Copy the code
Enable port 3478
Turnserver start
Path: CD /usr/local/bin
turnserver -c .. /etc/turnserver.conf
Online tool to detect ICE penetration
Link: webrtc. Making. IO/samples/SRC…
The tests found that Firefox worked, but Google Chrome did not
Android end use
PeerConnection.IceServer iceServer = new PeerConnection.IceServer("Turn: 172.21.0.147:3478"."taxiao"."123456");
iceServers.add(iceServer);
PeerConnection.RTCConfiguration configuration = new PeerConnection.RTCConfiguration(iceServers);
Copy the code