ALIAS_DB module
Admin Guide
Section titled “Admin Guide”Overview
Section titled “Overview”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.
Dependencies
Section titled “Dependencies”OpenSIPS Modules
Section titled “OpenSIPS Modules”The following modules must be loaded before this module:
- database module (mysql, dbtext, …).
External Libraries or Applications
Section titled “External Libraries or Applications”The following libraries or applications must be installed before running OpenSIPS with this module loaded:
- None.
Exported Parameters
Section titled “Exported Parameters”db_url (str)
Section titled “db_url (str)”Database URL.
Default value is “mysql://opensipsro:opensipsro@localhost/opensips”.
...modparam("alias_db", "db_url", "dbdriver://username:password@dbhost/dbname")...user_column (str)
Section titled “user_column (str)”Name of the column storing username.
Default value is “username”.
...modparam("alias_db", "user_column", "susername")...domain_column (str)
Section titled “domain_column (str)”Name of the column storing user’s domain.
Default value is “domain”.
...modparam("alias_db", "domain_column", "sdomain")...alias_user_column (str)
Section titled “alias_user_column (str)”Name of the column storing alias username.
Default value is “alias_username”.
...modparam("alias_db", "alias_user_column", "auser")...alias_domain_column (str)
Section titled “alias_domain_column (str)”Name of the column storing alias domain.
Default value is “alias_domain”.
...modparam("alias_db", "alias_domain_column", "adomain")...domain_prefix (str)
Section titled “domain_prefix (str)”Specifies the prefix to be stripped from the domain in R-URI before doing the search.
Default value is “NULL”.
...modparam("alias_db", "domain_prefix", "sip.")...append_branches (int)
Section titled “append_branches (int)”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).
...modparam("alias_db", "append_branches", 1)...Exported Functions
Section titled “Exported Functions”alias_db_lookup( table_name [,flags] )
Section titled “alias_db_lookup( table_name [,flags] )”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 - the name of the table where to search for alias. It can include pseudo-variables.
- 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("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 - the name of the table where to search for alias. It can include pseudo-variables.
-
input - any PV (pseudo-variable) carrying the SIP URI that needs to be looked up.
-
ouput - 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, FAILURE_ROUTE and ONREPLY_ROUTE.
...# do revers alias lookup and find the alias for the FROM URIalias_db_find("dbaliases" , "$fu", "$avp(s:from_alias)", "r");...Frequently Asked Questions
Section titled “Frequently Asked Questions”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.
Contributors
Section titled “Contributors”By Commit Statistics
Section titled “By Commit Statistics”Top contributors by DevScore(1), authored commits(2) and lines added/removed(3)
| # | Name | DevScore | Commits | Lines++ | Lines— |
|---|---|---|---|---|---|
| 1. | Bogdan-Andrei Iancu (@bogdan-iancu) | 31 | 23 | 339 | 291 |
| 2. | Daniel-Constantin Mierla (@miconda) | 15 | 12 | 28 | 64 |
| 3. | Stefan Darius (@dariusstefan) | 8 | 4 | 328 | 50 |
| 4. | Elena-Ramona Modroiu | 7 | 3 | 142 | 89 |
| 5. | Henning Westerholt (@henningw) | 6 | 4 | 51 | 52 |
| 6. | Vladimir Romanov | 4 | 1 | 230 | 54 |
| 7. | Sergio Gutierrez | 3 | 1 | 4 | 4 |
| 8. | Konstantin Bokarius | 3 | 1 | 2 | 5 |
| 9. | Razvan Crainea (@razvancrainea) | 3 | 1 | 1 | 1 |
| 10. | Anca Vamanu | 3 | 1 | 1 | 1 |
All remaining contributors: 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
By Commit Activity
Section titled “By Commit Activity”| # | Name | Commit Activity |
|---|---|---|
| 1. | Stefan Darius (@dariusstefan) | Jun 2026 - Jul 2026 |
| 2. | Razvan Crainea (@razvancrainea) | Jun 2026 - Jun 2026 |
| 3. | Bogdan-Andrei Iancu (@bogdan-iancu) | Oct 2005 - Apr 2010 |
| 4. | Anca Vamanu | Sep 2009 - Sep 2009 |
| 5. | Vladimir Romanov | May 2009 - May 2009 |
| 6. | Sergio Gutierrez | Feb 2009 - Feb 2009 |
| 7. | Henning Westerholt (@henningw) | Dec 2007 - Jun 2008 |
| 8. | Elena-Ramona Modroiu | Oct 2005 - May 2008 |
| 9. | Daniel-Constantin Mierla (@miconda) | Jun 2005 - Mar 2008 |
| 10. | Konstantin Bokarius | Mar 2008 - Mar 2008 |
All remaining contributors: Edson Gellert Schubert.
(1) including any documentation-related commits, excluding merge commits
Documentation
Section titled “Documentation”Contributors
Section titled “Contributors”Last edited by: Razvan Crainea (@razvancrainea), Bogdan-Andrei Iancu (@bogdan-iancu), Sergio Gutierrez, Henning Westerholt (@henningw), Elena-Ramona Modroiu, Daniel-Constantin Mierla (@miconda), Konstantin Bokarius, Edson Gellert Schubert.
License
Section titled “License”All documentation files (i.e. .md extension) are licensed under the Creative Common License 4.0