Browsed by
Category: Howto

How to Install & Configure TURN Server (coTURN)

How to Install & Configure TURN Server (coTURN)

This blog page covers how to install and configure coTURN server for your SIP or WebRTC projects (like Jitsi Meet) to allow users behind restrictive firewalls or proxies to connect.

What is TURN?

TURN stands for Traversal Using Relays around NAT. Similar as STUN, it is a network protocol / packet format (IETF RFC 5766) used to assist in the discovery of paths between peers on the Internet. It differs from STUN in that it uses a public relay to transfer packets between peers. TURN is used to exchange media packets when no other option is available. So that it consumes server resources and has an increased latency due to the extra hop in peer to peer connection.

The time when you must use TURN is when one of the peers is behind a symmetric NAT and the other is behind either a symmetric NAT or port-restricted NAT. The frequency of cases where a relay is necessary is around %10 of the overall connections, since STUN is enough for most cases.

Install coTURN Server

Audio / Video based services requires a wide range of UDP ports to be available for WebRTC. In some network restricted sites, such as those behind NAT or a firewall that restricts outgoing UDP connections, users may be unable to make outgoing UDP connections to your media server.

TURN protocol is designed to allow UDP communication flows to bypass NAT or firewalls by forcing the client to connect to the TURN server, and then force TURN server to connect to the destination on their behalf.

Using a TURN server under your control improves the success of connections to your multimedia application and also improves user privacy, since it acts like a proxy so that peers will no longer be sending their IP address information to a public STUN server.

Required Hardware

TURN protocol is not really CPU or memory intensive. Additionally, since it’s only used during connection setup (for STUN) and as a fallback for users who would otherwise be unable to connect, the bandwidth requirements aren’t particularly high. For a moderate number of connections, a single small VPS configuration is usually enough. Here you can find my reccomendations to install coTURN:

  • At least two vCPUs
  • 4GB Memory.
  • 20GB HDD. SSD can be used, but not mandatory.
  • The most important thing is the networking performance.
    • Low jitter (less than 30ms)
    • Low latency (less than 150ms)
    • Enough bandwidth to handle relayed media streams in both directions.

Having the server behind NAT (like on Amazon EC2) is OK, but all incoming UDP and TCP connections on any port (TCP 80 & 443, UDP 3478, 10000-20000) must be forwarded to coTURN server and not firewalled.

Required Software

I recommend using a minimal server installation of Debian with netinst or Ubuntu. Since coTURN software uses port TCP 443, the server which coTURN will be installed cannot have any other web applications running.

coTURN is already available in the Debian and Ubuntu repositories and it can be installed with apt-get:

$ sudo apt-get update
$ sudo apt-get install coturn

Please note that coTURN will not start automatically until the configuration is finished. You can find the configuration tasks in below.

DNS Entry For coTURN

You need to setup a fully qualified domain name (FQDN) that resolves the external IP address of your coTURN server. You’ll use this domain name to generate a TLS certificate.

Generating TLS Certificates

You can use certbot to generate free TLS certificates from Let’s Encrypt. To setup certbot, enter the following commands on your coTURN server:

$ sudo add-apt-repository ppa:certbot/certbot
$ sudo apt-get update
$ sudo apt-get install certbot

Note: If you face with add-apt-repository command not found error, please use sudo apt-get install software-properties-common command to install the necessary packets.

You can then run a certbot command like the following to generate the certificate, replacing turn.fatiherikci.com with the domain name of your TURN server:

$ sudo certbot certonly --standalone --preferred-challenges http \
    --deploy-hook "systemctl restart coturn" \
    -d turn.fatiherikci.com

Current versions of the certbot command set up automatic renewal by default. Note that when certbot renews the certificate, it will restart coTURN service, so coTURN will start to use the updated certificate files. This will cause an interruption on any ongoing TURN connections. You may change the certbot renewal schedule or disable automatic renewal if you like.

Configure coTURN

coTURN configuration is stored in /etc/turnserver.conf file. There are a lot of options and all of them are documented in comments in that file. I include a sample configuration below with comments as the recommended settings, also with notes in places where customization is needed.

You can replace the contents /etc/turnserver.conf with the file below and make these changes:

  • Replace turn.fatiherikci.com with the hostname of your TURN server
  • Change the values in bold with your choices.

You can see an example config file below:

server-name=turn.fatiherikci.com
realm=turn.fatiherikci.com
cert=/etc/letsencrypt/live/turn.fatiherikci.com/cert.pem
pkey=/etc/letsencrypt/live/turn.fatiherikci.com/privkey.pem
fingerprint 
listening-ip=0.0.0.0 
external-ip= 1.2.3.4/192.168.0.1 #or just write the external ip 
listening-port=3478 
min-port=10000 
max-port=20000 
log-file=/var/log/turnserver.log 
verbose 
user=myusername:mypassword 
lt-cred-mech

You can now start the COTURN service with this command:

$ systemctl start coturn

Running coTURN as a Service

The Debian / Ubuntu package for coTURN requires that you edit a file to enable at startup. Edit /etc/default/coturn file and uncomment the following line:

TURNSERVER_ENABLED=1

That’s it! coTURN install is complete. Now you have an up and runnning TURN server!

Testing Your TURN Server

To test your coTURN server, you can use Trickle-Ice testing tool. Go to trickle-ice webpage and enter following:

STUN or TURN URI : turn:Your Public IP Address:3478
TURN username: Username
TURN password: Password

Then click Add Server button and then click Gather Candidates button. If everything works well, you should see Done as final result.

What is ENUM? ENUM Syntax

What is ENUM? ENUM Syntax

ENUM (Telephone Number Mapping, E.164 Number to URI Mapping) is an addressing protocol that converts telephone numbers to URI format (name@domain). This allows you to access a SIP, H.323 or other Internet phone user by dialing a phone number.

The ENUM function aims to ensure that users can be accessed anywhere in the world with the same number, best quality and the cheapest way. ENUM maps a phone number to an Internet address in the DNS system. Thus, a user with an ENUM number can broadcast the DNS record to which the call will be routed. Even different routes can be defined for different types of calls (fax, video, etc.).

It is possible to obtain an ENUM record as if it were a domain name. Nowadays, you can obtain this registration free of charge through many registration services and VoIP service providers.

ENUM Syntax

ENUM allows normal phone (E.164) numbers to be displayed as DNS names ending in e164.arpa. A number can be decoded for one or more predefined services.

For example, a telephone number + 90-312-555-1234 will be displayed as 4.3.2.1.5.5.5.2.1.3.0.9.e164.arpa after issuing rules defined in RFC 3761 and below:

  1. All characters except digits are removed. (“+90-312-555-1234” becomes “903125551234″)
  2. A period (“.”) Is placed between each number. (“9.0.3.1.2.5.5.5.1.2.3.4”)
  3. The order of the numbers is reversed. (“4.3.2.1.5.5.5.2.1.3.0.9”)
  4. .e164.arpa is added to the end of the array. (“4.3.2.1.5.5.5.2.1.3.0.9.arp a”)

To respond to this syntax, the DNS server must have a record that looks like this:

$ ORIGIN 4.3.2.1.5.5.5.2.1.3.0.9.barley.
   NAPTR 10 100 "u" "E2U + sip" "! ^. * $! Sip: fatih.erikci@fatiherikci.com!" .
   NAPTR 10 101 & quot; u & quot; & quot; E2U + h323 & quot; .
   NAPTR 10 102 "u" "E2U + msg" "! ^. * $! Mailto: fatih.erikci@fatiherikci.com!" .

In this record you see three different routing sequences for the address 4.3.2.1.5.5.5.2.1.3.0.9. The first is SIP, the second is H.323 and the third is the SMTP response. Device selects which service to communicate by using these records.

How It Works?

The operating principle of ENUM is similar to the DNS queries we use on the Internet. DNS NAPTR resource records are used in queries.

ENUM Query and Call
ENUM Query and Call
  1. The phone calls an E.164 number (+90-312-555-1234)
  2. Gateway translates it (4.3.2.1.5.5.5.2.1.3.0.9.e164.arpa) and asks the DNS server.
  3. The DNS server responds to this query with a URI (sip: fatih.erikci@fatiherikci.com).
  4. The gateway sends the call to the SIP server as a SIP URI call.
  5. The SIP server rings the IP phone registered with the URI.
How to Install Jitsi Meet on Debian 10

How to Install Jitsi Meet on Debian 10

Jitsi Meet is a very usable and simple WebRTC based open-source multi-platform video conferencing solution. It can be even cloud based solution or you can install it on your premises. In this blog post, I will explain how to install Jitsi server on your Debian or Ubuntu based linux platform.

Before starting, if you are curious about the video calling experience, just click this URL and go to my video call page powered by meet.jit.si.

Installing Jitsi Meet is very easy if you want to install it on Ubuntu or Debian linux platform. In this guide you can find how to install Jitsi Meet on Debian 10 by using .deb packages.

I prefer installing Debian from net installer package (netinst), since it is a minimal installation with up-to-date packages. I assume that you can install a Debian linux and I will continue from that point.

First, let’s install base packages like sudo & ssh, so set that up first. Log in from console as root, then install the necessary packets.

apt-get install -y ssh sudo ufw apt-transport-https

Add your non-root user (mine is ferikci) to /etc/sudoers file.

 ferikci  ALL=(ALL:ALL) ALL 

Now you can continue with your user by using sudo commands.

(Optional) Enable UFW firewall and open the needed ports:

ufw allow in ssh
ufw allow in http
ufw allow in https
ufw allow in 10000:20000/udp
ufw enable

I have to warn you that if you are connected to your linux machine via SSH, enter “ufw enable” command after entering “ufw allow in ssh” command, otherwise you may lose your current SSH connection.

Now re-login with your non-root user via SSH for the rest of the setup.

Add the Jitsi GPG key.

wget -qO - https://download.jitsi.org/jitsi-key.gpg.key | sudo apt-key add -

Add the Jitsi repository and update apt

sudo sh -c "echo 'deb https://download.jitsi.org stable/' > /etc/apt/sources.list.d/jitsi-stable.list"
sudo apt-get -y update

Install Jitsi-Meet

Now you’re ready for Jitsi server installation. Use the command below to install jitsi-meet with dependencies:

sudo apt-get -y install jitsi-meet

You will be asked your hostname but do not only write your hostname, you MUST write as FQDN, otherwise you will encounter with problems. By the way, be sure that the FQDN can be addressable with your DNS server (Or you can insert the FQDN to your host file.).

Jitsi Hostname Configuration

After that you will be asked for certificate. In this installation I will use self-signed SSL certificate, so select the first option.

Jitsi SSL Certificate Configuration Menu

The installation will be completed after a while and it will put you to the command prompt. Reboot your linux machine:

sudo reboot

Now it’s time to connect to your video conference GUI. Use https://FQDN to go to the main page of Jitsi server:

https://jitsi.test.local

You will see a greeting page with a room name input field. Just enter a room name and click Go button.

Jitsi Meet Greeting Page

That’s it! You can add more participants with the same procedure or by using URL https://FQDN/roomname

https://jitsi.test.local/testroom
Finally Jitsi Meet is Alive!

Running Jitsi Meet Behind a NAT

If you wish to use your Jitsi server behind a NAT, you must configure your router to forward the following ports to your Jitsi Meet server:

  • 80/TCP
  • 443/TCP
  • 10000-20000/UDP

Next you have to add following lines to /etc/jitsi/videobridge/sip-communicator.properties file:

org.ice4j.ice.harvest.NAT_HARVESTER_LOCAL_ADDRESS=[INTERNAL.IP.ADDRESS]
org.ice4j.ice.harvest.NAT_HARVESTER_PUBLIC_ADDRESS=[PUBLIC.IP.ADDRESS]

For example, here is my configuration:

org.ice4j.ice.harvest.NAT_HARVESTER_LOCAL_ADDRESS=192.168.1.20
org.ice4j.ice.harvest.NAT_HARVESTER_PUBLIC_ADDRESS=95.9.74.32
CUCM Common Partition – How to Clean?

CUCM Common Partition – How to Clean?

Sometimes when you go through RTMT logs on a Cisco Unified Communicatios Manager (CUCM), you can see a critical warning of “LogPartitionLowWaterMarkExceeded“. This happens when free space in CUCM common partition becomes low.

In most cases this problem doesn’t affect the whole system to function, but the low space on disk may cause problems if you want to do some installation (eg. device pack) or upgrades.

CUCM common partition is also called as log partition and is mostly filled with CDRs, CUCM traces and phone firmware files from TFTP server. LogPartitionLowWaterMarkExceeded alarm is occured when the log partition disk space percentage reaches the “Low WaterMark” treshold. You can take this alarm as an early notification to clean up the disk space. CUCM doesn’t have such kind of automated cleanup process until the “High WaterMark” value is reached.

What Should I Do To Clean CUCM Common Partition?

To clean up and free some space in the common partition, you can do the following:

  • Change the threshold values of LogPartitionLowWaterMarkExceeded to 50% and LogPartitionHighWaterMarkExceeded to 60%, and then restart “Cisco Log Partition Monitoring Tool” service and after couple of hours you should see that the used space is decreased.
  • Delete unused log by using RTMT Trace/Log Central to collect logs/traces with “Delete Collected Log Files from Server” option.(this is for both active and inactive partitions). Select relateive range as 8-9 years to delete all unused logs.
  • Delete the old unused phone firmware files from the TFTP server.
  • Use CUCM script called ciscocm.free_common_space_v1.1.cop.sgn (you can find & download it in cisco.com) that deletes all files from the inactive common partition. But please be informed that after using this script, you won’t be able to switch to previous CUCM version.

If you want to reduce the CUCM common partition usage, you can do the following:

  • Deactivate Detail/Debug trace level.
  • Reduce the number of trace files to be stored.
  • For CDR: reduce the High Water Mark, reduce the occupied disk space, and reduce the number of days to store CDRs.

Taking a Screenshot of a Cisco IP Phone

Taking a Screenshot of a Cisco IP Phone

The screen capture function which is available on Cisco IP Phone models can be very useful, especially in some situations that require remote support. In the following article, you can find the procedure for taking screenshots for Cisco 7800 and 8800 series IP phones.

First, let’s verify some settings on Cisco Unified Communications Manager (CUCM).

CUCM Settings

In order to take a screenshot of a Cisco IP phone, the phone first must be paired with a CUCM user (End User) and web access must be enabled in the phone settings page. You can make these settings from the CUCM Administration page using the Device -> Phone menu and selecting the corresponding phone.

First you need to open the web interface of the phone. To do so, enable Web Access in the Product Specific Configuration Layout section.

Cisco IP Phone Web Access Settings

Then we need to pair the IP phone with an end user. Select the end user in Owner User ID section on the same settings page.

Pairing End User With Cisco IP Phone

After selecting the end user, select the relevant user from the User Management -> End User menu and ensure that the corresponding phone is added in the Controlled Devices field of Device Information section.

User – IP Phone Matching under End User Settings

After applying these settings, go to System -> Enterprise Parameters menu and check the user authentication URLs that the phone will use when accessing the web interface. Related settings can be found in the Phone URL Parameters and Secure Phone URL Parameters.

Service Authentication URL Settings in Enterprise Parameters

Authentication on IP phones uses the URL format below:

http(s)://cucmcip/authenticate.jsp?UserID=<id>&Password=<password>&devicename=<nameofthedevice>

If the information entered is appropriate, browser displays a simple AUTHORIZED message, and if there is inconsistency in the information, UN-AUTHORIZED message is displayed. Below is a sample URL and its output:

You Can Check Your CUCM End User & Password This Way

Tip: If you want to by-pass authentication on IP phones, you can redirect the Authentication URLs under Enterprise Parameters to a webpage that will always respond as “AUTHORIZED” 🙂

Taking a Screenshot of a Cisco IP Phone From a Web Browser

If you have done all of the above steps properly, you can now take a screenshot of your IP phone. To do so, you can use the following URL:

 http://cucmip/CGI/Screenshot 

After entering the username and password, you will see an image like the following:

Cisco 7821 IP Phone Screenshot Tkane From a Web Browser

Troubleshooting

If you get an error message like this in your web browser:

 <CiscoIPPhoneError Number=”4” /> 

This problem is probably related to authentication. Verify that the IP phone is in control of an end user and that the user’s credentials are correct. To see this easily, you can test and adapt the above authentication URL format to your phone. If the URL works but the phone’s web page still shows the same error, reset the phone and try again.

 <CiscoIPPhoneError Number=”0” /> 

This error indicates that the phone cannot connect to the URL provided in CUCM for authentication. There can be many things that can cause this issue, and almost all of them are about the accessibility. Please check the settings like routing from IP telephones to CUCM (or authentication server), DNS etc.