Stun Module


Table of Contents

1. Admin Guide
1.1. Overview
1.1.1. The idea
1.1.2. Basic Operation
1.1.3. Supported STUN Attributes
1.2. Dependencies
1.2.1. OpenSIPS Modules
1.2.2. External Libraries or Applications
1.3. Exported Parameters
1.3.1. primary_ip (str)
1.3.2. primary_port (str)
1.3.3. alternate_ip (str)
1.3.4. alternate_port (str)
1.4. Exported MI Functions
2. Contributors
2.1. By Commit Statistics
2.2. By Commit Activity
3. Documentation
3.1. Contributors

List of Tables

2.1. Top contributors by DevScore(1), authored commits(2) and lines added/removed(3)
2.2. Most recently active contributors(1) to this module

List of Examples

1.1. Set primary_ip parameter
1.2. Set primary_port parameter
1.3. Set alternate_ip parameter
1.4. Set alternate_port parameter

Chapter1.Admin Guide

1.1.Overview

1.1.1. The idea

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 server may also advertise different network addresses than the ones it is actually listening on.

1.1.2. Basic Operation

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.

1.1.3. Supported STUN Attributes

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

1.2.Dependencies

1.2.1.OpenSIPS Modules

The following modules must be loaded before this module:

None.

1.2.2.External Libraries or Applications

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

  • None.

1.3.Exported Parameters

1.3.1. primary_ip (str)

The IP of an interface which is configured as an UDP SIP listener in OpenSIPS. This is a mandatory parameter.

Syntax: "ip [/ advertised_ip]

By default, the primary_ip and the advertised primary_ip will be identical. This may be changed with an optional "/ xxx.xxx.xxx.xxx" string.

Example1.1.Set primary_ip parameter

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

# Example of a STUN server within OpenSIPS which is behind NAT
modparam("stun", "primary_ip", "192.168.0.100 / 64.50.46.78")
...
				

1.3.2. primary_port (str)

The port configured (together with the primary_ip) as an UDP SIP listener in OpenSIPS. The default value is 5060.

Syntax: "port [/ advertised_port]

By default, the primary_port and the advertised primary_port will be identical. This may be changed with an optional "/ adv_port" string.

Example1.2.Set primary_port parameter

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

# Listening on a primary port, but advertising a different one
modparam("stun", "primary_port", "5060 / 5062")
...
				

1.3.3. alternate_ip (str)

Another IP from another interface. This is a mandatory parameter.

Syntax: "ip [/ advertised_ip]

By default, the alternate_ip and the advertised alternate_ip will be identical. This may be changed with an optional "/ xxx.xxx.xxx.xxx" string.

Example1.3.Set alternate_ip parameter

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

# Example of a STUN server within OpenSIPS which is behind NAT
modparam("stun", "alternate_ip", "192.168.0.100 / 64.78.46.50")
...
				

1.3.4. alternate_port (str)

The port used by the STUN server for the second interface. The default value is 3478 (default STUN port).

Syntax: "port [/ advertised_port]

By default, the alternate_port and the advertised alternate_port will be identical. This may be changed with an optional "/ adv_port" string.

Example1.4.Set alternate_port parameter

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

# Listening on an alternate port, but advertising a different one
modparam("stun", "alternate_port", "5060 / 5062")
...
				

1.4.Exported MI Functions

Chapter2.Contributors

2.1.By Commit Statistics

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

NameDevScoreCommitsLines ++Lines --
1. Razvan Pistolea193189119
2. Bogdan-Andrei Iancu (@bogdan-iancu)1813136128
3. Liviu Chircu (@liviuchircu)139254104
4. Razvan Crainea (@razvancrainea)861310
5. Vlad Paiu (@vladpaiu)64214

(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. Regarding imported patches/code, we do our best to count the work on behalf of the proper owner, as per the "fix_authors" and "mod_renames" arrays in opensips/doc/build-contrib.sh. If you identify any patches/commits which do not get properly attributed to you, please submit a pull request which extends "fix_authors" and/or "mod_renames".

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

2.2.By Commit Activity

Table2.2.Most recently active contributors(1) to this module

NameCommit Activity
1. Bogdan-Andrei Iancu (@bogdan-iancu)Sep 2009 - Jun 2018
2. Liviu Chircu (@liviuchircu)Mar 2014 - Jun 2018
3. Razvan Crainea (@razvancrainea)Oct 2011 - Feb 2016
4. Vlad Paiu (@vladpaiu)Sep 2011 - Mar 2015
5. Razvan PistoleaSep 2009 - Sep 2009

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

Chapter3.Documentation

3.1.Contributors

Last edited by: Bogdan-Andrei Iancu (@bogdan-iancu), Liviu Chircu (@liviuchircu), Razvan Pistolea.

doc copyrights:

Copyright 2009 Voice Sistem SRL