Hi,<br><br>I&#39;ve configured OpenSIPs using Nathelper module and rtpproxy. the problem I&#39;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 &quot;dispatcher.so&quot;<br>loadmodule &quot;avpops.so&quot;<br>loadmodule &quot;permissions.so&quot;<br>loadmodule &quot;aaa_radius.so&quot;<br>loadmodule &quot;auth_aaa.so&quot;<br>#loadmodule &quot;auth_diameter.so&quot;<br>
loadmodule &quot;nathelper.so&quot;<br><br>#--------------------------------Settings For Radius-------------------------------------<br>#modparam(&quot;auth_diameter&quot;, &quot;diameter_client_host&quot;, &quot;localhost&quot;)<br>
modparam(&quot;aaa_radius&quot;, &quot;radius_config&quot;,&quot;/usr/local/etc/radiusclient-ng/radiusclient.conf&quot;)<br>modparam(&quot;acc&quot;, &quot;aaa_url&quot;, &quot;radius:/usr/local/etc/radiusclient-ng/radiusclient.conf&quot;)<br>
modparam(&quot;acc&quot;, &quot;aaa_flag&quot;, 2)<br>modparam(&quot;acc&quot;, &quot;aaa_missed_flag&quot;, 3)<br>modparam(&quot;acc&quot;, &quot;aaa_extra&quot;,    &quot;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)&quot;)<br><br>modparam(&quot;auth_aaa&quot;,&quot;aaa_url&quot;,&quot;radius:/usr/local/etc/radiusclient-ng/radiusclient.conf&quot;)<br>modparam(&quot;auth&quot;, &quot;rpid_prefix&quot;, &quot;&lt;sip:&quot;)<br>
modparam(&quot;auth&quot;, &quot;rpid_suffix&quot;, &quot;@<a href="http://77.66.2.137">77.66.2.137</a>&gt;;screen=yes;privacy=off&quot;)<br>#modparam(&quot;auth&quot;, &quot;rpid_suffix&quot;, &quot;@<a href="http://203.215.179.54">203.215.179.54</a>&gt;;screen=yes;privacy=off&quot;)<br>
modparam(&quot;auth&quot;, &quot;rpid_avp&quot;, &quot;$avp(s:rpid)&quot;)<br>#modparam(&quot;uri&quot;,&quot;service_type&quot;,10)<br><br><br># ----------------- setting module-specific parameters ---------------<br><br>
modparam(&quot;dispatcher&quot;, &quot;db_url&quot;, &quot;mysql://opensips:opensipsrw@localhost/opensips&quot;)<br>modparam(&quot;permissions&quot;, &quot;db_url&quot;, &quot;mysql://opensips:opensipsrw@localhost/opensips&quot;)<br>
<br>#----------------- setting NAT module parameters ---------------------<br><br>modparam(&quot;nathelper&quot;,&quot;ping_nated_only&quot;,1)<br>modparam(&quot;nathelper&quot;, &quot;natping_interval&quot;, 30)<br>modparam(&quot;nathelper&quot;,&quot;natping_processes&quot;,1)<br>
modparam(&quot;nathelper&quot;,&quot;rtpproxy_sock&quot;,&quot;udp:<a href="http://127.0.0.1:7890">127.0.0.1:7890</a>&quot;)<br>#modparam(&quot;nathelper&quot;,&quot;rtpproxy_sock&quot;,&quot; &quot;)<br>modparam(&quot;nathelper&quot;,&quot;received_avp&quot;,&quot;$avp(i:42)&quot;)<br>
#modparam(&quot;nathelper&quot;, &quot;sipping_bflag&quot;, 7)<br>modparam(&quot;usrloc&quot;, &quot;nat_bflag&quot;, 6)<br><br><br>route{<br><br>        if (!mf_process_maxfwd_header(&quot;10&quot;)) {<br>                sl_send_reply(&quot;483&quot;,&quot;Too Many Hops&quot;);<br>
                exit;<br>        }<br><br>        #NAT detection<br>        log(&quot;######################################### Go to Route 3 for NAT Detection #####################################&quot;);<br>        route(3);<br>
<br>        if (has_totag()) {<br>                if (loose_route()) {<br>                        if (is_method(&quot;BYE&quot;)) {<br>                                setflag(1); # do accounting ...<br>                                setflag(3); # ... even if the transaction fails<br>
                        } else if (is_method(&quot;INVITE&quot;)) {<br>                                record_route();<br>                        }<br>                        route(1);<br>                } else {<br>                        if ( is_method(&quot;ACK&quot;) ) {<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 -&gt;<br>
                                        # ignore and discard<br>                                        exit;<br>                                }<br>                        }<br>                        sl_send_reply(&quot;404&quot;,&quot;Not here&quot;);<br>
                }<br>                exit;<br>        }<br><br>        #initial requests<br><br>        # CANCEL processing<br>        if (is_method(&quot;CANCEL&quot;))<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(&quot;L_ERR&quot;,<br>
                &quot;Attempt to route with preloaded Route&#39;s [$fu/$tu/$ru/$ci]&quot;);<br>                if (!is_method(&quot;ACK&quot;))<br>                        sl_send_reply(&quot;403&quot;,&quot;Preload Route denied&quot;);<br>
                exit;<br>        }<br><br>        # record routing<br>        if (!is_method(&quot;REGISTER|MESSAGE&quot;))<br>                record_route();<br><br>        $avp(s:checksrc) = check_source_address(&quot;0&quot;);<br>
        log(&quot;###########################################################################################\n&quot;);<br>        xlog(&quot;Check Source Address from Address TABLE Where Value 1 is Equal to True: $(avp(s:checksrc))\n&quot;);<br>
        log(&quot;###########################################################################################\n&quot;);<br><br><br>        # account only INVITEs<br>        if (check_source_address(&quot;0&quot;)) {<br>                if (is_method(&quot;INVITE&quot;)){<br>
                        log(&quot;#################### INVITE FUNCTION 1 ####################&quot;);<br>                        if(uri=~&quot;^sip:4569918004@*&quot;){<br>                                log(&quot;###################### CALL From DID And Reroute to Asterisk ######################&quot;);<br>
                                rewritehostport(&quot;<a href="http://11.22.33.45:5060">11.22.33.45:5060</a>&quot;);<br>                                force_rtp_proxy(&quot;l&quot;);<br>                                setflag(2); # do accounting<br>
                        }<br>                }<br>        }<br>        else<br>        {<br>               log(&quot;################CALL REJECTED##################&quot;);<br>               #t_reply(&quot;405&quot;,&quot;Forbidden&quot;);<br>
        }<br><br>        if (!uri==myself)<br>        {<br>                append_hf(&quot;P-hint: outbound\r\n&quot;);<br>                route(1);<br>        }<br><br>        if(uri==myself)<br>        {<br>                log(&quot;########################################### URI == MYSELF  ########################################&quot;);<br>
<br>                if(method==&quot;REGISTER&quot;)<br>                {<br>                        #fix_nated_register();<br>                        #force_rport();<br>                        route(2);<br>                }<br>
<br>                append_hf(&quot;P-hint: usrloc applied\r\n&quot;);<br><br>        }<br><br><br>        if (is_method(&quot;PUBLISH&quot;))<br>        {<br>                sl_send_reply(&quot;503&quot;, &quot;Service Unavailable&quot;);<br>
                exit;<br>        }<br><br><br>        if (is_method(&quot;REGISTER&quot;))<br>        {<br>                route(2);<br>        }<br><br>        if ($rU==NULL) {<br>                # request with no Username in RURI<br>
                sl_send_reply(&quot;484&quot;,&quot;Address Incomplete&quot;);<br>                exit;<br>        }<br><br>        # apply DB based aliases (uncomment to enable)<br>        ##alias_db_lookup(&quot;dbaliases&quot;);<br>
<br>        # do lookup with method filtering<br>        if (!lookup(&quot;location&quot;,&quot;m&quot;)) {<br>                switch ($retcode) {<br>                        case -1:<br>                                log(&quot;############################# LOOKUP LOCATION FLAG -1 PASS #################################&quot;);<br>
                                #ds_select_dst(&quot;1&quot;,&quot;4&quot;);<br><br>                                log(&quot;############################# DO ACCOUNTING ON RADIUS ######################################&quot;);<br>
                                setflag(2);<br><br>                                force_rtp_proxy();<br>                                log(&quot;############################# SEND CALL TO ASTERISK  #######################################&quot;);<br>
                                rewritehostport(&quot;<a href="http://11.22.33.45:5060">11.22.33.45:5060</a>&quot;);<br><br>                                #forward();<br>                                log(&quot;############################# CALL IS GOING IN STATEFULL MANNER ############################&quot;);<br>
                                t_relay();<br><br>                                log(&quot;############################# CALL ROUTING TO ROUTE 1 ######################################&quot;);<br>                                route(1);<br>
                                exit;<br><br>                        case -3:<br>                                log(&quot;############################ LOOKUP LOCATION FLAG -3 PASS #################################&quot;);<br>
                                t_newtran();<br>                                t_reply(&quot;404&quot;, &quot;Not Found&quot;);<br>                                exit;<br>                        case -2:<br>                                log(&quot;############################ LOOKUP LOCATION FLAG -2 PASS #################################&quot;);<br>
                                sl_send_reply(&quot;405&quot;, &quot;Method Not Allowed&quot;);<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(&quot;INVITE&quot;)) {<br><br>                log(&quot;################################ INVITE ROUTE 1 Function ##################################&quot;);<br>
                #force_rtp_proxy(&quot;l&quot;);<br>                t_on_branch(&quot;2&quot;);<br>                t_on_reply(&quot;2&quot;);<br>                t_on_failure(&quot;1&quot;);<br>        }<br><br>        if (subst_uri(&#39;/(sip:.*);nat=yes/\1/&#39;)){<br>
<br>                log(&quot;################################  IF SUBSTR CONTAINS NAT=YES ################################&quot;);<br>                setbflag(6);<br>        };<br><br>        if (isflagset(5)||isbflagset(6)) {<br>
<br>                log(&quot;################################  CHECK FLAGSET AND ROUTE TO 4 ###############################&quot;);<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(&quot;######################################## AAA-REGISTRATION #######################################&quot;);<br>        if (!aaa_www_authorize(&quot;11.22.33.44&quot;))<br>
        {<br>                www_challenge(&quot;11.22.33.44&quot;, &quot;1&quot;);<br>                 return;<br>                #    #exit;<br>        }<br>        #else<br>        #{<br>        #       t_reply(&quot;405&quot;,&quot;UnAuhorized&quot;);<br>
        #       exit();<br>        #}<br><br>        if(isflagset(5))<br>        {<br>               log(&quot;###################################  IF FLAG SET IS 5 ##################################&quot;);<br>                # set branch flag -- when someone will call this user<br>
                # the INVITE will have branch flag 6 set after lookup(&quot;location&quot;)<br>                setbflag(6);<br>                # if you want OPTIONS natpings uncomment next<br>                # setbflag(7);<br>
        }<br><br><br>        if (!save(&quot;location&quot;))<br>                sl_reply_error();<br><br>        exit;<br>}<br><br>route[3]<br>{<br>        log(&quot;################################ FUNCTION ROUTE 3 NAT DETECTION  ################################&quot;);<br>
<br>        force_rport();<br>        if (nat_uac_test(&quot;19&quot;)) {<br>                if (method==&quot;REGISTER&quot;) {<br>                        fix_nated_register();<br>                } else {<br>                        fix_nated_contact();<br>
                };<br>        setflag(5);<br>        };<br>}<br><br>route[4]<br>{<br>        log(&quot;################################ FUNCTION ROUTE 4 RTP PROXY  ################################&quot;);<br>        if (is_method(&quot;BYE&quot;)) {<br>
                unforce_rtp_proxy();<br>        } else if (is_method(&quot;INVITE&quot;)){<br>                force_rtp_proxy();<br>                #t_on_failure(&quot;2&quot;);<br>                t_on_failure(&quot;3&quot;);<br>
        };<br>        if (isflagset(5))<br>                search_append(&#39;Contact:.*sip:[^&gt;[:cntrl:]]*&#39;, &#39;;nat=yes&#39;);<br>        #t_on_reply(&quot;1&quot;);<br>        t_on_reply(&quot;3&quot;);<br>}<br>
<br><br><br>branch_route[2] {<br>        xlog(&quot;new branch at $ru\n&quot;);<br>}<br><br><br>onreply_route[2] {<br>        xlog(&quot;incoming reply\n&quot;);<br>}<br><br><br>failure_route[1] {<br>        if (t_was_cancelled()) {<br>
                exit;<br>        }<br>}<br><br>failure_route[3] {<br><br>        log(&quot;################################ FAILURE ROUTE 3 FUNCTION  ################################&quot;);<br><br>        if (isbflagset(6) || isflagset(5)) {<br>
                unforce_rtp_proxy();<br>        }<br>}<br><br>onreply_route[3] {<br><br>        log(&quot;################################ ONREPLY ROUTE 3 FUNCTION  ################################&quot;);<br><br>        if ((isflagset(5) || isbflagset(6)) &amp;&amp; status=~&quot;(183)|(2[0-9][0-9])&quot;) {<br>
                force_rtp_proxy();<br>        }<br>        search_append(&#39;Contact:.*sip:[^&gt;[:cntrl:]]*&#39;, &#39;;nat=yes&#39;);<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>