<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 "uac_auth.so"<br>loadmodule "uac_registrant.so"<br>modparam("uac_registrant", "hash_size", 2)<br>
modparam("uac_registrant", "timer_interval", 100)<br>modparam("uac_registrant", "db_url", "mysql://opensips:opensipsrw@localhost/opensips")<br>modparam("uac_registrant", "table_name", "registrant")<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("INVITE")) {<br>
<br> setflag(ACC_DO); # do accounting<br> $avp(can_uri) = $ru;<br> <br> };<br><br> }<br> # PSTN Testing<br> if ( uri=~"^sip:16465352727@.*") {<br>
route(3);<br> exit;<br> };<br><br>...<br>...<br></div>route[3] {<br><br>if (method=="INVITE")<br> {<br> if (uri=~"^sip:16465352727@.*") {<br><br> rewritehostport("65.xxx.xxx.xxx:5065");<br>
xlog("Redirecting to SIP Provider.. $ru\n");<br> exit;<br> };<br>};<br>}<br><br><div><div><br></div></div></div>