Skip to content

ALIAS_DB module

ALIAS_DB module can be used as an alternative for user aliases via usrloc. The main feature is that it does not store all adjacent data as for user location and always uses database for search (no memory caching).

Having no memory caching, search speed might decrease but provisioning is easier. With very fast databases like MySQL, speed penalty can be lowered. Also, search can be performed on different tables in the same script.

The following modules must be loaded before this module:

  • database module (mysql, dbtext, …).

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

  • None.

Database URL.

Default value is “mysql://opensipsro:opensipsro@localhost/opensips”.

Set db_url parameter
...
modparam("alias_db", "db_url", "dbdriver://username:password@dbhost/dbname")
...

Name of the column storing username.

Default value is “username”.

Set user_column parameter
...
modparam("alias_db", "user_column", "susername")
...

Name of the column storing user’s domain.

Default value is “domain”.

Set domain_column parameter
...
modparam("alias_db", "domain_column", "sdomain")
...

Name of the column storing alias username.

Default value is “alias_username”.

Set alias_user_column parameter
...
modparam("alias_db", "alias_user_column", "auser")
...

Name of the column storing alias domain.

Default value is “alias_domain”.

Set alias_domain_column parameter
...
modparam("alias_db", "alias_domain_column", "adomain")
...

Specifies the prefix to be stripped from the domain in R-URI before doing the search.

Default value is “NULL”.

Set domain_prefix parameter
...
modparam("alias_db", "domain_prefix", "sip.")
...

If the alias resolves to many SIP IDs, the first is replacing the R-URI, the rest are added as branches.

Default value is “0” (0 - don’t add branches; 1 - add branches).

Set append_branches parameter
...
modparam("alias_db", "append_branches", 1)
...

The function takes the R-URI and search to see whether it is an alias or not. If it is an alias for a local user, the R-URI is replaced with user’s SIP uri.

The function returns TRUE if R-URI is alias and it was replaced by user’s SIP uri.

Meaning of the parameters is as follows:

  • table_name - any PV (string or PV or mix) the name of the table where to search for alias.
  • flags (optional) - set of flags (char based flags) to control the alias lookup process:
    • d - do not use domain URI part in the alias lookup query (use only a username-based lookup). By default, both username and domain are used.
    • r - do revers alias lookup - lookup for the alias mapped to the current URI (URI 2 alias translation); normally, the function looks up for the URI mapped to the alias (alias 2 URI translation).

This function can be used from REQUEST_ROUTE, FAILURE_ROUTE.

alias_db_lookup() usage
...
alias_db_lookup("dbaliases" , "rd");
alias_db_lookup("dba_$(rU{s.substr,0,1})");
...

alias_db_find( table_name , input, output [,flags] )

Section titled “alias_db_find( table_name , input, output [,flags] )”

The function is very similar to alias_db_lookup(), but instead of using fixed input (RURI) and output (RURI) is able to get the input SIP URI from a pseudo-variable and place the result back also in a pseudo-variable.

The function is useful as the alias lookup does not affect the request itself (no RURI changes), can be used in a reply context (as it does not work with RURI only) and can be used for others URI than the RURI (To URI, From URI, custom URI).

The function returns TRUE if any alias mapping was found and returned.

Meaning of the parameters is as follows:

  • table_name - any PV (string or PV or mix) the name of the table where to search for alias.

  • input - any PV (string or PV or mix) carrying the SIP URI that needs to be looked up.

  • output - PV (AVP or script VAR) where to place the SIP URI resulting from the alias lookup.

  • flags (optional) - set of flags (char based flags) to control the alias lookup process:

    • d - do not use domain URI part in the alias lookup query (use only a username-based lookup). By default, both username and domain are used.
    • r - do revers alias lookup - lookup for the alias mapped to the current URI (URI 2 alias translation); normally, the function looks up for the URI mapped to the alias (alias 2 URI translation).

This function can be used from REQUEST_ROUTE, BRANCH_ROUTE, LOCAL_ROUTE, STARTUP_ROUTE, FAILURE_ROUTE and ONREPLY_ROUTE.

alias_db_find() usage
...
# do revers alias lookup and find the alias for the FROM URI
alias_db_find("dbaliases" , "$fu", "$avp(from_alias)", "r");
...

Q: What happened with old use_domain parameter

The global parameter (affecting the entire module) was replaced with a per lookup parameter (affecting only current lookup). See the “d” (do not used domain part) flag in the db_alias_lookup() and db_alias_find() functions.

Q: How can I report a bug?

Please follow the guidelines provided at: https://github.com/OpenSIPS/opensips/issues.

doc copyrights:

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

#NameDevScoreCommitsLines++Lines—
1.Bogdan-Andrei Iancu (@bogdan-iancu)3426339290
2.Daniel-Constantin Mierla (@miconda)15122864
3.Liviu Chircu (@liviuchircu)864255
4.Stefan Darius (@dariusstefan)8433150
5.Elena-Ramona Modroiu7314289
6.Henning Westerholt (@henningw)645152
7.Razvan Crainea (@razvancrainea)6488
8.Vladimir Romanov4123054
9.Sergey Khripchenko (@shripchenko)311822
10.Walter Doekes (@wdoekes)3155

All remaining contributors: Sergio Gutierrez, Konstantin Bokarius, Dusan Klinec (@ph4r05), Anca Vamanu, Edson Gellert Schubert.

(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 2011 - Jun 2026
3.Bogdan-Andrei Iancu (@bogdan-iancu)Oct 2005 - Jun 2018
4.Liviu Chircu (@liviuchircu)Mar 2014 - Jun 2018
5.Dusan Klinec (@ph4r05)Dec 2015 - Dec 2015
6.Sergey Khripchenko (@shripchenko)Sep 2015 - Sep 2015
7.Walter Doekes (@wdoekes)Apr 2010 - Apr 2010
8.Anca VamanuSep 2009 - Sep 2009
9.Vladimir RomanovMay 2009 - May 2009
10.Sergio GutierrezFeb 2009 - Feb 2009

All remaining contributors: Henning Westerholt (@henningw), Elena-Ramona Modroiu, Daniel-Constantin Mierla (@miconda), Konstantin Bokarius, Edson Gellert Schubert.

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

Last edited by: Razvan Crainea (@razvancrainea), Bogdan-Andrei Iancu (@bogdan-iancu), Liviu Chircu (@liviuchircu), Sergey Khripchenko (@shripchenko), Walter Doekes (@wdoekes), Sergio Gutierrez, Henning Westerholt (@henningw), Elena-Ramona Modroiu, Daniel-Constantin Mierla (@miconda), Konstantin Bokarius, Edson Gellert Schubert.

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