<div dir="ltr"><div><div dir="auto">Hello</div><div dir="auto"><br></div><div dir="auto">Dialplan is perfect for this.</div><div dir="auto">I did this on kamailio, but it's probably doable porting it.</div><div dir="auto"><br></div><div dir="auto">It would be something like:</div><div dir="auto"><font face="monospace"><br></font></div><div dir="auto"><font face="monospace">modparam("dialplan", "db_url", DBURL)<br><br></font></div><div dir="auto"><font face="monospace">...<br><br></font></div><div dir="auto"><font face="monospace">route[DISPATCH] {<br> ...<br> # Get the attrs field for the matching domain, will store the result in $var(dispatcher_id)<br> dp_translate( "1", "$ru", "$var(dispatcher_id)" )<br><br> # Select the group of fs nodes that we want this call to be sent to.<br> if(!ds_select_dst("$var(dispatcher_id)", "4"))<br> {<br> xlog("[DISPATCH]: ds_select_dst FAILED!'\n");<br> send_reply("404", "No destination");<br> exit;<br> }<br> <br> xlog("L_DBG", "[DISPATCH]: going to <$ru> via <$du>\n");<br> t_on_failure("RTF_DISPATCH");<br> route(RELAY);<br>}</font><br><br> <br>Your dialplan table would look like this:<br><br><font face="monospace">+----+------+-----+----------+---------------------------+-----------+-----------+----------+-------+<br>| id | dpid | pr | match_op | match_exp | match_len | subst_exp | repl_exp | attrs |<br>+----+------+-----+----------+---------------------------+-----------+-----------+----------+-------+<br>| 37 | 1 | 100 | 1 | .*domain1* | 0 | | | 10 |<br>| 55 | 1 | 100 | 1 | .*domain2* | 0 | | | 30 |<br>| 56 | 1 | 100 | 1 | .*domain3* | 0 | | | 30 |</font><br><br>and your dispatcher would look like you want to distribute your traffic:<br><br><font face="monospace">+------+-------+-------------------------+-------+----------+----------------------------------+------------------+<br>| id | setid | destination | flags | priority | attrs | description |<br>+------+-------+-------------------------+-------+----------+----------------------------------+------------------+<br>| 3097 | 10 | sip:<a href="http://1.2.3.1:5080">1.2.3.1:5080</a> | 0 | 10 | | server-01 |<br>| 3098 | 10 | sip:<a href="http://1.2.3.2:5080">1.2.3.2:5080</a> | 0 | 10 | | server-02 |<br>| 3110 | 20 | sip:<a href="http://1.2.3.1:5080">1.2.3.1:5080</a> | 0 | 10 | | server-01 |<br>| 3109 | 20 | sip:<a href="http://1.2.3.2:5080">1.2.3.2:5080</a> | 0 | 10 | | server-02 |<br>| 3108 | 30 | sip:<a href="http://1.2.3.3:5080">1.2.3.3:5080</a> | 0 | 10 | | server-03 |</font><br></div><div dir="auto"><br></div></div><div>I hope that helps!</div><div><br></div><div>David</div></div><div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, 5 Dec 2019 at 15:01, Matthias Kneer via Users <<a href="mailto:users@lists.opensips.org" target="_blank">users@lists.opensips.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div>
<p>Hi list,</p>
<p>I'm currently building a HA setup with 2 openSIPS 2.4 instances
which do share a floating IP through keepalived. They are working
as 1:1 mid_registrar, gateway to the PSTN and dispatcher for
multiple FreeSWITCH instances. Those FreeSWITCH instances hold all
accounts, domains and media services, they also do the RTP part.</p>
<p>Since we are hosting multiple customers on the same FreeSWITCH
instances, sperated through domains, we'd like to ensure that all
registrations of a domain stay on the same FreeSWITCH as long this
instance is reachable. We want this to ensure that conferences,
call pickups and so on work reliable. It's not very important for
us to distribute the load evenly since we have no high call /
conference volume, the goal is more to have the setup as available
as possible with some sort of loadbalancing and without having to
take manual action if one of the FreeSWITCHes dies.<br>
</p>
<p>To achieve this, our idea was to set <b>modparam("dispatcher",
"hash_pvar", "$fd")</b> to use the from domain as source for
hashing and call <b>ds_select_dst </b>with the alg "7":</p>
<p>if (!ds_select_dst("2", "7"))<br>
{<br>
xlog("L_ERR", "$ci|end|no servers avaliable");<br>
sl_send_reply("480", "Temporarily Unavailable");<br>
exit;<br>
}</p>
<p>This approach works fine as long as we use it for internal calls
since those have the from / to domain part properly set. If a call
arrives from the PSTN openSIPS has no knowledge about the relation
of the external numbers and internal numbers / domains. Is there a
smart way to properly route those external calls to the correct
FreeSWITCH wihtout having openSIPS to access the FreeSWITCH
database / duplicating the data into the openSIPS database or to
run FreeSWITCH in active/standby mode?<br>
</p>
<p>Best regards,<br>
Matthias<br>
</p>
</div>
_______________________________________________<br>
Users mailing list<br>
<a href="mailto:Users@lists.opensips.org" target="_blank">Users@lists.opensips.org</a><br>
<a href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users" rel="noreferrer" target="_blank">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a><br>
</blockquote></div></div>