Opensips user Authentication profile-opensips.cfg opensips.cfg configuration file, red marked for adding modified parts, personally tested!
#
# $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 is generated via ' Make Menuconfig ', from
# the "residential" scenario.
# can enable/disable more features/functionalities by
# re-generating the scenario with different options.#
#
# Please refer to the Core cookbook at:
# 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 of
Not available destinations (default disabled) */
#disable_dns_blacklist =no
/* Uncomment the next line to enable IPV6 lookup IPv4 DNS
Lookup failures (default disabled) * *
#dns_try_ipv6 =yes
/* Comment The next line to enable the auto discovery of 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"
/* does 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_fifo.so"
Modparam ("Mi_fifo", "Fifo_name", "/tmp/opensips_fifo")
Modparam ("Mi_fifo", "Fifo_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 isn't to allow more than contacts per AOR * *
#modparam ("Registrar", "Max_contacts", 10)
# ACCounting Module
LoadModule "Acc.so"
/* What special events should be accounted? */
Modparam ("ACC", "Early_media", 0)
Modparam ("ACC", "Report_cancels", 0)
/* By default we did 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 Many hops");
Exit
}
if (Has_totag ()) {
# Sequential request withing a dialog should
# 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, does RR for
# re-invites Alos, as some buggy clients do change route set
# during the dialog.
Record_route ();
}
# route it out to whatever destination is 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 a 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 isn't local, then called number must being 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 and method filtering
if (!lookup ("Location", "M")) {
T_newtran ();
T_reply ("404", "not Found");
Exit
}
# when routing via Usrloc, log the missed calls Also
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 ("M", "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;
##}
}