stun/turn example

1. Install stunserver on CentOS/Ubuntu
yum -y install gcc
yum -y install make
yum -y install boost* # For Boost
yum -y install openssl* # For OpenSSL
wget  http://www.stunprotocol.org/stunserver-1.2.3.tgz
tar zxvf stunserver-1.2.3.tgz
cd stunserver
make

apt-get install g++  
apt-get install make  
apt-get install libboost-dev # For Boost  
apt-get install libssl-dev # For OpenSSL  
wget http://www.stunprotocol.org/stunserver-1.2.13.tgz
tar -zxvf stunserver-1.2.13.tgz
make

./stunserver
netstat -ap | grep 3478
udp        0      0 *:3478                  *:*                                 3658/stunserver
sudo ./stunclient 127.0.0.1 3478
Binding test: success  
Local address: 127.0.0.1:41348  
Mapped address: 127.0.0.1:41348

2. sipml5 ICE Servers:
[{url:'stun:8.134.18.182:3478'}]

3. Install coturn on CentOS/Ubuntu
sudo yum install coturn/sudo apt-get install coturn

systemctl stop coturn
systemctl start coturn

4. simple mode
turnserver -o -a -f -v --mobility -m 10 --max-bps=1024000 --min-port=16384 --max-port=32768 --user=test:test123 -r test --cert=/usr/local/nginx/conf/SSL_Pub.pem --pkey=/usr/local/nginx/conf/SSL_Priv.pem CA-file=/usr/local/nginx/conf/SSL_CA.pem

# stop
ps aux | grep turnserver
found process id,example:2059
kill 2059

5. custom config
cp /etc/coturn/turnserver.conf /etc/coturn/turnserver.conf.bak
vi /etc/coturn/turnserver.conf
```
### add by zhoudd 20201225

# Secure form for password 'qwerty':
cli-password=qwerty

# Specify the user for the TURN authentification
user=test:test123

# Further ports that are open for communication
min-port=16384
max-port=32768

# Enable verbose logging
verbose

# Use fingerprint in TURN message
fingerprint

# Enable long-term credential mechanism
lt-cred-mech
```

6. sipml5 ICE Servers:
[{url:'stun:8.134.18.182:3478'}]
[{url:'stun:8.134.18.182:3478'},{url:'turn:8.134.18.182:3478', username:'test', credential:'test123'}]

7. firewall open the port
sudo firewall-cmd --permanent --add-port=3478/tcp
sudo firewall-cmd --permanent --add-port=3478/udp
sudo firewall-cmd --permanent --add-port=5349/tcp
sudo firewall-cmd --permanent --add-port=5349/udp
sudo firewall-cmd --permanent --add-port=63000-64535/udp
sudo firewall-cmd --reload

8. Reference
1) How to set up and configure your own TURN server using Coturn
https://gabrieltanner.org/blog/turn-server
2) Configure Your Own TURN/STUN Server
https://www.red5pro.com/docs/server/webrtc/turnstun/#step-by-step-install-on-an-ubuntu-linux-server
3) ICE server set up in Ubuntu (Coturn)
https://www.codetd.com/en/article/6415507
4) Installation SSL certificates and Coturn for OpenMeetings 5.0.0-M4 on CentOS 7-8.pdf
5)WebRTC samples Trickle ICE

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

 

posted @ 2020-12-25 13:59  dong1  阅读(178)  评论(0编辑  收藏  举报