Hi,<br><br>I've configured OpenSIPs using Nathelper module and rtpproxy. the problem I'm facing is when I try to register my softphone, it got registered but as I issue the command opensipsctl ul show, in contact header the IP is private not public. The configuration of OpenSIPs is listed down below;<br>
<br><br>loadmodule "dispatcher.so"<br>loadmodule "avpops.so"<br>loadmodule "permissions.so"<br>loadmodule "aaa_radius.so"<br>loadmodule "auth_aaa.so"<br>#loadmodule "auth_diameter.so"<br>
loadmodule "nathelper.so"<br><br>#--------------------------------Settings For Radius-------------------------------------<br>#modparam("auth_diameter", "diameter_client_host", "localhost")<br>
modparam("aaa_radius", "radius_config","/usr/local/etc/radiusclient-ng/radiusclient.conf")<br>modparam("acc", "aaa_url", "radius:/usr/local/etc/radiusclient-ng/radiusclient.conf")<br>
modparam("acc", "aaa_flag", 2)<br>modparam("acc", "aaa_missed_flag", 3)<br>modparam("acc", "aaa_extra", "User-Name=$Au; \<br> Calling-Station-Id=$from; \<br>
Called-Station-Id=$to; \<br> Sip-Translated-Request-URI=$ruri; \<br> Sip-RPid=$avp(s:rpid); \<br> Source-IP=$si; \<br>
Source-Port=$sp; \<br> Canonical-URI=$avp(s:can_uri); \<br> Billing-Party=$avp(s:billing_party); \<br> Divert-Reason=$avp(s:divert_reason); \<br>
X-RTP-Stat=$hdr(X-RTP-Stat); \<br> Contact=$hdr(contact); \<br> Event=$hdr(event); \<br> SIP-Proxy-IP=$avp(s:sip_proxy_ip); \<br>
ENUM-TLD=$avp(s:enum_tld)")<br><br>modparam("auth_aaa","aaa_url","radius:/usr/local/etc/radiusclient-ng/radiusclient.conf")<br>modparam("auth", "rpid_prefix", "<sip:")<br>
modparam("auth", "rpid_suffix", "@<a href="http://77.66.2.137">77.66.2.137</a>>;screen=yes;privacy=off")<br>#modparam("auth", "rpid_suffix", "@<a href="http://203.215.179.54">203.215.179.54</a>>;screen=yes;privacy=off")<br>
modparam("auth", "rpid_avp", "$avp(s:rpid)")<br>#modparam("uri","service_type",10)<br><br><br># ----------------- setting module-specific parameters ---------------<br><br>
modparam("dispatcher", "db_url", "mysql://opensips:opensipsrw@localhost/opensips")<br>modparam("permissions", "db_url", "mysql://opensips:opensipsrw@localhost/opensips")<br>
<br>#----------------- setting NAT module parameters ---------------------<br><br>modparam("nathelper","ping_nated_only",1)<br>modparam("nathelper", "natping_interval", 30)<br>modparam("nathelper","natping_processes",1)<br>
modparam("nathelper","rtpproxy_sock","udp:<a href="http://127.0.0.1:7890">127.0.0.1:7890</a>")<br>#modparam("nathelper","rtpproxy_sock"," ")<br>modparam("nathelper","received_avp","$avp(i:42)")<br>
#modparam("nathelper", "sipping_bflag", 7)<br>modparam("usrloc", "nat_bflag", 6)<br><br><br>route{<br><br> if (!mf_process_maxfwd_header("10")) {<br> sl_send_reply("483","Too Many Hops");<br>
exit;<br> }<br><br> #NAT detection<br> log("######################################### Go to Route 3 for NAT Detection #####################################");<br> route(3);<br>
<br> if (has_totag()) {<br> if (loose_route()) {<br> if (is_method("BYE")) {<br> setflag(1); # do accounting ...<br> setflag(3); # ... even if the transaction fails<br>
} else if (is_method("INVITE")) {<br> record_route();<br> }<br> route(1);<br> } else {<br> if ( is_method("ACK") ) {<br>
if ( t_check_trans() ) {<br> # non loose-route, but stateful ACK; must be an ACK after<br> # a 487 or e.g. 404 from upstream server<br>
t_relay();<br> exit;<br> } else {<br> # ACK without matching transaction -><br>
# ignore and discard<br> exit;<br> }<br> }<br> sl_send_reply("404","Not here");<br>
}<br> exit;<br> }<br><br> #initial requests<br><br> # CANCEL processing<br> if (is_method("CANCEL"))<br> {<br> if (t_check_trans())<br>
t_relay();<br> exit;<br> }<br> t_check_trans();<br><br><br> # preloaded route checking<br> if (loose_route()) {<br> xlog("L_ERR",<br>
"Attempt to route with preloaded Route's [$fu/$tu/$ru/$ci]");<br> if (!is_method("ACK"))<br> sl_send_reply("403","Preload Route denied");<br>
exit;<br> }<br><br> # record routing<br> if (!is_method("REGISTER|MESSAGE"))<br> record_route();<br><br> $avp(s:checksrc) = check_source_address("0");<br>
log("###########################################################################################\n");<br> xlog("Check Source Address from Address TABLE Where Value 1 is Equal to True: $(avp(s:checksrc))\n");<br>
log("###########################################################################################\n");<br><br><br> # account only INVITEs<br> if (check_source_address("0")) {<br> if (is_method("INVITE")){<br>
log("#################### INVITE FUNCTION 1 ####################");<br> if(uri=~"^sip:4569918004@*"){<br> log("###################### CALL From DID And Reroute to Asterisk ######################");<br>
rewritehostport("<a href="http://11.22.33.45:5060">11.22.33.45:5060</a>");<br> force_rtp_proxy("l");<br> setflag(2); # do accounting<br>
}<br> }<br> }<br> else<br> {<br> log("################CALL REJECTED##################");<br> #t_reply("405","Forbidden");<br>
}<br><br> if (!uri==myself)<br> {<br> append_hf("P-hint: outbound\r\n");<br> route(1);<br> }<br><br> if(uri==myself)<br> {<br> log("########################################### URI == MYSELF ########################################");<br>
<br> if(method=="REGISTER")<br> {<br> #fix_nated_register();<br> #force_rport();<br> route(2);<br> }<br>
<br> append_hf("P-hint: usrloc applied\r\n");<br><br> }<br><br><br> if (is_method("PUBLISH"))<br> {<br> sl_send_reply("503", "Service Unavailable");<br>
exit;<br> }<br><br><br> if (is_method("REGISTER"))<br> {<br> route(2);<br> }<br><br> if ($rU==NULL) {<br> # request with no Username in RURI<br>
sl_send_reply("484","Address Incomplete");<br> exit;<br> }<br><br> # apply DB based aliases (uncomment to enable)<br> ##alias_db_lookup("dbaliases");<br>
<br> # do lookup with method filtering<br> if (!lookup("location","m")) {<br> switch ($retcode) {<br> case -1:<br> log("############################# LOOKUP LOCATION FLAG -1 PASS #################################");<br>
#ds_select_dst("1","4");<br><br> log("############################# DO ACCOUNTING ON RADIUS ######################################");<br>
setflag(2);<br><br> force_rtp_proxy();<br> log("############################# SEND CALL TO ASTERISK #######################################");<br>
rewritehostport("<a href="http://11.22.33.45:5060">11.22.33.45:5060</a>");<br><br> #forward();<br> log("############################# CALL IS GOING IN STATEFULL MANNER ############################");<br>
t_relay();<br><br> log("############################# CALL ROUTING TO ROUTE 1 ######################################");<br> route(1);<br>
exit;<br><br> case -3:<br> log("############################ LOOKUP LOCATION FLAG -3 PASS #################################");<br>
t_newtran();<br> t_reply("404", "Not Found");<br> exit;<br> case -2:<br> log("############################ LOOKUP LOCATION FLAG -2 PASS #################################");<br>
sl_send_reply("405", "Method Not Allowed");<br> exit;<br> }<br> }<br><br> # when routing via usrloc, log the missed calls also<br>
force_rtp_proxy();<br> setflag(2);<br><br> route(1);<br>}<br><br>route[1] {<br> # for INVITEs enable some additional helper routes<br> if (is_method("INVITE")) {<br><br> log("################################ INVITE ROUTE 1 Function ##################################");<br>
#force_rtp_proxy("l");<br> t_on_branch("2");<br> t_on_reply("2");<br> t_on_failure("1");<br> }<br><br> if (subst_uri('/(sip:.*);nat=yes/\1/')){<br>
<br> log("################################ IF SUBSTR CONTAINS NAT=YES ################################");<br> setbflag(6);<br> };<br><br> if (isflagset(5)||isbflagset(6)) {<br>
<br> log("################################ CHECK FLAGSET AND ROUTE TO 4 ###############################");<br> route(4);<br> }<br><br><br> if (!t_relay()) {<br> sl_reply_error();<br>
};<br> exit;<br>}<br><br>route[2]<br>{<br> log("######################################## AAA-REGISTRATION #######################################");<br> if (!aaa_www_authorize("11.22.33.44"))<br>
{<br> www_challenge("11.22.33.44", "1");<br> return;<br> # #exit;<br> }<br> #else<br> #{<br> # t_reply("405","UnAuhorized");<br>
# exit();<br> #}<br><br> if(isflagset(5))<br> {<br> log("################################### IF FLAG SET IS 5 ##################################");<br> # set branch flag -- when someone will call this user<br>
# the INVITE will have branch flag 6 set after lookup("location")<br> setbflag(6);<br> # if you want OPTIONS natpings uncomment next<br> # setbflag(7);<br>
}<br><br><br> if (!save("location"))<br> sl_reply_error();<br><br> exit;<br>}<br><br>route[3]<br>{<br> log("################################ FUNCTION ROUTE 3 NAT DETECTION ################################");<br>
<br> force_rport();<br> if (nat_uac_test("19")) {<br> if (method=="REGISTER") {<br> fix_nated_register();<br> } else {<br> fix_nated_contact();<br>
};<br> setflag(5);<br> };<br>}<br><br>route[4]<br>{<br> log("################################ FUNCTION ROUTE 4 RTP PROXY ################################");<br> if (is_method("BYE")) {<br>
unforce_rtp_proxy();<br> } else if (is_method("INVITE")){<br> force_rtp_proxy();<br> #t_on_failure("2");<br> t_on_failure("3");<br>
};<br> if (isflagset(5))<br> search_append('Contact:.*sip:[^>[:cntrl:]]*', ';nat=yes');<br> #t_on_reply("1");<br> t_on_reply("3");<br>}<br>
<br><br><br>branch_route[2] {<br> xlog("new branch at $ru\n");<br>}<br><br><br>onreply_route[2] {<br> xlog("incoming reply\n");<br>}<br><br><br>failure_route[1] {<br> if (t_was_cancelled()) {<br>
exit;<br> }<br>}<br><br>failure_route[3] {<br><br> log("################################ FAILURE ROUTE 3 FUNCTION ################################");<br><br> if (isbflagset(6) || isflagset(5)) {<br>
unforce_rtp_proxy();<br> }<br>}<br><br>onreply_route[3] {<br><br> log("################################ ONREPLY ROUTE 3 FUNCTION ################################");<br><br> if ((isflagset(5) || isbflagset(6)) && status=~"(183)|(2[0-9][0-9])") {<br>
force_rtp_proxy();<br> }<br> search_append('Contact:.*sip:[^>[:cntrl:]]*', ';nat=yes');<br><br> if (isbflagset(6)) {<br> fix_nated_contact();<br> }<br>
exit;<br>}<br><br><br>Kindly assist me in my script to sort out this problem, (please point out what other changes or addition function do I required for it). Note My OpenSIPs is hosted on public IP and on different network and my UAC is at private IP. Please advise.<br clear="all">
<br><br>-- <br>Regards,<br><br>Ahmed Munir<br><br><br>