<div dir="ltr"><div><div><div><div><div>We have opensip running with multidomain authentication, now we have purchases SIP trunk from provide to send call to put side country (PSTN)<br><br></div>They gave me Username/Password and IP address of their SIP server<br>
<br></div>I have did following configuration to configure my opensip as UAC<br><br>#### Opensips UAC<br>loadmodule &quot;uac_auth.so&quot;<br>loadmodule &quot;uac_registrant.so&quot;<br>modparam(&quot;uac_registrant&quot;, &quot;hash_size&quot;, 2)<br>
modparam(&quot;uac_registrant&quot;, &quot;timer_interval&quot;, 100)<br>modparam(&quot;uac_registrant&quot;, &quot;db_url&quot;, &quot;mysql://opensips:opensipsrw@localhost/opensips&quot;)<br>modparam(&quot;uac_registrant&quot;, &quot;table_name&quot;, &quot;registrant&quot;)<br>
<br><br></div>My Opensip successfully register on their Trunk<br><br># opensipsctl registrant dump<br>AOR:: sip:testtrunk@65.xxx.xxx.xxx:5065 expires=300<br>        state:: REGISTERED_STATE<br>        last_register_sent:: Fri Aug 22 02:18:14 2014<br>
        registration_t_out:: Fri Aug 22 02:21:35 2014<br>        registrar:: sip:65.xxx.xxx.xxx.xxx:5065<br>        binding:: sip:testtrunk@65.xxx.xxx.xxx:5065<br>        dst_IP:: IPv4 ip=xxx.xxx.xxx.xxx<br><br><br></div>
Now big question is how do i use this trunk in my routing script, After google i came up with following configuration but it is not working, It is not rewriting host part. <br><br> # account only INVITEs<br>        if (is_method(&quot;INVITE&quot;)) {<br>
<br>                setflag(ACC_DO); # do accounting<br>                $avp(can_uri) = $ru;<br>             <br>                      };<br><br>        }<br>        # PSTN Testing<br>        if  ( uri=~&quot;^sip:16465352727@.*&quot;) {<br>
        route(3);<br>        exit;<br>        };<br><br>...<br>...<br></div>route[3] {<br><br>if (method==&quot;INVITE&quot;)<br> {<br>  if (uri=~&quot;^sip:16465352727@.*&quot;) {<br><br>        rewritehostport(&quot;65.xxx.xxx.xxx:5065&quot;);<br>
        xlog(&quot;Redirecting to SIP Provider.. $ru\n&quot;);<br>    exit;<br>  };<br>};<br>}<br><br><div><div><br></div></div></div>