<div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr">Hi Mihai!<div><br></div><div>RTPEngine should be set on the same server where Kamailio is running.</div><div>These are the options I use in RTPEngine on a NATed server, </div><div><br></div><div><div>/etc/sysconfig/rtpengine</div><div># Add extra options here</div><div>OPTIONS="--interface eth1/<a href="http://10.19.139.66">10.19.139.66</a> --listen-ng <a href="http://127.0.0.1:60000">127.0.0.1:60000</a> -m 10000 -M 20000 -L 7 --log-facility=local1"</div></div><div><br></div><div>where 10.19.139.66 is a local Virutal IP address (handled by Pacemaker + Corosync). This IP Address receives everything from the router/firewall who has the public IP address, meaning that for security purposes, the server has no public IP setup directly on the server, instead the public IP is set on the router/firewall equipment, who redirects (almost) everything to the server.</div><div><br></div><div>This is pretty standard.</div><div><br></div><div>My setup is very similar to yours: all SIP traffic received on Kamailio is forwarded to 1 of the Asterisk servers available (using dispatcher) who will process the SIP messages accordingly, including calls which are then forwarded by Asterisk to SIP Trunks (Telcos) or directly to customers (SIP extensions or SIP trunks too). So, resuming, we receive calls from inbound Telcos (or SIP registered partners) to Kamailio then to Asterisk who will decide (route) calls (to IVR or other destinations) and process transcoding if required.</div><div><br></div><div>Not sure if this is the best approach, but it works. However there is 1 minor issue I have found in this setup: inbound calls need a separate IP address from outbound calls, that is, Kamailio's public IP address must be different thant IP Address of the Asterisk servers (all Asterisk servers share the same public IP for outbound to other networks), so that SIP messages do not scramble between inbound and outbound calls.</div><div>Needless to say that you must keep the same path for a call coming from Kamailio to Asterisk, so that SIP messages use always the same Asterisk servers back and forth the endpoints. </div><div>Also, check if RTPEngine is initialized in every call that comes from public network to Kamailio:</div><div>- on route[NATMANAGE]  there must be a rtpengine_manage() command</div><div>- the main route() method must contain the following lines after the route(WITHINDLG); call:</div><div><br></div><div><div>               if (is_method("INVITE|SUBSCRIBE")){</div><div>                        xlog("L_INFO","Recording Route");</div><div>                        record_route();</div><div><br></div><div>                        if (is_method("INVITE")) {</div><div>                            if (has_body("application/sdp")) {</div><div>                                    if (rtpengine_offer())</div><div>                                        t_on_reply("1");</div><div>                                } else {</div><div>                                    t_on_reply("2");</div><div>                                }</div><div>                        }</div><div>                }</div><div><br></div><div>                if (is_method("ACK") && has_body("application/sdp"))</div><div>                        rtpengine_answer();</div><div><br></div></div><div>I think it should be enough.</div><div><br></div><div>Cheers!</div><div><br></div><div>(you still owe me a beer, but now it is 2 😉 ... it this works)</div><div><br clear="all"><div><div dir="ltr" class="gmail_signature"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><p style="color:rgb(0,0,0);margin:0px;font-family:Calibri,sans-serif;background-color:rgb(253,253,253)"><b><span style="font-family:Arial,sans-serif">Sérgio Charrua</span></b><br></p><div><div dir="ltr"><p style="font-size:11pt;color:rgb(0,0,0);margin:0px;font-family:Calibri,sans-serif;background-color:rgb(253,253,253)"><img src="http://cdn.shopify.com/s/files/1/0380/5305/t/11/assets/logo.png?11469850511917603945" width="96" height="32"><b><span style="font-size:9pt;font-family:Arial,sans-serif"><br></span></b></p><p style="font-size:11pt;color:rgb(0,0,0);margin:0px;font-family:Calibri,sans-serif;background-color:rgb(253,253,253)"><b><span style="font-size:9pt;font-family:Arial,sans-serif;color:red"><span style="color:rgb(0,0,0)"></span><span style="color:rgb(51,102,255)"><a href="http://www.voip.pt/" style="color:rgb(17,85,204)" target="_blank">www.voip.pt</a></span></span></b><span style="font-size:x-small"><span style="font-family:Arial,sans-serif;color:rgb(136,136,136)"><br></span><span style="font-family:Arial,sans-serif">Tel.: <span style="color:rgb(51,102,153)"><a href="callto:+351+91+104+12+66" style="color:rgb(51,102,153);text-decoration:none" target="_blank">+351 </a>21 130 71 77<br></span></span><span style="font-family:"Times New Roman",serif"></span></span></p><p style="font-size:11pt;color:rgb(0,0,0);margin:0px;font-family:Calibri,sans-serif;background-color:rgb(253,253,253)"><span style="font-size:x-small"><span style="font-family:Arial,sans-serif;color:rgb(187,187,187)"><span style="color:rgb(128,128,128)">Email : <strong><a href="mailto:sergio.charrua@voip.pt" style="color:rgb(17,85,204)" target="_blank">sergio.charrua@voip.pt</a></strong></span><br></span></span></p><table border="0" cellspacing="0" cellpadding="0" width="650" style="width:487.5pt">
 <tbody><tr>
  <td style="padding:0cm">
  <p class="MsoNormal"><span lang="EN-US" style="font-family:"Vodafone Rg";color:rgb(204,204,204)">This message
  and any files or documents attached are strictly confidential or otherwise
  legally protected. </span></p><p class="MsoNormal"><span lang="EN-US" style="font-family:"Vodafone Rg";color:rgb(204,204,204)">It is intended only for the individual or entity named. If
  you are not the named addressee or have received this email in error, please
  inform the sender immediately, delete it from your system and do not copy or
  disclose it or its contents or use it for any purpose. Please also note that
  transmission cannot be guaranteed to be secure or error-free. </span><span lang="EN-US" style="font-family:"Times New Roman",serif"><span></span></span></p>
  </td>
 </tr>
</tbody></table><p style="color:rgb(0,0,0);margin:0px;font-family:Calibri,sans-serif;background-color:rgb(253,253,253)">

<span style="font-family:"Times New Roman",serif"></span></p><p class="MsoNormal"><span lang="EN-US"> </span></p><p style="color:rgb(0,0,0);margin:0px;font-family:Calibri,sans-serif;background-color:rgb(253,253,253)"> </p></div></div><div style="font-size:small"><br><br></div></div></div></div></div></div></div></div><br></div></div></div></div></div></div></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, May 23, 2021 at 4:42 PM Mihai Cezar <<a href="mailto:cezar@mokalife.ro">cezar@mokalife.ro</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"> If my rtpengine is on vm with 1 ip address ( public ) and started in<br>
the command line with --interface=public/<a href="http://110.20.20.1" rel="noreferrer" target="_blank">110.20.20.1</a> --tos=184<br>
--pidfile=/run/rtpengine.pid<br>
my direction will be public, corect? Or do I need to start rtpengine<br>
on the same vm with asterisk where it has 2 interfaces (public and<br>
private)<br>
<br>
Thanks!<br>
<br>
<br>
<br>
On Sun, May 23, 2021 at 5:11 PM David Villasmil<br>
<<a href="mailto:david.villasmil.work@gmail.com" target="_blank">david.villasmil.work@gmail.com</a>> wrote:<br>
><br>
> This might help you, you need to set directions (as suggested)<br>
><br>
> <a href="https://github.com/davidcsi/kamailio-private-public/blob/master/kamailio.cfg#L1220" rel="noreferrer" target="_blank">https://github.com/davidcsi/kamailio-private-public/blob/master/kamailio.cfg#L1220</a><br>
><br>
><br>
> On Sun, 23 May 2021 at 11:22, M Arqum CH <<a href="mailto:marqumch@gmail.com" target="_blank">marqumch@gmail.com</a>> wrote:<br>
>><br>
>> Hi Mehai,<br>
>><br>
>> Bind rtpengine with local ip as well.<br>
>><br>
>> use direction flags  in  rtpengine_offer function .  <a href="https://kamailio.org/docs/modules/5.2.x/modules/rtpengine.html#rtpengine.f.rtpengine_offer" rel="noreferrer" target="_blank">https://kamailio.org/docs/modules/5.2.x/modules/rtpengine.html#rtpengine.f.rtpengine_offer</a><br>
>><br>
>> From Rtpenigne Doc:<br>
>><br>
>> direction<br>
>><br>
>> Contains a list of two strings and corresponds to the rtpproxy e and i flags. Each element must correspond to one of the named logical interfaces configured on the command line (through --interface). For example, if there is one logical interface named pub and another one named priv, then if side A (originator of the message) is considered to be on the private network and side B (destination of the message) on the public network, then that would be rendered within the dictionary as:<br>
>><br>
>>   { ..., "direction": [ "priv", "pub" ], ... }<br>
>><br>
>><br>
>> Cheers,<br>
>><br>
>> Arqum<br>
>><br>
>><br>
>> On Fri, May 21, 2021 at 10:39 PM Mihai Cezar <<a href="mailto:cezar@mokalife.ro" target="_blank">cezar@mokalife.ro</a>> wrote:<br>
>>><br>
>>> Hi All,<br>
>>><br>
>>> I've been using Kamailio as a proxy for asterisk (with public ips),<br>
>>> everything was fine  until i've changed the setup to private ips for<br>
>>> asterisk.<br>
>>><br>
>>> What I did so far:<br>
>>> - Kamailio and rtpengine are on a box with 1 public IP.<br>
>>> - Asterisk containers on private ips each asterisk has 2 trunks (<br>
>>> 1trunk voip provider 1trunk the Proxy).<br>
>>><br>
>>> What works:<br>
>>> - Proxy registrations and sip signaling works.<br>
>>><br>
>>> What it does not  work:<br>
>>> - On the asterisk I got only on rtp connexion, my guess is that has<br>
>>> something to do with the SDP, asterisk put the private ip in the SDP<br>
>>> header.<br>
>>><br>
>>> RTPengine is configured using this guide <a href="https://github.com/sipwise/rtpengine" rel="noreferrer" target="_blank">https://github.com/sipwise/rtpengine</a><br>
>>><br>
>>> Can you have a look at the kamailio config, i think i am missing<br>
>>> something or do something wrong.<br>
>>><br>
>>> Thank you!<br>
>>><br>
>>> command to start was:<br>
>>> rtpengine --table=42 --listen-ng=<a href="http://127.0.0.1:2223" rel="noreferrer" target="_blank">127.0.0.1:2223</a><br>
>>> --interface=public/<a href="http://110.20.20.1" rel="noreferrer" target="_blank">110.20.20.1</a> --tos=184 --pidfile=/run/rtpengine.pid<br>
>>> --no-fallback<br>
>>><br>
>>> and the Kamailio cfg is this:<br>
>>><br>
>>> #!KAMAILIO<br>
>>><br>
>>> #!define FLT_ACC 1<br>
>>> #!define FLT_ACCMISSED 2<br>
>>> #!define FLT_ACCFAILED 3<br>
>>> #!define FLT_FS 10<br>
>>><br>
>>> #!define FLT_NATS 5<br>
>>> #!define FLB_NATB 6<br>
>>> #!define FLB_NATSIPPING 7<br>
>>><br>
>>> #!define WITH_DEBUG<br>
>>> #!define WITH_NAT<br>
>>><br>
>>><br>
>>> ## This is the main configuration file for our proxy!<br>
>>><br>
>>> ####### Global Parameters #########<br>
>>><br>
>>> #!ifdef WITH_DEBUG<br>
>>> debug=4<br>
>>> memdbg=5<br>
>>> memlog=5<br>
>>> log_stderror=yes<br>
>>> disable_core_dump=no<br>
>>> sip_warning=yes<br>
>>> #!else<br>
>>> debug=-0<br>
>>> log_stderror=no<br>
>>> sip_warning=no<br>
>>> disable_core_dump=yes<br>
>>> #!endif<br>
>>><br>
>>> log_facility=LOG_LOCAL0<br>
>>><br>
>>> fork=yes<br>
>>> children=8<br>
>>> auto_aliases=no<br>
>>> port=5060<br>
>>> disable_tcp=yes<br>
>>><br>
>>> server_id = 1<br>
>>> server_signature=yes<br>
>>> server_header="Server: proxy"<br>
>>><br>
>>> dns_try_ipv6=no<br>
>>> dns_try_naptr=no<br>
>>> dns_retr_time=1<br>
>>> dns_retr_no=1<br>
>>> rev_dns=no<br>
>>><br>
>>> ####### Modules Section ########<br>
>>><br>
>>> #loadmodule "db_mysql.so"<br>
>>> loadmodule "jsonrpcs.so"<br>
>>> loadmodule "kex.so"<br>
>>> loadmodule "corex.so"<br>
>>> loadmodule "tm.so"<br>
>>> loadmodule "tmx.so"<br>
>>> loadmodule "sl.so"<br>
>>> loadmodule "rr.so"<br>
>>> loadmodule "pv.so"<br>
>>> loadmodule "maxfwd.so"<br>
>>> loadmodule "usrloc.so"<br>
>>> loadmodule "registrar.so"<br>
>>> loadmodule "textops.so"<br>
>>> loadmodule "siputils.so"<br>
>>> loadmodule "xlog.so"<br>
>>> loadmodule "sanity.so"<br>
>>> loadmodule "ctl.so"<br>
>>> loadmodule "acc.so"<br>
>>> loadmodule "dispatcher.so"<br>
>>> loadmodule "path.so"<br>
>>> loadmodule "nathelper.so"<br>
>>> loadmodule "rtpengine.so"<br>
>>><br>
>>><br>
>>> ####### Modules Settings<br>
>>> # ----------------- setting module-specific parameters ---------------<br>
>>><br>
>>> modparam("xlog", "buf_size", 4096)<br>
>>> modparam("xlog", "prefix", "xlog: ")<br>
>>> modparam("xlog", "log_facility", "LOG_DAEMON")<br>
>>> modparam("xlog", "log_colors", "L_ERR=cr")<br>
>>> modparam("xlog", "log_colors", "L_ERR=cr;L_WARN=px")<br>
>>><br>
>>> # ----- jsonrpcs params -----<br>
>>> modparam("jsonrpcs", "pretty_format", 1)<br>
>>><br>
>>> # ----- tm params -----<br>
>>> modparam("tm", "failure_reply_mode", 3)<br>
>>> modparam("tm", "fr_timer", 30000)<br>
>>> modparam("tm", "fr_inv_timer", 120000)<br>
>>><br>
>>> # ----- rr params -----<br>
>>> modparam("rr", "enable_full_lr", 1)<br>
>>> modparam("rr", "append_fromtag", 0)<br>
>>><br>
>>> #!ifdef WITH_NAT<br>
>>> modparam("nathelper", "received_avp", "$avp(RECEIVED)")<br>
>>> modparam("nathelper", "nortpproxy_str", "a=sdpmangled:yes\r\n")<br>
>>> modparam("nathelper", "natping_interval", 30)<br>
>>> modparam("nathelper", "ping_nated_only", 1)<br>
>>> modparam("nathelper", "sipping_bflag", FLB_NATSIPPING)<br>
>>> modparam("nathelper", "sipping_from", "sip:pinger@proxy")<br>
>>><br>
>>> # params needed for NAT traversal in other modules<br>
>>> modparam("nathelper|registrar", "received_avp", "$avp(RECEIVED)")<br>
>>> modparam("usrloc", "nat_bflag", FLB_NATB)<br>
>>><br>
>>> modparam("rtpengine", "rtpengine_sock", "udp:<a href="http://127.0.0.1:2223" rel="noreferrer" target="_blank">127.0.0.1:2223</a>")<br>
>>> modparam("rtpengine", "rtpengine_retr", 2)<br>
>>> modparam("rtpengine", "hash_table_size", 256)<br>
>>> modparam("rtpengine", "hash_table_tout", 600)<br>
>>> #!endif<br>
>>><br>
>>> # ----- registrar params -----<br>
>>> modparam("registrar", "method_filtering", 1)<br>
>>> modparam("registrar", "append_branches", 0)<br>
>>> modparam("registrar", "max_expires", 3600)<br>
>>> modparam("registrar", "gruu_enabled", 1)<br>
>>><br>
>>> # ----- acc params -----<br>
>>> modparam("acc", "early_media", 0)<br>
>>> modparam("acc", "report_ack", 0)<br>
>>> modparam("acc", "report_cancels", 0)<br>
>>> modparam("acc", "detect_direction", 0)<br>
>>> modparam("acc", "log_flag", FLT_ACC)<br>
>>> modparam("acc", "log_missed_flag", FLT_ACCMISSED)<br>
>>> modparam("acc", "log_extra",<br>
>>> "src_user=$fU;src_domain=$fd;dst_ouser=$tU;dst_user=$rU;dst_domain=$rd;src_ip=$si")<br>
>>> modparam("acc", "failed_transaction_flag", FLT_ACCFAILED)<br>
>>><br>
>>> # ----- dispatcher params -----<br>
>>> modparam("dispatcher", "list_file", "/etc/kamailio/plugins/dispatcher.list")<br>
>>> modparam("dispatcher", "xavp_dst", "_dsdst_")<br>
>>> modparam("dispatcher", "xavp_ctx", "_dsctx_")<br>
>>> modparam("dispatcher", "ds_ping_from", "sip:ping@proxy")<br>
>>> modparam("dispatcher", "ds_probing_mode", 1)<br>
>>><br>
>>> modparam("path", "use_received", 1)<br>
>>><br>
>>><br>
>>> ####### Routing Logic ###########<br>
>>> # main request routing logic<br>
>>><br>
>>> request_route {<br>
>>><br>
>>>     # per request initial checks<br>
>>>     route(REQINIT);<br>
>>><br>
>>>     # NAT detection<br>
>>>     route(NATDETECT);<br>
>>><br>
>>>     if(ds_is_from_list()) {<br>
>>>             setflag(FLT_FS);<br>
>>>     }<br>
>>><br>
>>>     # CANCEL processing<br>
>>>     if (is_method("CANCEL")) {<br>
>>>         rtpengine_delete();<br>
>>>         if (t_check_trans()) {<br>
>>>             route(RELAY);<br>
>>>         }<br>
>>>         exit;<br>
>>>     }<br>
>>><br>
>>>     # handle retransmissions<br>
>>>     if (!is_method("ACK")) {<br>
>>>         if(t_precheck_trans()) {<br>
>>>             t_check_trans();<br>
>>>             exit;<br>
>>>         }<br>
>>>         t_check_trans();<br>
>>>     }<br>
>>><br>
>>>     # handle requests within SIP dialogs<br>
>>>     route(WITHINDLG);<br>
>>><br>
>>>     if (isflagset(FLT_FS)) {<br>
>>>             route(FROM_WORLD);<br>
>>>             exit;<br>
>>>     }<br>
>>><br>
>>>     ### only initial requests (no To tag)<br>
>>><br>
>>>     # record routing for dialog forming requests (in case they are routed)<br>
>>>     # - remove preloaded route headers<br>
>>>     remove_hf("Route");<br>
>>>     if (is_method("INVITE|SUBSCRIBE")) {<br>
>>>         record_route();<br>
>>>     }<br>
>>><br>
>>>     # account only INVITEs<br>
>>>     if (is_method("INVITE")) {<br>
>>>         setflag(FLT_ACC); # do accounting<br>
>>>         sl_send_reply("100","Trying");<br>
>>>     }<br>
>>><br>
>>>     # handle presence related requests<br>
>>>     route(PRESENCE);<br>
>>><br>
>>>     # handle registrations<br>
>>>     route(REGISTRAR);<br>
>>><br>
>>>     if ($rU==$null) {<br>
>>>         # request with no Username in RURI<br>
>>>         sl_send_reply("484","Address Incomplete");<br>
>>>         exit;<br>
>>>     }<br>
>>><br>
>>>     # dispatch destinations<br>
>>>     route(DISPATCH);<br>
>>> }<br>
>>><br>
>>> route[FROM_WORLD]<br>
>>> {<br>
>>>         record_route();<br>
>>>         route(RELAY);<br>
>>>         exit;<br>
>>> }<br>
>>><br>
>>> route[RELAY] {<br>
>>>     if (!t_relay()) {<br>
>>>         sl_reply_error();<br>
>>>     }<br>
>>><br>
>>>     if (!add_path()) {<br>
>>>         sl_send_reply("503", "Internal Path Error");<br>
>>>     }<br>
>>><br>
>>>     if (is_method("INVITE|BYE|SUBSCRIBE|UPDATE")) {<br>
>>>         if(!t_is_set("branch_route")) t_on_branch("MANAGE_BRANCH");<br>
>>>     }<br>
>>>     if (is_method("INVITE|SUBSCRIBE|UPDATE")) {<br>
>>>         if(!t_is_set("onreply_route")) t_on_reply("MANAGE_REPLY");<br>
>>>     }<br>
>>>     if (is_method("INVITE")) {<br>
>>>         if(!t_is_set("failure_route")) t_on_failure("MANAGE_FAILURE");<br>
>>>     }<br>
>>><br>
>>>     if (has_body("application/sdp")) {<br>
>>>             rtpengine_manage();<br>
>>>     }<br>
>>><br>
>>>     append_hf("Supported: path\r\n");<br>
>>>     exit;<br>
>>> }<br>
>>><br>
>>> # Per SIP request initial checks<br>
>>> route[REQINIT] {<br>
>>><br>
>>>     if (!mf_process_maxfwd_header("10")) {<br>
>>>         sl_send_reply("483","Too Many Hops");<br>
>>>         exit;<br>
>>>     }<br>
>>><br>
>>>     if(is_method("OPTIONS") && uri==myself && $rU==$null) {<br>
>>>         sl_send_reply("200","Keepalive");<br>
>>>         exit;<br>
>>>     }<br>
>>><br>
>>>     if(!sanity_check("1511", "7")) {<br>
>>>         xlog("L_WARN","Malformed SIP message from $si:$sp\n");<br>
>>>         exit;<br>
>>>     }<br>
>>> }<br>
>>><br>
>>> # Handle requests within SIP dialogs<br>
>>> route[WITHINDLG] {<br>
>>>     if (has_totag()) {<br>
>>>         # sequential request withing a dialog should<br>
>>>         # take the path determined by record-routing<br>
>>>         if (loose_route()) {<br>
>>>             if (is_method("BYE")) {<br>
>>>                 rtpengine_delete();<br>
>>>                 setflag(FLT_ACC); # do accounting ...<br>
>>>                 setflag(FLT_ACCFAILED); # ... even if the transaction fails<br>
>>>             } else if ( is_method("ACK") ) {<br>
>>>                 # ACK is forwarded statelessly<br>
>>>                 route(NATMANAGE);<br>
>>>             } else if ( is_method("NOTIFY") ) {<br>
>>>                 # Add Record-Route for in-dialog NOTIFY as per RFC 6665.<br>
>>>                 record_route();<br>
>>>             }<br>
>>>             route(RELAY);<br>
>>>             # exit;<br>
>>><br>
>>>         } else {<br>
>>><br>
>>>             if (is_method("SUBSCRIBE") && uri == myself) {<br>
>>>                 # in-dialog subscribe requests<br>
>>>                 route(PRESENCE);<br>
>>>                 exit;<br>
>>>             }<br>
>>>             if ( is_method("ACK") ) {<br>
>>>                 if ( t_check_trans() ) {<br>
>>>                     # non loose-route, but stateful ACK; must be ACK<br>
>>> after a 487 or e.g. 404 from upstream server<br>
>>>                     t_relay();<br>
>>>                     exit;<br>
>>>                 } else {<br>
>>>                     # ACK without matching transaction ... ignore and discard.<br>
>>>                     exit;<br>
>>>                 }<br>
>>>             }<br>
>>>             sl_send_reply("404","Not here");<br>
>>>         }<br>
>>>         exit;<br>
>>>     }<br>
>>> }<br>
>>><br>
>>> # Handle SIP registrations<br>
>>> route[REGISTRAR] {<br>
>>><br>
>>>     if(!is_method("REGISTER"))<br>
>>>         return;<br>
>>><br>
>>>     if(isflagset(FLT_NATS)) {<br>
>>>         setbflag(FLB_NATB);<br>
>>>     }<br>
>>><br>
>>>     if (!add_path_received()) {<br>
>>>         sl_send_reply("503", "Internal Path Error");<br>
>>>     };<br>
>>><br>
>>>     route(DISPATCH);<br>
>>> }<br>
>>><br>
>>> # Presence server route<br>
>>> route[PRESENCE] {<br>
>>>     if(!is_method("PUBLISH|SUBSCRIBE"))<br>
>>>         return;<br>
>>><br>
>>>     sl_send_reply("404", "Not found");<br>
>>>     exit;<br>
>>> }<br>
>>><br>
>>><br>
>>> # Dispatch requests<br>
>>> route[DISPATCH] {<br>
>>>     # to add more servers in k8s<br>
>>>     if (!ds_select_dst("1", "4")) {<br>
>>>                     send_reply(503, "Service Unavailable $fd");<br>
>>>                     exit;<br>
>>>     }<br>
>>><br>
>>>     t_on_failure("RTF_DISPATCH");<br>
>>>     route(RELAY);<br>
>>>     exit;<br>
>>> }<br>
>>><br>
>>> # Caller NAT detection<br>
>>> route[NATDETECT] {<br>
>>> #!ifdef WITH_NAT<br>
>>>      if (nat_uac_test("3")) {<br>
>>>                if (is_method("REGISTER")) {<br>
>>>                            xlog("L_WARN", "natdetect<br>
>>> fix_nated_register ip: $si\n");<br>
>>>                        fix_nated_register();<br>
>>>                } else {<br>
>>>                            xlog("L_WARN", "natdetect set_contact_alias<br>
>>> ip: $si\n");<br>
>>>                        fix_nated_contact();<br>
>>>                }<br>
>>>                force_rport();<br>
>>>        }<br>
>>>        if (has_body("application/sdp") && nat_uac_test("8")) {<br>
>>>                xlog("L_WARN", "sdp fix ip: $si\n");<br>
>>>                fix_nated_sdp("10");<br>
>>>        }<br>
>>> #!endif<br>
>>>     return;<br>
>>> }<br>
>>><br>
>>> # RTPProxy control and signaling updates for NAT traversal<br>
>>> route[NATMANAGE] {<br>
>>> #!ifdef WITH_NAT<br>
>>>         if (is_request()) {<br>
>>>                 if(has_totag()) {<br>
>>>                         if(check_route_param("nat=yes")) {<br>
>>>                                 setbflag(FLB_NATB);<br>
>>>                         }<br>
>>>                 }<br>
>>>         }<br>
>>>         if (!(isflagset(FLT_NATS) || isbflagset(FLB_NATB))) return;<br>
>>><br>
>>>         if(nat_uac_test("8")) {<br>
>>>             xlog("L_WARN", "nat_uac_test 1...");<br>
>>>             rtpengine_manage("replace-origin<br>
>>> replace-session-connection direction=public ICE=force");<br>
>>>         } else {<br>
>>>             xlog("L_WARN", "nat_uac_test addrtp...");<br>
>>>             rtpengine_manage("codec-strip-all codec-transcode-PCMA<br>
>>> codec-transcode-PCMU codec-transcode-G729 replace-origin<br>
>>> replace-session-connection direction=public ICE=force ");<br>
>>>         }<br>
>>><br>
>>>         if (is_request()) {<br>
>>>                 if (!has_totag()) {<br>
>>>                         if(t_is_branch_route()) {<br>
>>>                                 add_rr_param(";nat=yes");<br>
>>>                         }<br>
>>>                 }<br>
>>>         }<br>
>>>         if (is_reply()) {<br>
>>>                 if(isbflagset(FLB_NATB)) {<br>
>>>                         if(is_first_hop())<br>
>>>                                 set_contact_alias();<br>
>>>                 }<br>
>>>         }<br>
>>> #!endif<br>
>>>         return;<br>
>>> }<br>
>>><br>
>>> # Manage outgoing branches<br>
>>> branch_route[MANAGE_BRANCH] {<br>
>>>     xlog("L_WARN", "new branch [$T_branch_idx] to $ru\n");<br>
>>>     route(NATMANAGE);<br>
>>> }<br>
>>><br>
>>> # Manage incoming replies<br>
>>> onreply_route[MANAGE_REPLY] {<br>
>>>         xlog("L_WARN", "incoming reply\n");<br>
>>><br>
>>>         if(status=~"[12][0-9][0-9]") {<br>
>>>                 route(NATMANAGE);<br>
>>>         }<br>
>>>         if (has_body("application/sdp")) {<br>
>>>                 rtpengine_manage();<br>
>>>         }<br>
>>><br>
>>> }<br>
>>><br>
>>> onreply_route[REPLY_ROUTE] {<br>
>>>     if(status=~"2[0-9][0-9]") {<br>
>>>         rtpengine_answer("replace-session-connection replace-origin");<br>
>>>     }<br>
>>>     if (has_body("application/sdp")) {<br>
>>>         rtpengine_offer();<br>
>>>     }<br>
>>> }<br>
>>><br>
>>> # Manage failure routing cases<br>
>>> failure_route[MANAGE_FAILURE] {<br>
>>>     xlog("L_WARN", "failure route\n");<br>
>>>     route(NATMANAGE);<br>
>>>     if (t_is_canceled()) exit;<br>
>>> }<br>
>>><br>
>>> # Try next destionations in failure route<br>
>>> failure_route[RTF_DISPATCH] {<br>
>>>     if (t_is_canceled()) {<br>
>>>         exit;<br>
>>>     }<br>
>>>     # next DST - only for 500 or local timeout<br>
>>>     if (t_check_status("500")<br>
>>>             or (t_branch_timeout() and !t_branch_replied())) {<br>
>>>         if(ds_next_dst()) {<br>
>>>             xlog("Retrying to <$ru> via <$du> (attrs:<br>
>>> $xavp(_dsdst_=>attrs))\n");<br>
>>>             t_on_failure("RTF_DISPATCH");<br>
>>>             route(RELAY);<br>
>>>             exit;<br>
>>>         }<br>
>>>     }<br>
>>> }<br>
>>><br>
>>> __________________________________________________________<br>
>>> Kamailio - Users Mailing List - Non Commercial Discussions<br>
>>>   * <a href="mailto:sr-users@lists.kamailio.org" target="_blank">sr-users@lists.kamailio.org</a><br>
>>> Important: keep the mailing list in the recipients, do not reply only to the sender!<br>
>>> Edit mailing list options or unsubscribe:<br>
>>>   * <a href="https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users" rel="noreferrer" target="_blank">https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users</a><br>
>><br>
>><br>
>><br>
>> --<br>
>> Regards<br>
>> M Arqum<br>
>> __________________________________________________________<br>
>> Kamailio - Users Mailing List - Non Commercial Discussions<br>
>>   * <a href="mailto:sr-users@lists.kamailio.org" target="_blank">sr-users@lists.kamailio.org</a><br>
>> Important: keep the mailing list in the recipients, do not reply only to the sender!<br>
>> Edit mailing list options or unsubscribe:<br>
>>   * <a href="https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users" rel="noreferrer" target="_blank">https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users</a><br>
><br>
> --<br>
> Regards,<br>
><br>
> David Villasmil<br>
> email: <a href="mailto:david.villasmil.work@gmail.com" target="_blank">david.villasmil.work@gmail.com</a><br>
> phone: +34669448337<br>
> __________________________________________________________<br>
> Kamailio - Users Mailing List - Non Commercial Discussions<br>
>   * <a href="mailto:sr-users@lists.kamailio.org" target="_blank">sr-users@lists.kamailio.org</a><br>
> Important: keep the mailing list in the recipients, do not reply only to the sender!<br>
> Edit mailing list options or unsubscribe:<br>
>   * <a href="https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users" rel="noreferrer" target="_blank">https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users</a><br>
<br>
__________________________________________________________<br>
Kamailio - Users Mailing List - Non Commercial Discussions<br>
  * <a href="mailto:sr-users@lists.kamailio.org" target="_blank">sr-users@lists.kamailio.org</a><br>
Important: keep the mailing list in the recipients, do not reply only to the sender!<br>
Edit mailing list options or unsubscribe:<br>
  * <a href="https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users" rel="noreferrer" target="_blank">https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users</a><br>
</blockquote></div>