<div>Hi, I am using Kamailio 3.2.0 (x86_64/linux) and since some days ago I am trying to call from a network with NAT to outside. This is the configuration:</div><div><br></div><div>Softphone (192.168.0.5) &lt;--&gt; Kamailio (192.168.0.3) &lt;--&gt; Router (192.168.0.1) &lt;--&gt; Softphone over smartphone</div>


<div><br></div><div>All the router ports are opened and redirected to 192.168.0.3. I have installed rtpproxy 1.2.1-1 with the following configuration:</div><div><br></div><div>--------------------------/etc/defaults/rtpproxy--------------------------------</div>


<div># The control socket.</div><div>#CONTROL_SOCK=&quot;unix:/var/run/rtpproxy/rtpproxy.sock&quot;</div><div># To listen on an UDP socket, uncomment this line:</div><div>CONTROL_SOCK=udp:<a href="http://127.0.0.1:22222" target="_blank">127.0.0.1:22222</a></div>


<div><br></div><div># Additional options that are passed to the daemon.</div><div>EXTRA_OPTS=&quot;-l <a href="http://candamil.dyndns.org" target="_blank">candamil.dyndns.org</a>&quot;</div><div>----------------------------------------------------------------------------------------</div>


<div><br></div><div>and works properly. This is the log message:</div><div><br></div><div>----------------------------------------------------------------------------------------------</div>
<div>Nov 12 20:09:13 condor kamailio[7001]: INFO: rtpproxy [rtpproxy.c:1415]:</div><div>rtp proxy &lt;udp:<a href="http://127.0.0.1:22222" target="_blank">127.0.0.1:22222</a>&gt; found, support for it enabled</div><div>-----------------------------------------------------------------------------------------------</div>


<div><br></div><div><br></div><div>Both softphones are &quot;linphone&quot;. The configuration of the network softphone is the following:</div><div><br></div><div>SIP identity: <a href="mailto:sip%3A1001@192.168.0.3" target="_blank">sip:1001@192.168.0.3</a></div>


<div>SIP proxy: sip:192.168.0.3</div><div>Direct connection to the Internet.</div><div><br></div><div>In the softphone of the smartphone I set as proxy and domain &quot;<a href="http://candamil.dyndns.org">candamil.dyndns.org</a>&quot;, the DNS address of my router IP.</div>

<div><br></div><div>In this case, these are the symptoms:</div><div>Both softphones can autentify correctly. When calling, both softphones ring, but when I answer, the voice signal is not received. This is the log error:</div>

<div><br></div><div>----------------------------------------------------------------------------------------------</div>
<div>Nov 12 20:23:14 condor kamailio[6991]: ERROR: rtpproxy [rtpproxy.c:2260]:</div><div>incorrect port 0 in reply from rtp proxy</div><div>----------------------------------------------------------------------------------------------</div>


<div><br></div><div><br></div><div>The same happens if I set in the network softphone that it&#39;s behind NAT, and I set the router IP.</div><div>The same happens if I set in the network softphone that it&#39;s behind NAT and with a STUN server (<a href="http://stunserver.org">stunserver.org</a>). In the three cases, in the softphone over smartphone, the caller is <a href="mailto:1001@192.168.0.3">1001@192.168.0.3</a>, and in the network softphone, the caller is <a href="mailto:1002@candamil.dyndns.org">1002@candamil.dyndns.org</a>.</div>

<div><br></div><div>If I set in the network softphone the proxy as sip:<a href="http://candamil.dyndns.org/" target="_blank">candamil.dyndns.org</a>, the same happens.</div><div>If what I do is setting the SIP identity as  <a href="mailto:sip%3A1001@candamil.dyndns.org" target="_blank">sip:1001@candamil.dyndns.org</a>, when calling form inside to ouside the network, the softphone doesn&#39;t know that the call was answered, and there is the following error in the log:</div>

<div><br></div><div>----------------------------------------------------------------------------------------------------------</div>
<div>Nov 12 20:53:00 condor kamailio[7306]: ERROR: &lt;core&gt;</div><div>[parser/parse_via.c:2600]: ERROR: parse_via: invalid port number</div><div>&lt;5060ranch=z9hG4bKc</div><div>50f.b4825246.0&gt;</div><div>Nov 12 20:53:00 condor kamailio[7306]: ERROR: &lt;core&gt;</div>


<div>[parser/parse_via.c:2629]: ERROR: parse_via on: &lt;SIP/2.0/UDP</div><div>192.168.0.3:5060ranch=z</div><div>9hG4bKc50f.b4825246.0;received=<a href="tel:87.223.138.84%23015%23" value="+18722313884" target="_blank">87.223.138.84#015#</a>012Via: SIP/2.0/UDP</div>

<div><a href="tel:87.223.138.84" value="+18722313884" target="_blank">87.223.138.84</a>:5060;rport=5060;branch=z9hG4bK1021772993#015#012From:</div>
<div>&lt;<a href="mailto:sip%3A1001@candamil.dyndns.org" target="_blank">sip:1001@candamil.dyndns.org</a>&gt;;tag=783852345#015#012To: &lt;</div><div><a href="mailto:sip%3A1002@candamil.dyndns.org" target="_blank">sip:1002@candamil.dyndns.org</a>&gt;#015#012Call-ID: 1644787160#015#012CSeq: 21</div>


<div>INVITE#</div><div>015#012User-Agent: Linphone/3.4.0 (eXosip2/unknown)#015#012Content-Length:</div><div>0#015#012#015#012&gt;</div><div>------------------------------------------------------------------------------------------------------------</div>


<div><br></div><div>If the call is from outside to inside the network, it happens the same than in the previous cases.</div><div><br></div><div>This is the relevant kamailio configuration:</div><div><br>
</div><div>-----------------------------------------kamailio.cfg----------------------------------------------------</div><div>#!define WITH_MYSQL</div><div>#!define WITH_AUTH</div><div>#!define WITH_NAT</div><div><br></div>


<div>####### Defined Values #########</div><div><br></div><div># *** Value defines - IDs used later in config</div><div>#!ifdef WITH_MYSQL</div><div># - database URL - used to connect to database server by modules such</div>


<div>#       as: auth_db, acc, usrloc, a.s.o.</div><div>#!define DBURL &quot;mysql://openser:openserrw@localhost/openser&quot;</div><div>#!endif</div><div>#!ifdef WITH_MULTIDOMAIN</div><div># - the value for &#39;use_domain&#39; parameters</div>


<div>#!define MULTIDOMAIN 1</div><div>#!else</div><div>#!define MULTIDOMAIN 0</div><div>#!endif</div><div><br></div><div># - flags</div><div>#   FLT_ - per transaction (message) flags</div><div># FLB_ - per branch flags</div>


<div>#!define FLT_ACC 1</div><div>#!define FLT_ACCMISSED 2</div><div>#!define FLT_ACCFAILED 3</div><div>#!define FLT_NATS 5</div><div><br></div><div>#!define FLB_NATB 6</div><div>#!define FLB_NATSIPPING 7</div><div><br></div>


<div>####### Global Parameters #########</div><div>/* uncomment the next line to disable the auto discovery of local aliases</div><div>  based on reverse DNS on IPs (default on) */</div><div>#auto_aliases=no</div><div><br>


</div><div>/* add local domain aliases */</div><div>alias=&quot;<a href="http://candamil.dyndns.org" target="_blank">candamil.dyndns.org</a>&quot;</div><div><br></div><div>/* port to listen to</div><div> * - can be specified more than once if needed to listen on many ports */</div>


<div>port=5060</div><div><br></div><div>#!ifdef WITH_TLS</div><div>enable_tls=yes</div><div>#!endif</div><div><br></div><div># life time of TCP connection when there is no traffic</div><div># - a bit higher than registration expires to cope with UA behind NAT</div>


<div>tcp_connection_lifetime=3605</div><div><br></div><div>####### Custom Parameters #########</div><div><br></div><div>#!ifdef WITH_PSTN</div><div># PSTN GW Routing</div><div>#</div><div># - pstn.gw_ip: valid IP or hostname as string value, example:</div>


<div># pstn.gw_ip = &quot;10.0.0.101&quot; desc &quot;My PSTN GW Address&quot;</div><div>#</div><div># - by default is empty to avoid misrouting</div><div>pstn.gw_ip = &quot;&quot; desc &quot;PSTN GW Address&quot;</div><div>


#!endif</div><div><br></div><div>####### Modules Section ########</div><div><br></div><div>#!ifdef WITH_MYSQL</div><div>loadmodule &quot;db_mysql.so&quot;</div><div>#!endif</div><div><br></div><div>#!ifdef WITH_AUTH</div>


<div>loadmodule &quot;auth.so&quot;</div><div>loadmodule &quot;auth_db.so&quot;</div><div><br></div><div>#!ifdef WITH_NAT</div><div>loadmodule &quot;nathelper.so&quot;</div><div>loadmodule &quot;rtpproxy.so&quot;</div><div>


#!endif</div><div><br></div><div># ----------------- setting module-specific parameters ---------------</div><div><br></div><div># ----- auth_db params -----</div><div>#!ifdef WITH_AUTH</div><div>modparam(&quot;auth_db&quot;, &quot;db_url&quot;, DBURL)</div>


<div>modparam(&quot;auth_db&quot;, &quot;calculate_ha1&quot;, yes)</div><div>modparam(&quot;auth_db&quot;, &quot;password_column&quot;, &quot;password&quot;)</div><div>modparam(&quot;auth_db&quot;, &quot;load_credentials&quot;, &quot;&quot;)</div>


<div>modparam(&quot;auth_db&quot;, &quot;use_domain&quot;, MULTIDOMAIN)</div><div><br></div><div><br></div><div>#!ifdef WITH_NAT</div><div># ----- rtpproxy params -----</div><div>modparam(&quot;rtpproxy&quot;, &quot;rtpproxy_sock&quot;, &quot;udp:<a href="http://127.0.0.1:22222" target="_blank">127.0.0.1:22222</a>&quot;)</div>


<div><br></div><div># ----- nathelper params -----</div><div>modparam(&quot;nathelper&quot;, &quot;natping_interval&quot;, 30)</div><div>modparam(&quot;nathelper&quot;, &quot;ping_nated_only&quot;, 1)</div><div>modparam(&quot;nathelper&quot;, &quot;sipping_bflag&quot;, FLB_NATSIPPING)</div>


<div>modparam(&quot;nathelper&quot;, &quot;sipping_from&quot;, &quot;<a href="mailto:sip%3Apinger@kamailio.org" target="_blank">sip:pinger@kamailio.org</a>&quot;)</div><div><br></div><div># params needed for NAT traversal in other modules</div>


<div>modparam(&quot;nathelper|registrar&quot;, &quot;received_avp&quot;, &quot;$avp(RECEIVED)&quot;)</div><div>modparam(&quot;usrloc&quot;, &quot;nat_bflag&quot;, FLB_NATB)</div><div>#!endif</div><div><br></div><div>####### Routing Logic ########</div>


<div><br></div><div><br></div><div># Main SIP request routing logic</div><div># - processing of any incoming SIP request starts with this route</div><div># - note: this is the same as route { ... }</div><div>request_route {</div>


<div><br></div><div># per request initial checks</div><div>route(REQINIT);</div><div><br></div><div> # NAT detection</div><div>route(NATDETECT);</div><div><br></div><div># handle requests within SIP dialogs</div><div> route(WITHINDLG);</div>


<div><br></div><div>### only initial requests (no To tag)</div><div><br></div><div> # CANCEL processing</div><div>if (is_method(&quot;CANCEL&quot;))</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># authentication</div><div> route(AUTH);</div><div><br></div><div># record routing for dialog forming requests (in case they are routed)</div>


<div> # - remove preloaded route headers</div><div>remove_hf(&quot;Route&quot;);</div><div>if (is_method(&quot;INVITE|SUBSCRIBE&quot;))</div><div> record_route();</div><div><br></div><div># account only INVITEs</div><div>


if (is_method(&quot;INVITE&quot;))</div><div> {</div><div>setflag(FLT_ACC); # do accounting</div><div>}</div><div><br></div><div># dispatch requests to foreign domains</div><div>route(SIPOUT);</div><div><br></div><div> ### requests for my local domains</div>


<div><br></div><div># handle presence related requests</div><div> route(PRESENCE);</div><div><br></div><div># handle registrations</div><div>route(REGISTRAR);</div><div><br></div><div>if ($rU==$null)</div><div>{</div><div>


# request with no Username in RURI</div><div> sl_send_reply(&quot;484&quot;,&quot;Address Incomplete&quot;);</div><div>exit;</div><div>}</div><div><br></div><div># dispatch destinations to PSTN</div><div>route(PSTN);</div>


<div><br></div><div> # user location service</div><div>route(LOCATION);</div><div><br></div><div>route(RELAY);</div><div>}</div><div><br></div><div><br></div><div>route[RELAY] {</div><div><br></div><div># enable additional event routes for forwarded requests</div>


<div># - serial forking, RTP relaying handling, a.s.o.</div><div> if (is_method(&quot;INVITE|SUBSCRIBE&quot;)) {</div><div>t_on_branch(&quot;MANAGE_BRANCH&quot;);</div><div> t_on_reply(&quot;MANAGE_REPLY&quot;);</div><div>


}</div><div>if (is_method(&quot;INVITE&quot;)) {</div><div> t_on_failure(&quot;MANAGE_FAILURE&quot;);</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># Per SIP request initial checks</div><div>route[REQINIT] {</div><div>#!ifdef WITH_ANTIFLOOD</div><div># flood dection from same IP and traffic ban for a while</div><div> # be sure you exclude checking trusted peers, such as pstn gateways</div>


<div># - local host excluded (e.g., loop to self)</div><div> if(src_ip!=myself)</div><div>{</div><div>if($sht(ipban=&gt;$si)!=$null)</div><div> {</div><div># ip is already blocked</div><div>xdbg(&quot;request from blocked IP - $rm from $fu (IP:$si:$sp)\n&quot;);</div>


<div> exit;</div><div>}</div><div>if (!pike_check_req())</div><div> {</div><div>xlog(&quot;L_ALERT&quot;,&quot;ALERT: pike blocking $rm from $fu (IP:$si:$sp)\n&quot;);</div><div> $sht(ipban=&gt;$si) = 1;</div><div>exit;</div>


<div>}</div><div> }</div><div>#!endif</div><div><br></div><div>if (!mf_process_maxfwd_header(&quot;10&quot;)) {</div><div> sl_send_reply(&quot;483&quot;,&quot;Too Many Hops&quot;);</div><div>exit;</div><div>}</div><div><br>


</div><div>if(!sanity_check(&quot;1511&quot;, &quot;7&quot;))</div><div>{</div><div>xlog(&quot;Malformed SIP message from $si:$sp\n&quot;);</div><div> exit;</div><div>}</div><div>}</div><div><br></div><div># Handle requests within SIP dialogs</div>


<div>route[WITHINDLG] {</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(&quot;BYE&quot;)) {</div>


<div> setflag(FLT_ACC); # do accounting ...</div><div>setflag(FLT_ACCFAILED); # ... even if the transaction fails</div><div> }</div><div>if ( is_method(&quot;ACK&quot;) ) {</div><div># ACK is forwarded statelessy</div><div>


 route(NATMANAGE);</div><div>}</div><div>route(RELAY);</div><div> } else {</div><div>if (is_method(&quot;SUBSCRIBE&quot;) &amp;&amp; uri == myself) {</div><div> # in-dialog subscribe requests</div><div>route(PRESENCE);</div>


<div>exit;</div><div> }</div><div>if ( is_method(&quot;ACK&quot;) ) {</div><div>if ( t_check_trans() ) {</div><div> # no loose-route, but stateful ACK;</div><div># must be an ACK after a 487</div><div># or e.g. 404 from upstream server</div>


<div> t_relay();</div><div>exit;</div><div>} else {</div><div> # ACK without matching transaction ... ignore and discard</div><div>exit;</div><div>}</div><div> }</div><div>sl_send_reply(&quot;404&quot;,&quot;Not here&quot;);</div>


<div>}</div><div> exit;</div><div>}</div><div>}</div><div><br></div><div># Handle SIP registrations</div><div>route[REGISTRAR] {</div><div> if (is_method(&quot;REGISTER&quot;))</div><div>{</div><div>if(isflagset(FLT_NATS))</div>


<div> {</div><div>setbflag(FLB_NATB);</div><div># uncomment next line to do SIP NAT pinging</div><div> setbflag(FLB_NATSIPPING);</div><div>}</div><div>if (!save(&quot;location&quot;))</div><div> sl_reply_error();</div><div>


<br></div><div>exit;</div><div>}</div><div>}</div><div><br></div><div># USER location service</div><div>route[LOCATION] {</div><div><br></div><div>#!ifdef WITH_SPEEDIAL</div><div># search for short dialing - 2-digit extension</div>


<div> if($rU=~&quot;^[0-9][0-9]$&quot;)</div><div>if(sd_lookup(&quot;speed_dial&quot;))</div><div>route(SIPOUT);</div><div>#!endif</div><div><br></div><div>#!ifdef WITH_ALIASDB</div><div># search in DB-based aliases</div>


<div>if(alias_db_lookup(&quot;dbaliases&quot;))</div><div> route(SIPOUT);</div><div>#!endif</div><div><br></div><div>$avp(oexten) = $rU;</div><div>if (!lookup(&quot;location&quot;)) {</div><div> $var(rc) = $rc;</div><div>


route(TOVOICEMAIL);</div><div>t_newtran();</div><div> switch ($var(rc)) {</div><div>case -1:</div><div>case -3:</div><div> send_reply(&quot;404&quot;, &quot;Not Found&quot;);</div><div>exit;</div><div>case -2:</div><div>

 send_reply(&quot;405&quot;, &quot;Method Not Allowed&quot;);</div>
<div>exit;</div><div>}</div><div> }</div><div><br></div><div># when routing via usrloc, log the missed calls also</div><div>if (is_method(&quot;INVITE&quot;))</div><div> {</div><div>setflag(FLT_ACCMISSED);</div><div>}</div>


<div>}</div><div><br></div><div># Presence server route</div><div>route[PRESENCE] {</div><div>if(!is_method(&quot;PUBLISH|SUBSCRIBE&quot;))</div><div>return;</div><div><br></div><div>#!ifdef WITH_PRESENCE</div><div>if (!t_newtran())</div>


<div>{</div><div>sl_reply_error();</div><div> exit;</div><div>};</div><div><br></div><div>if(is_method(&quot;PUBLISH&quot;))</div><div> {</div><div>handle_publish();</div><div>t_release();</div><div> }</div><div>else</div>


<div>if( is_method(&quot;SUBSCRIBE&quot;))</div><div> {</div><div>handle_subscribe();</div><div>t_release();</div><div> }</div><div>exit;</div><div>#!endif</div><div> # if presence enabled, this part will not be executed</div>


<div>if (is_method(&quot;PUBLISH&quot;) || $rU==$null)</div><div> {</div><div>sl_send_reply(&quot;404&quot;, &quot;Not here&quot;);</div><div>exit;</div><div> }</div><div>return;</div><div>}</div><div><br></div><div># Authentication route</div>


<div>route[AUTH] {</div><div>#!ifdef WITH_AUTH</div><div>if (is_method(&quot;REGISTER&quot;))</div><div>{</div><div># authenticate the REGISTER requests (uncomment to enable auth)</div><div> if (!www_authorize(&quot;$td&quot;, &quot;subscriber&quot;))</div>


<div>{</div><div>www_challenge(&quot;$td&quot;, &quot;0&quot;);</div><div> exit;</div><div>}</div><div><br></div><div>if ($au!=$tU)</div><div> {</div><div>sl_send_reply(&quot;403&quot;,&quot;Forbidden auth ID&quot;);</div>


<div>exit;</div><div> }</div><div>} else {</div><div><br></div><div>#!ifdef WITH_IPAUTH</div><div>if(allow_source_address())</div><div> {</div><div># source IP allowed</div><div>return;</div><div> }</div><div>#!endif</div>


<div><br></div><div># authenticate if from local subscriber</div><div> if (from_uri==myself)</div><div>{</div><div>if (!proxy_authorize(&quot;$fd&quot;, &quot;subscriber&quot;)) {</div><div> proxy_challenge(&quot;$fd&quot;, &quot;0&quot;);</div>


<div>exit;</div><div>}</div><div> if (is_method(&quot;PUBLISH&quot;))</div><div>{</div><div>if ($au!=$fU || $au!=$tU) {</div><div> sl_send_reply(&quot;403&quot;,&quot;Forbidden auth ID&quot;);</div><div>exit;</div><div> }</div>


<div>if ($au!=$rU) {</div><div>sl_send_reply(&quot;403&quot;,&quot;Forbidden R-URI&quot;);</div><div> exit;</div><div>}</div><div>#!ifdef WITH_MULTIDOMAIN</div><div>if ($fd!=$rd) {</div><div> sl_send_reply(&quot;403&quot;,&quot;Forbidden R-URI domain&quot;);</div>


<div>exit;</div><div> }</div><div>#!endif</div><div>} else {</div><div>if ($au!=$fU) {</div><div> sl_send_reply(&quot;403&quot;,&quot;Forbidden auth ID&quot;);</div><div>exit;</div><div> }</div><div>}</div><div><br></div>


<div>consume_credentials();</div><div> # caller authenticated</div><div>} else {</div><div># caller is not local subscriber, then check if it calls</div><div> # a local destination, otherwise deny, not an open relay here</div>


<div>if (!uri==myself)</div><div> {</div><div>sl_send_reply(&quot;403&quot;,&quot;Not relaying&quot;);</div><div>exit;</div><div> }</div><div>}</div><div>}</div><div>#!endif</div><div>return;</div><div>}</div><div><br></div>


<div># Caller NAT detection route</div><div>route[NATDETECT] {</div><div>#!ifdef WITH_NAT</div><div> force_rport();</div><div>if (nat_uac_test(&quot;19&quot;)) {</div><div>if (is_method(&quot;REGISTER&quot;)) {</div><div>


 fix_nated_register();</div><div>} else {</div><div>fix_nated_contact();</div><div> }</div><div>setflag(FLT_NATS);</div><div>}</div><div>#!endif</div><div>return;</div><div>}</div><div><br></div><div># RTPProxy control</div>


<div>route[NATMANAGE] {</div><div>#!ifdef WITH_NAT</div><div>if (is_request()) {</div><div> if(has_totag()) {</div><div>if(check_route_param(&quot;nat=yes&quot;)) {</div><div>setbflag(FLB_NATB);</div><div> }</div><div>}</div>


<div>}</div><div> if (!(isflagset(FLT_NATS) || isbflagset(FLB_NATB)))</div><div>return;</div><div><br></div><div> rtpproxy_manage();</div><div><br></div><div>if (is_request()) {</div><div>if (!has_totag()) {</div><div> add_rr_param(&quot;;nat=yes&quot;);</div>


<div>}</div><div>}</div><div> if (is_reply()) {</div><div>if(isbflagset(FLB_NATB)) {</div><div>fix_nated_contact();</div><div> }</div><div>}</div><div>#!endif</div><div>return;</div><div>}</div><div><br></div><div># Routing to foreign domains</div>


<div>route[SIPOUT] {</div><div>if (!uri==myself)</div><div>{</div><div> append_hf(&quot;P-hint: outbound\r\n&quot;);</div><div>route(RELAY);</div><div>}</div><div>}</div><div><br></div><div># PSTN GW routing</div><div>route[PSTN] {</div>


<div>#!ifdef WITH_PSTN</div><div># check if PSTN GW IP is defined</div><div>if (strempty($sel(cfg_get.pstn.gw_ip))) {</div><div> xlog(&quot;SCRIPT: PSTN rotuing enabled but pstn.gw_ip not defined\n&quot;);</div><div>return;</div>


<div> }</div><div><br></div><div># route to PSTN dialed numbers starting with &#39;+&#39; or &#39;00&#39;</div><div> #     (international format)</div><div># - update the condition to match your dialing rules for PSTN routing</div>


<div> if(!($rU=~&quot;^(\+|00)[1-9][0-9]{3,20}$&quot;))</div><div>return;</div><div><br></div><div> # only local users allowed to call</div><div>if(from_uri!=myself) {</div><div>sl_send_reply(&quot;403&quot;, &quot;Not Allowed&quot;);</div>


<div> exit;</div><div>}</div><div><br></div><div>$ru = &quot;sip:&quot; + $rU + &quot;@&quot; + $sel(cfg_get.pstn.gw_ip);</div><div><br></div><div>route(RELAY);</div><div>exit;</div><div>#!endif</div><div><br></div><div>

return;</div>
<div>}</div><div><br></div><div># XMLRPC routing</div><div>#!ifdef WITH_XMLRPC</div><div>route[XMLRPC] {</div><div># allow XMLRPC from localhost</div><div>if ((method==&quot;POST&quot; || method==&quot;GET&quot;)</div><div>


 &amp;&amp; (src_ip==127.0.0.1)) {</div><div># close connection only for xmlrpclib user agents (there is a bug in</div><div> # xmlrpclib: it waits for EOF before interpreting the response).</div><div>if ($hdr(User-Agent) =~ &quot;xmlrpclib&quot;)</div>


<div> set_reply_close();</div><div>set_reply_no_connect();</div><div>dispatch_rpc();</div><div> exit;</div><div>}</div><div>send_reply(&quot;403&quot;, &quot;Forbidden&quot;);</div><div> exit;</div><div>}</div><div>#!endif</div>


<div><br></div><div># route to voicemail server</div><div>route[TOVOICEMAIL] {</div><div>#!ifdef WITH_VOICEMAIL</div><div> if(!is_method(&quot;INVITE&quot;))</div><div>return;</div><div><br></div><div># check if VoiceMail server IP is defined</div>


<div> if (strempty($sel(cfg_get.voicemail.srv_ip))) {</div><div>xlog(&quot;SCRIPT: VoiceMail rotuing enabled but IP not defined\n&quot;);</div><div> return;</div><div>}</div><div>if($avp(oexten)==$null)</div><div> return;</div>


<div><br></div><div>$ru = &quot;sip:&quot; + $avp(oexten) + &quot;@&quot; + $sel(cfg_get.voicemail.srv_ip)</div><div> + $sel(cfg_get.voicemail.srv_port);</div><div>route(RELAY);</div><div>exit;</div><div>#!endif</div><div>


<br></div><div>return;</div><div>}</div><div><br></div><div># manage outgoing branches</div><div>branch_route[MANAGE_BRANCH] {</div><div> xdbg(&quot;new branch [$T_branch_idx] to $ru\n&quot;);</div><div>route(NATMANAGE);</div>


<div>}</div><div><br></div><div># manage incoming replies</div><div>onreply_route[MANAGE_REPLY] {</div><div>xdbg(&quot;incoming reply\n&quot;);</div><div>if(status=~&quot;[12][0-9][0-9]&quot;)</div><div> route(NATMANAGE);</div>


<div>}</div><div><br></div><div># manage failure routing cases</div><div>failure_route[MANAGE_FAILURE] {</div><div>route(NATMANAGE);</div><div><br></div><div>if (t_is_canceled()) {</div><div>exit;</div><div>}</div><div><br>


</div><div>#!ifdef WITH_BLOCK3XX</div><div># block call redirect based on 3xx replies.</div><div>if (t_check_status(&quot;3[0-9][0-9]&quot;)) {</div><div> t_reply(&quot;404&quot;,&quot;Not found&quot;);</div><div>exit;</div>


<div>}</div><div>#!endif</div><div><br></div><div>#!ifdef WITH_VOICEMAIL</div><div># serial forking</div><div># - route to voicemail on busy or no answer (timeout)</div><div> if (t_check_status(&quot;486|408&quot;)) {</div>


<div>route(TOVOICEMAIL);</div><div>exit;</div><div> }</div><div>#!endif</div><div>}</div><div>--------------------------------------------------------------------------------------------------------------</div><div><br></div>


<div><br></div><div>I hope you can help me. Thanks for your time.</div>