Skip to content

STUN module

A stun server working with the same port as SIP (5060) in order to gain accurate information. The benefit would be an exact external address in the case of NATs translating differently when given different destination ports.

The stun server will use 4 sockets:

  • socket1 = ip1 : port1
  • socket2 = ip1 : port2
  • socket3 = ip2 : port1
  • socket4 = ip2 : port2

The sockets come from existing SIP sockets or are created.

Socket1 must allways be a SIP UDP listener from OpenSIPS.

The server will create a separate process. This process will listen for data on created sockets. The server will register a callback function to SIP. This function is called when a specific (stun)header is found.

This stun implements RFC3489 (and XOR_MAPPED_ADDRESS from RFC5389)

  • MAPPED_ADDRESS
  • RESPONSE_ADDRESS
  • CHANGE_REQUEST
  • SOURCE_ADDRESS
  • CHANGED_ADDRESS
  • ERROR_CODE
  • UNKNOWN_ATTRIBUTES
  • REFLECTED_FROM
  • XOR_MAPPED_ADDRESS

Not supported attributes:

  • USERNAME
  • PASSWORD
  • MESSAGE_INTEGRITY

and associated ERROR_CODEs

The following modules must be loaded before this module:

None.

The following libraries or applications must be installed before running OpenSIPS with this module loaded:

  • None.

The ip of the an interface configured as UDP SIP listener in OpenSIPS. It is a mandatory paramter, by default empty.

Set primary_ip parameter
...
modparam("stun","primary_ip","192.168.0.100")
...

The port configured (together with the primary_ip) as an UDP SIP listener in OpenSIPS. It is a mandatory paramter, by default 5060.

Set primary_port parameter
...
modparam("stun","primary_port","5060")
...

Another ip from another interface. It is mandatory to be set, default is empty (not set).

Set alternate_ip parameter
...
modparam("stun","alternate_ip","11.22.33.44")
...

Another port used by STUN. It is mandatory to be set, default value is 3478 (default STUN port).

Set alternate_port parameter
...
modparam("stun","alternate_port","3479")
...

Top contributors by DevScore(1), authored commits(2) and lines added/removed(3)

#NameDevScoreCommitsLines++Lines—
1.Razvan Pistolea203189119
2.Bogdan-Andrei Iancu (@bogdan-iancu)168269256
3.Stefan Darius (@dariusstefan)6317916
4.Vlad Paiu (@vladpaiu)53257
5.Razvan Crainea (@razvancrainea)3122

(1) DevScore = author_commits + author_lines_added / (project_lines_added / project_commits) + author_lines_deleted / (project_lines_deleted / project_commits)

(2) including any documentation-related commits, excluding merge commits

(3) ignoring whitespace edits, renamed files and auto-generated files

#NameCommit Activity
1.Stefan Darius (@dariusstefan)Jun 2026 - Jul 2026
2.Razvan Crainea (@razvancrainea)Jun 2026 - Jun 2026
3.Bogdan-Andrei Iancu (@bogdan-iancu)Sep 2009 - Jan 2013
4.Vlad Paiu (@vladpaiu)Sep 2011 - Apr 2012
5.Razvan PistoleaSep 2009 - Sep 2009

(1) including any documentation-related commits, excluding merge commits

Last edited by: Razvan Crainea (@razvancrainea), Bogdan-Andrei Iancu (@bogdan-iancu), Razvan Pistolea.

All documentation files (i.e. .md extension) are licensed under the Creative Common License 4.0