$linuxjunkies
>

STUN

also: Session Traversal Utilities for NAT, RFC 5389

STUN (Session Traversal Utilities for NAT) is a network protocol that helps devices behind NAT firewalls discover their public IP address and establish peer-to-peer connections by detecting network topology.

STUN is a lightweight protocol (RFC 5389) used primarily in VoIP, video conferencing, and P2P applications to work around Network Address Translation (NAT) barriers. When a device is behind a NAT/firewall, it cannot directly communicate its public-facing IP address to remote peers—STUN solves this by having the device query a STUN server on the public internet.

A STUN client sends a request to a public STUN server, which responds with the client's public IP address and port as seen from the internet. This allows the client to advertise its real public endpoint to peer applications. For example, in a WebRTC video call, both participants use STUN to discover their public addresses so they can attempt direct peer-to-peer communication.

STUN is often used alongside TURN (Traversal Using Relays around NAT), which provides a fallback relay service when direct P2P connections fail. STUN is lightweight and stateless, making it efficient for NAT traversal in real-time communication scenarios.

Related terms