Opensips user authentication configuration file-opensips. cfg opensips. cfg configuration file, marked in red as the added and modified part. Test it in person!
#
# $ Id: opensips. cfg 9742 2013-02-05 10: 24: 48Z vladut-paiu $
#
# OpenSIPS residential configuration script
# By OpenSIPS Solutions <team@opensips-solutions.com>
#
# This script was generated via "make menuconfig", from
# The "Residential" scenario.
# You can enable/disable more features/functionalities
# Re-generating the scenario with different options .#
#
# Please refer to the Core CookBook:
# Http://www.opensips.org/Resources/DocsCookbooks
# For a explanation of possible statements, functions and parameters.
#
####### Global Parameters #########
Debug = 3
Log_stderror = no
Log_facility = LOG_LOCAL0
Fork = yes
Children = 4
/* Uncomment the following lines to enable debugging */
# Debug = 6
# Fork = no
# Log_stderror = yes
/* Uncomment the next line to enable the auto temporary blacklisting
Not available destinations (default disabled )*/
# Disable_dns_blacklist = no
/* Uncomment the next line to enable IPv6 lookup after IPv4 dns
Lookup failures (default disabled )*/
# Dns_try_ipv6 = yes
/* Comment the next line to enable the auto discovery of local aliases
Based on revers DNS on IPs */
Auto_aliases = no
# Listen = udp: 127.0.0.1: 5060 # CUSTOMIZE ME
Listen = udp: 192.168.139.121: 5060 # CUSTOMIZE ME
Disable_tcp = yes
# Disable_tls = yes
####### Modules Section ########
# Set module path
Mpath = "// lib/opensips/modules /"
#### MySQL
Loadmodule "db_mysql.so"
#### SIGNALING module
Loadmodule "signaling. so"
#### StateLess module
Loadmodule "sl. so"
#### Transaction Module
Loadmodule "tm. so"
Modparam ("tm", "fr_timer", 5)
Modparam ("tm", "fr_inv_timer", 30)
Modparam ("tm", "restart_fr_on_each_reply", 0)
Modparam ("tm", "onreply_avp_mode", 1)
#### Record Route Module
Loadmodule "rr. so"
/* Do not append from tag to the RR (no need for this script )*/
Modparam ("rr", "append_fromtag", 0)
#### MAX ForWarD module
Loadmodule "maxfwd. so"
#### Sip msg OPerationS module
Loadmodule "sipmsgops. so"
#### FIFO Management Interface
Loadmodule "mi_polico.so"
Modparam ("mi_fifo", "kerbero_name", "/tmp/opensips_fifo ")
Modparam ("mi_fifo", "kerbero_mode", 0666)
#### URI module
Loadmodule "uri. so"
Modparam ("uri", "use_uri_table", 0)
#### USeR LOCation module
Loadmodule "usrloc. so"
Modparam ("usrloc", "nat_bflag", "NAT ")
Modparam ("usrloc", "db_url", "mysql: // opensips: opensipsrw @ localhost/opensips ")
Modparam ("usrloc", "db_mode", 2)
#### REGISTRAR module
Loadmodule "registrar. so"
Modparam ("registrar", "tcp_persistent_flag", "TCP_PERSISTENT ")
/* Uncomment the next line not to allow more than 10 contacts per AOR */
# Modparam ("registrar", "max_contacts", 10)
#### ACCounting module
Loadmodule "acc. so"
/* What special events shocould be accounted? */
Modparam ("acc", "early_media", 0)
Modparam ("acc", "report_cancels", 0)
/* By default we do not adjust the direct of the sequential requests.
If you enable this parameter, be sure the enable "append_fromtag"
In "rr" module */
Modparam ("acc", "detect_direction", 0)
Modparam ("acc", "failed_transaction_flag", "ACC_FAILED ")
/* Account triggers (flags )*/
Modparam ("acc", "log_flag", "ACC_DO ")
Modparam ("acc", "log_missed_flag", "ACC_MISSED ")
#### Auth support
Loadmodule "auth. so"
Loadmodule "auth_db.so"
Modparam ("auth", "calculate_ha1", yes)
Modparam ("auth_db", "db_url", "mysql: // opensips: opensipsrw @ localhost/opensips ")
Modparam ("auth_db", "password_column", "password ")
####### Routing Logic ########
# Main request routing logic
Route {
If (! Mf_process_maxfwd_header ("10 ")){
Sl_send_reply ("483", "Too route Hops ");
Exit;
}
If (has_totag ()){
# Sequential request withing a dialog shold
# Take the path determined by record-routing
If (loose_route ()){
If (is_method ("BYE ")){
Setflag (ACC_DO); # do accounting...
Setflag (ACC_FAILED); #... even if the transaction fails
} Else if (is_method ("INVITE ")){
# Even if in most of the cases is useless, do RR
# Re-INVITEs alos, as some buggy clients do change route set
# During the dialog.
Record_route ();
}
# Route it out to whatever destination was set by loose_route ()
# In $ du (destination URI ).
Route (relay );
} Else {
If (is_method ("ACK ")){
If (t_check_trans ()){
# Non loose-route, but stateful ACK; must be an ACK after
# A 487 or e.g. 404 from upstream server
T_relay ();
Exit;
} Else {
# ACK without matching transaction->
# Ignore and discard
Exit;
}
}
Sl_send_reply ("404", "Not here ");
}
Exit;
}
# CANCEL processing
If (is_method ("CANCEL "))
{
If (t_check_trans ())
T_relay ();
Exit;
}
T_check_trans ();
If (! (Is_method ("REGISTER "))){
If (from_uri = myself)
{
} Else {
# If caller is not local, then called number must be local
If (! Uri = myself ){
Send_reply ("403", "Rely forbidden ");
Exit;
}
}
}
# Preloaded route checking
If (loose_route ()){
Xlog ("L_ERR ",
"Attempt to route with preloaded Route's [$ fu/$ tu/$ ru/$ ci]");
If (! Is_method ("ACK "))
Sl_send_reply ("403", "Preload Route denied ");
Exit;
}
# Record routing
If (! Is_method ("REGISTER | MESSAGE "))
Record_route ();
# Account only INVITEs
If (is_method ("INVITE ")){
Setflag (ACC_DO); # do accounting
}
If (! Uri = myself ){
Append_hf ("P-hint: outbound \ r \ n ");
Route (relay );
}
# Requests for my domain
If (is_method ("PUBLISH | SUBSCRIBE "))
{
Sl_send_reply ("503", "Service Unavailable ");
Exit;
}
If (is_method ("REGISTER "))
{
# Auth user using mysql DB
If (! Www_authorize ("192.168.139.121", "subscriber ")){
Www_challenge ("192.168.139.121", "0 ");
Exit;
}
# End auth user
If (0) setflag (TCP_PERSISTENT );
If (! Save ("location "))
Sl_reply_error ();
Exit;
}
If ($ rU = NULL ){
# Request with no Username in RURI
Sl_send_reply ("484", "Address Incomplete ");
Exit;
}
# Do lookup with method filtering
If (! Lookup ("location", "m ")){
T_newtran ();
T_reply ("404", "Not Found ");
Exit;
}
# When routing via usrloc, log the missed callalso
Setflag (ACC_MISSED );
Route (relay );
}
Route [relay] {
# For INVITEs enable some additional helper routes
If (is_method ("INVITE ")){
T_on_branch ("per_branch_ops ");
T_on_reply ("handle_nat ");
# T_on_reply ();
T_on_failure ("missed_call ");
}
If (! T_relay ()){
Send_reply ("500", "Internal Error ");
};
Exit;
}
Branch_route [per_branch_ops] {
Xlog ("new branch at $ ru \ n ");
}
Onreply_route [handle_nat] {
Xlog ("incoming reply \ n ");
}
Failure_route [missed_call] {
If (t_was_cancelled ()){
Exit;
}
# Uncomment the following lines if you want to block client
# Redirect based on 3xx replies.
# If (t_check_status ("3 [0-9] [0-9]") {
# T_reply ("404", "Not found ");
# Exit;
##}
}