<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
<tt>Hi Kook,<br>
<br>
If you want to use multiple domains, then the domain info must be
consistent between registration and lookup - I mean users should
register and be searched inside the same domain (for each user).<br>
<br>
What domain do users A and B use for registering into OpenSIPS ?
Also what is the domain in RURI when looking up for user B in
OpenSIPS (for the call received from Asterisk) ?<br>
<br>
Regards,<br>
</tt>
<pre class="moz-signature" cols="72">Bogdan-Andrei Iancu
OpenSIPS Founder and Developer
<a class="moz-txt-link-freetext" href="http://www.opensips-solutions.com">http://www.opensips-solutions.com</a></pre>
<br>
On 08/29/2012 12:05 PM, Kook Maeng wrote:
<blockquote
cite="mid:CAA1B+P1mg=dO5EvjvxiN0iBotZbtNpUcE9fQZ+LZSyFTHLMvXg@mail.gmail.com"
type="cite">
<div>Hi, all.</div>
<div><br>
</div>
<div>My goal is to building scalable multi-domain(tenant)
telephone system using Opensips with multiple asterisk servers
that can be multi-domain.</div>
<div>But I ran into a problem during the progress.</div>
<div><br>
</div>
<div>Structure of the system for test is</div>
<div>Opensips(10.10.10.10) ------ Asterisk A(20.02.0.20), Asterisk
B(30.30.30.30)</div>
<div><br>
</div>
<div>My Opensips modules(auth_db, usrloc, uri) are enabled
"use_domain".</div>
<div>Below are flows for test.</div>
<div><br>
</div>
<div>Flow 1. Registrar</div>
<div>a : User A (<a moz-do-not-send="true"
href="mailto:1000@foo.com">1000@foo.com</a>)
-----register-----> OpenSIPS => 200 OK.</div>
<div>b : User B (<a moz-do-not-send="true"
href="mailto:2000@bar.com">2000@bar.com</a>)
-----register-----> OpenSIPS => 200 OK.</div>
<div><br>
</div>
<div>Flow 2. User A(<a moz-do-not-send="true"
href="mailto:1000@foo.com">1000@foo.com</a>) call User B(<a
moz-do-not-send="true" href="mailto:2000@bar.com">2000@bar.com</a>)</div>
<div>a : User A -----INVITE-----> OpenSIPS (via load_balancer)
-----INVITE-----> Asterisk A</div>
<div>b : Asterisk A -----Dial(SIP/${EXTEN}@OPENSIPS)----->
OpenSIPS => lookup("location) FAILED about <a
moz-do-not-send="true" href="mailto:2000@10.10.10.10">2000@10.10.10.10</a></div>
<div><br>
</div>
<div>If "usrloc.so" dont't use domain it works good. but otherwise
it fails.</div>
<div>I think the problem occurred because the lookup() find
contact using "userid@domain".</div>
<div><br>
</div>
<div>How can I fix this? I will append content of opensips.cfg
below.</div>
<div><br>
</div>
<div>Would really appreciate it if you can help.</div>
<div>Thanks in advance.</div>
<div><br>
</div>
<div>-Kook Maeng</div>
<div><br>
</div>
<div><br>
</div>
<div>----- opensip.cfg -----</div>
<div><br>
</div>
<div>####### Global Parameters #########</div>
<div><br>
</div>
<div>alias="14.63.222.202"</div>
<div>advertised_address="14.63.222.202"</div>
<div><br>
</div>
<div>#debug=3</div>
<div>#log_stderror=no</div>
<div>log_facility=LOG_LOCAL0</div>
<div><br>
</div>
<div>fork=yes</div>
<div>children=4</div>
<div><br>
</div>
<div>
port=5060</div>
<div>#listen=udp:211.62.253.136</div>
<div><br>
</div>
<div><br>
</div>
<div>####### Modules Section ########</div>
<div><br>
</div>
<div>#set module path</div>
<div>mpath="/usr/lib/opensips/modules/"</div>
<div><br>
</div>
<div>loadmodule "db_mysql.so"</div>
<div>loadmodule "signaling.so"</div>
<div>loadmodule "sl.so"</div>
<div>loadmodule "tm.so"</div>
<div>loadmodule "rr.so"</div>
<div>loadmodule "maxfwd.so"</div>
<div>loadmodule "usrloc.so"</div>
<div>loadmodule "registrar.so"</div>
<div>loadmodule "textops.so"</div>
<div>loadmodule "mi_fifo.so"</div>
<div>
loadmodule "uri.so"</div>
<div>loadmodule "acc.so"</div>
<div>loadmodule "auth.so"</div>
<div>loadmodule "auth_db.so"</div>
<div>loadmodule "alias_db.so"</div>
<div>loadmodule "domain.so"</div>
<div>loadmodule "permissions.so"</div>
<div>loadmodule "dialog.so"</div>
<div>loadmodule "load_balancer.so"</div>
<div>loadmodule "nathelper.so"</div>
<div>loadmodule "sipmsgops.so"</div>
<div>loadmodule "group.so"</div>
<div><br>
</div>
<div># ----------------- setting module-specific parameters
---------------</div>
<div><br>
</div>
<div># ----- mi_fifo params -----</div>
<div>modparam("mi_fifo", "fifo_name", "/tmp/opensips_fifo")</div>
<div><br>
</div>
<div># ----- rr params -----</div>
<div>modparam("rr", "append_fromtag", 0)</div>
<div><br>
</div>
<div># ----- registrar params -----</div>
<div>modparam("registrar", "max_expires", 60)</div>
<div>modparam("registrar", "min_expires", 60)</div>
<div><br>
</div>
<div># ----- usrloc params -----</div>
<div>modparam("usrloc", "db_mode", 2)</div>
<div>modparam("usrloc", "db_url",</div>
<div> "mysql://opensips:opensipsrw@localhost/opensips")</div>
<div>modparam("usrloc", "nat_bflag", 6)</div>
<div>modparam("usrloc", "use_domain", 1)</div>
<div>modparam("usrloc", "timer_interval", 30)</div>
<div><br>
</div>
<div># ----- uri params -----</div>
<div>modparam("uri", "use_uri_table", 0)</div>
<div>modparam("uri", "use_domain", 1)</div>
<div><br>
</div>
<div># ----- acc params -----</div>
<div>modparam("acc", "early_media", 1)</div>
<div>modparam("acc", "report_cancels", 1)</div>
<div>modparam("acc", "detect_direction", 0)</div>
<div>modparam("acc", "failed_transaction_flag", 3)</div>
<div>modparam("acc", "log_flag", 1)</div>
<div>modparam("acc", "log_missed_flag", 2)</div>
<div>modparam("acc", "db_flag", 1)</div>
<div>modparam("acc", "db_missed_flag", 2)</div>
<div><br>
</div>
<div># ----- auth_db params -----</div>
<div>modparam("auth_db", "calculate_ha1", 0)</div>
<div>#modparam("auth_db", "password_column", "password")</div>
<div>
modparam("auth_db", "db_url",</div>
<div> "mysql://opensips:opensipsrw@localhost/opensips")</div>
<div>modparam("auth_db", "load_credentials", "")</div>
<div>
modparam("auth_db", "use_domain", 1)</div>
<div><br>
</div>
<div># ----- alias_db params -----</div>
<div>modparam("alias_db", "db_url",</div>
<div> "mysql://opensips:opensipsrw@localhost/opensips")</div>
<div><br>
</div>
<div># ----- domain params -----</div>
<div>modparam("domain", "db_url",</div>
<div> "mysql://opensips:opensipsrw@localhost/opensips")</div>
<div>modparam("domain", "db_mode", 1) # Use caching</div>
<div><br>
</div>
<div># ----- multi-module params -----</div>
<div><br>
</div>
<div># ----- dialog params -----</div>
<div>modparam("dialog", "db_url",
"mysql://opensips:opensipsrw@localhost/opensips")</div>
<div>modparam("dialog", "db_mode", 1)</div>
<div>#modparam("dialog", "dlg_flag", 4)</div>
<div><br>
</div>
<div># ----- load_balancer params -----</div>
<div>modparam("load_balancer", "db_url",
"mysql://opensips:opensipsrw@localhost/opensips")</div>
<div><br>
</div>
<div># ----- nathelper params -----</div>
<div>modparam("registrar","received_avp", "$avp(i:42)")</div>
<div>modparam("nathelper","received_avp", "$avp(i:42)")</div>
<div><br>
</div>
<div># ----- permissions params -----</div>
<div>modparam("permissions", "db_url",
"mysql://opensips:opensipsrw@localhost/opensips")</div>
<div><br>
</div>
<div># ----- group params -----</div>
<div>modparam("group", "db_url",
"mysql://opensips:opensipsrw@localhost/opensips")</div>
<div>modparam("group", "use_domain", 1)</div>
<div><br>
</div>
<div><br>
</div>
<div><br>
</div>
<div>####### Routing Logic ########</div>
<div><br>
</div>
<div><br>
</div>
<div># main request routing logic</div>
<div><br>
</div>
<div>route{</div>
<div> if (!mf_process_maxfwd_header("10")) {</div>
<div> sl_send_reply("483","Too Many Hops");</div>
<div> exit;</div>
<div> }</div>
<div><br>
</div>
<div> #---- NAT Detection ----#</div>
<div> force_rport();</div>
<div> #if (nat_uac_test("19")) {</div>
<div> if (nat_uac_test("23")) {</div>
<div> if (is_method("REGISTER")) {</div>
<div> fix_nated_register();</div>
<div> } else {</div>
<div> fix_nated_contact();</div>
<div> }</div>
<div> setflag(5);</div>
<div> }</div>
<div><br>
</div>
<div> if (has_totag()) {</div>
<div> # sequential request withing a dialog should</div>
<div> # take the path determined by record-routing</div>
<div> if (loose_route()) {</div>
<div> if (is_method("BYE")) {</div>
<div> setflag(1); # do accounting
...</div>
<div> setflag(3); # ... even if the
transaction fails</div>
<div> } else if (is_method("INVITE")) {</div>
<div> # even if in most of the
cases is useless, do RR for</div>
<div> # re-INVITEs alos, as some
buggy clients do change route set</div>
<div> # during the dialog.</div>
<div><br>
</div>
<div> xlog("##################
HAS_TOTAG() INVITE => si: $si, sp: $sp
###################\n");</div>
<div> record_route();</div>
<div> }</div>
<div> # route it out to whatever
destination was set by loose_route()</div>
<div> # in $du (destination URI).</div>
<div> route(1);</div>
<div> } else {</div>
<div> /* uncomment the following lines if
you want to enable presence */</div>
<div> ##if (is_method("SUBSCRIBE")
&& $rd == "your.server.ip.address") {</div>
<div> ## # in-dialog subscribe
requests</div>
<div> ## route(2);</div>
<div> ## exit;</div>
<div> ##}</div>
<div> if ( is_method("ACK") ) {</div>
<div> if ( t_check_trans() ) {</div>
<div> # non loose-route,
but stateful ACK; must be an ACK after </div>
<div> # a 487 or e.g. 404
from upstream server</div>
<div> t_relay();</div>
<div> exit;</div>
<div> } else {</div>
<div> # ACK without
matching transaction -></div>
<div> # ignore and discard</div>
<div> exit;</div>
<div> }</div>
<div> }</div>
<div> sl_send_reply("404","Not here");</div>
<div> }</div>
<div> exit;</div>
<div> }</div>
<div><br>
</div>
<div> #initial requests</div>
<div><br>
</div>
<div> # CANCEL processing</div>
<div> if (is_method("CANCEL"))</div>
<div> {</div>
<div> if (t_check_trans())</div>
<div> t_relay();</div>
<div> exit;</div>
<div> }</div>
<div><br>
</div>
<div> t_check_trans();</div>
<div><br>
</div>
<div> # authenticate if from local subscriber (uncomment to
enable auth)</div>
<div> # authenticate all initial non-REGISTER request that
pretend to be</div>
<div> # generated by local subscriber (domain from FROM URI
is local)</div>
<div> ##if (!(method=="REGISTER") &&
from_uri==myself) /*no multidomain version*/</div>
<div> if (!(method=="REGISTER") && is_from_local())
/*multidomain version*/</div>
<div>
{</div>
<div> if (!check_source_address("0")) {</div>
<div> if (!proxy_authorize("",
"subscriber")) {</div>
<div> proxy_challenge("", "0");</div>
<div> exit;</div>
<div> }</div>
<div> if (!db_check_from()) {</div>
<div>
sl_send_reply("403","Forbidden auth ID");</div>
<div> exit;</div>
<div> }</div>
<div><br>
</div>
<div> consume_credentials();</div>
<div> # caller authenticated</div>
<div> #}</div>
<div> }</div>
<div> }</div>
<div><br>
</div>
<div> # preloaded route checking</div>
<div> if (loose_route()) {</div>
<div> xlog("L_ERR", "Attempt to route with
preloaded Route's [$fu/$tu/$ru/$ci]");</div>
<div> if (!is_method("ACK"))</div>
<div> sl_send_reply("403","Preload Route
denied");</div>
<div> exit;</div>
<div> }</div>
<div><br>
</div>
<div> # record routing</div>
<div> if (!is_method("REGISTER|MESSAGE"))</div>
<div> record_route();</div>
<div><br>
</div>
<div><br>
</div>
<div><br>
</div>
<div> # account only INVITEs</div>
<div> if (is_method("INVITE")) {</div>
<div> # load balancing</div>
<div> if (!($si =~ "^115.92.199." || $si =~
"^172.27.155.27")) {</div>
<div> load_balance("2","sip");</div>
<div> if ($retcode<0) {</div>
<div> sl_send_reply("500","Service
full");</div>
<div> exit;</div>
<div> }</div>
<div> xlog("Selected destination is:
$du\n");</div>
<div> setflag(1); # do accounting</div>
<div> #setflag(2);</div>
<div> route(1);</div>
<div> } else {</div>
<div> }</div>
<div> setflag(1); # do accounting</div>
<div> }</div>
<div><br>
</div>
<div><br>
</div>
<div> #if (!uri==myself)</div>
<div> ## replace with following line if multi-domain
support is used</div>
<div> if (!is_uri_host_local())</div>
<div> {</div>
<div> append_hf("P-hint: outbound\r\n"); </div>
<div> # if you have some interdomain connections
via TLS</div>
<div> ##if($rd=="<a moz-do-not-send="true"
href="http://tls_domain1.net">tls_domain1.net</a>") {</div>
<div> ## t_relay("tls:<a
moz-do-not-send="true" href="http://domain1.net">domain1.net</a>");</div>
<div> ## exit;</div>
<div> ##} else if($rd=="<a moz-do-not-send="true"
href="http://tls_domain2.net">tls_domain2.net</a>") {</div>
<div> ## t_relay("tls:<a
moz-do-not-send="true" href="http://domain2.net">domain2.net</a>");</div>
<div> ## exit;</div>
<div> ##}</div>
<div> route(1);</div>
<div> }</div>
<div><br>
</div>
<div> # requests for my domain</div>
<div><br>
</div>
<div> ## uncomment this if you want to enable presence
server </div>
<div> ## and comment the next 'if' block</div>
<div> ## NOTE: uncomment also the definition of route[2]
from below</div>
<div> ##if( is_method("PUBLISH|SUBSCRIBE"))</div>
<div> ## route(2);</div>
<div><br>
</div>
<div> if (is_method("PUBLISH"))</div>
<div> {</div>
<div> sl_send_reply("503", "Service Unavailable");</div>
<div> exit;</div>
<div> }</div>
<div><br>
</div>
<div> if (is_method("REGISTER"))</div>
<div> {</div>
<div> # authenticate the REGISTER requests
(uncomment to enable auth)</div>
<div> if (!www_authorize("", "subscriber"))</div>
<div> {</div>
<div> www_challenge("", "0");</div>
<div> exit;</div>
<div> }</div>
<div><br>
</div>
<div> if (!db_check_to()) </div>
<div> {</div>
<div> sl_send_reply("403","Forbidden auth
ID");</div>
<div> exit;</div>
<div> }</div>
<div><br>
</div>
<div> #-- Request is begind NAT(flag5) save with
bflag 6 --#</div>
<div> if (isflagset(5))</div>
<div> setbflag(6);</div>
<div><br>
</div>
<div> if (!save("location"))</div>
<div> sl_reply_error();</div>
<div><br>
</div>
<div> exit;</div>
<div> }</div>
<div><br>
</div>
<div> if ($rU==NULL) {</div>
<div> # request with no Username in RURI</div>
<div> sl_send_reply("484","Address Incomplete");</div>
<div> exit;</div>
<div> }</div>
<div><br>
</div>
<div>
# apply DB based aliases (uncomment to enable)</div>
<div> alias_db_lookup("dbaliases");</div>
<div><br>
</div>
<div><br>
</div>
<div> # do lookup with method filtering</div>
<div> if (!lookup("location","m")) {</div>
<div><br>
</div>
<div> xlog("L_NOTICE","\n######### LOOKUP
FAILED($retcode) => [$pr:$fu/$tu/$si:$sp] $du: Processing
'$rm' ########## \n\n");</div>
<div><br>
</div>
<div> switch ($retcode) {</div>
<div> case -1:</div>
<div> case -3:</div>
<div> t_newtran();</div>
<div> t_reply("404", "Not Found");</div>
<div> exit;</div>
<div><br>
</div>
<div> #break;</div>
<div> case -2:</div>
<div> sl_send_reply("405", "Method
Not Allowed");</div>
<div> exit;</div>
<div> }</div>
<div> }</div>
<div><br>
</div>
<div> # when routing via usrloc, log the missed calls also</div>
<div> setflag(2);</div>
<div><br>
</div>
<div> route(1);</div>
<div>}</div>
<div><br>
</div>
<div>route[1] {</div>
<div> # for INVITEs enable some additional helper routes</div>
<div> if (subst_uri('/(<a class="moz-txt-link-freetext" href="sip:.*">sip:.*</a>);nat=yes/\1/')) {</div>
<div>
setbflag(6);</div>
<div> }</div>
<div> if (isflagset(5)) {</div>
<div>
search_append('Contact:.*sip:[^>[:cntrl:]]*', ';nat=yes');</div>
<div> }</div>
<div>
<br>
</div>
<div><br>
</div>
<div> # for INVITEs enable some additional helper routes</div>
<div> if (is_method("INVITE")) {</div>
<div> t_on_branch("2");</div>
<div> t_on_reply("2");</div>
<div> t_on_failure("1");</div>
<div> }</div>
<div><br>
</div>
<div> if (!t_relay()) {</div>
<div> sl_reply_error();</div>
<div> };</div>
<div> exit;</div>
<div>}</div>
<div><br>
</div>
<div>branch_route[2] {</div>
<div> xlog("new branch at $ru\n");</div>
<div>}</div>
<div>onreply_route[2] {</div>
<div> xlog("incoming reply\n");</div>
<div> if (isbflagset(6)) {</div>
<div>
search_append('Contact:.*sip:[^>[:cntrl:]]*', ';nat=yes');</div>
<div> append_hf("P-hint: Onreply-route - fixcontact
\r\n");</div>
<div> fix_nated_contact();</div>
<div> }</div>
<div>}</div>
<div>failure_route[1] {</div>
<div> if (t_was_cancelled()) {</div>
<div> exit;</div>
<div> }</div>
<div>}</div>
<pre wrap="">
<fieldset class="mimeAttachmentHeader"></fieldset>
_______________________________________________
Users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Users@lists.opensips.org">Users@lists.opensips.org</a>
<a class="moz-txt-link-freetext" href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a>
</pre>
</blockquote>
</body>
</html>