STUN, TURN, ICE: the Three Musketeers of SIP calling

There is a common misconception that the terms at the beginning of the title mean the same thing — much as SIP and VoIP, or dialers and softphones, often get lumped together. They do not: STUN, TURN, and ICE are different protocols that solve the same problem — getting devices behind firewalls and NAT (Network Address Translation) to communicate. Which protocol is the right one depends on your network configuration, security requirements, and other factors.

Let’s take a quick look at each one.

STUN

STUN (Session Traversal Utilities for NAT) is a client-server protocol that allows applications to detect the presence and type of firewalls and NAT. STUN clients send requests to a STUN server and receive the address they need to send voice packets to the other party.

STUN is described in detail in RFC 3489, RFC 8489, and RFC 5780. Here we’ll focus on the main point: essentially, STUN is a mechanism for determining the correct addresses for transmitting voice data when the endpoints are in different NAT-based networks. It can solve communication problems such as a softphone failing to register with the PBX, one-way audio, dropped calls, or missing incoming calls.

The STUN server must be outside the networks where the softphone and PBX are located, and that is not always possible. If either side is behind a symmetric NAT, STUN cannot be used. That’s where TURN steps in.

TURN

TURN (Traversal Using Relays around NAT; see RFC 8656 for a detailed description) helps devices communicate from behind a symmetric NAT by using an intermediary — a TURN server. In that sense, TURN complements STUN, and many servers support both STUN and TURN.

TURN addresses some of STUN’s limitations — for example, it makes communication through a symmetric NAT possible — but it still requires a connection to an external server. Because the data is relayed through that intermediary server, some additional latency is introduced.

To choose the best available path for the data, there is ICE.

ICE

ICE (Interactive Connectivity Establishment; described in RFC 8445, with its use in SIP covered in RFC 5768) complements STUN and TURN. Its main purpose is to determine the connection method automatically:

  • first, it tries to establish a direct connection between the devices;
  • if that fails, ICE tries to connect via STUN;
  • if that is not possible either, it uses TURN.

ICE has one obvious advantage: simplicity. Users do not have to dig into the intricacies of NAT configuration. The trade-off is that establishing the connection can take a little longer because ICE may need to check the available connection methods one by one.

Softphone, firewall, and DNS

By now, attentive readers probably have a few more questions. Do you need to configure your own STUN server to make calls through a softphone? If so, how do you configure STUN and ICE in Softphone.Pro? What about getting through the firewall? And which DNS records do you need?

You’ll find the answers in our comprehensive guide, STUN, TURN, and ICE in Softphone.Pro, in the Knowledge Base. It covers DNS, Linux, and setting up your own STUN server using Ubuntu Server 24.04 LTS as an example.

Enjoy!

YOU MAY ALSO LIKE

Help STUN, TURN, and ICE in Softphone.Pro

Blog VoIP choppy audio: how to quickly find records with stuttering and breaking up

Blog SIP vs VoIP, dialers vs softphones: differences and similarities

Blog Call me maybe… via “sip:”, “callto:”, and “tel:”

Blog How to continue receiving calls when the Android softphone app is in the background or closed


Last Articles