<html>
  <head>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    Hello Sammy,<br>
    The default kamailio.cfg was quite intimidating for me while trying
    to read it, so I got a simpler one that just proxies all requests to
    a backend PBX and started from there.<br>
    Here's my current configuration file (Public IP masked):<br>
    #!KAMAILIO<br>
    <br>
    #!define IPADDRESS "X.X.X.X"<br>
    <br>
    #!define FLAG_FROM_SWITCH 1<br>
    #!define FLAG_FROM_USER 2<br>
    <br>
    #!define NODE_FAILURE 100<br>
    mpath = "/usr/lib/x86_64-linux-gnu/kamailio/modules"<br>
    listen = "X.X.X.X"<br>
    <br>
    # ------------------ module loading
    ----------------------------------<br>
    loadmodule "mi_fifo.so"<br>
    loadmodule "tm.so"<br>
    loadmodule "rr.so"<br>
    loadmodule "pv.so"<br>
    loadmodule "sl.so"<br>
    loadmodule "maxfwd.so"<br>
    loadmodule "nathelper.so"<br>
    loadmodule "textops.so"<br>
    loadmodule "sdpops.so"<br>
    loadmodule "siputils.so"<br>
    loadmodule "xlog.so"<br>
    loadmodule "sanity.so"<br>
    loadmodule "path.so"<br>
    loadmodule "dispatcher.so"<br>
    loadmodule "usrloc.so"<br>
    <br>
    # ----------------- setting module-specific parameters
    ---------------<br>
    modparam("mi_fifo", "fifo_name", "/var/run/kamailio/kamailio_fifo")<br>
    modparam("nathelper|registrar", "received_avp", "$avp(s:rcv)")<br>
    modparam("dispatcher", "dst_avp", "$avp(AVP_DST)")<br>
    modparam("dispatcher", "grp_avp", "$avp(GRP_DST)")<br>
    modparam("dispatcher", "cnt_avp", "$avp(CNT_DST)")<br>
    modparam("dispatcher", "ds_ping_method", "OPTIONS")<br>
    modparam("dispatcher", "ds_ping_interval", 3)<br>
    modparam("dispatcher", "ds_probing_threshhold", 1)<br>
    modparam("dispatcher", "ds_probing_mode", 1)<br>
    # -------------------------  request routing logic
    -------------------<br>
    # main routing logic<br>
    <br>
    route {<br>
            # Handle insane requests<br>
            route(SANITY_CHECK);<br>
    <br>
            # CANCEL processing<br>
            if (is_method("CANCEL")) {<br>
                    if (t_check_trans()) {<br>
                            t_relay();<br>
                    }<br>
                    exit;<br>
            }<br>
    <br>
            # Determine where the requests are coming from<br>
            route(CHECK_SOURCE_IP);<br>
            <br>
            # Handle NAT<br>
            route(NAT_DETECT);<br>
    <br>
            # Handle existing SIP dialogs<br>
            route(WITHINDLG);<br>
    <br>
            # Process new SIP dialogs below<br>
            if (is_method("INVITE|REFER")) {<br>
                    record_route();<br>
            }<br>
           <br>
            if (is_method("REGISTER")) {<br>
                add_path();<br>
            }<br>
    <br>
            if (isflagset(FLAG_FROM_SWITCH)) {<br>
                    # don't send INVITE from SWITCH back to SWITCH, set
    reply route to handle NAT and forward them along<br>
                    t_on_reply("EXTERNAL_REPLY");<br>
            } else {<br>
                    # Route to one of the switches<br>
                    #route(TO_SWITCH_NODE);<br>
                   if(!ds_select_dst("1", "1")) {<br>
                       sl_send_reply("503", "No route available");<br>
                       exit;<br>
                   }<br>
            }<br>
    <br>
            route(RELAY);<br>
    }<br>
    <br>
    # Failover gracefully<br>
    route[TO_SWITCH_NODE] {<br>
        ds_select_dst("1", "1");<br>
        t_on_failure(NODE_FAILURE);<br>
        t_relay();<br>
        exit();<br>
    }<br>
    <br>
    failure_route[NODE_FAILURE] {<br>
        ds_mark_dst("p");<br>
        ds_next_dst();<br>
        t_on_failure(NODE_FAILURE);<br>
        t_relay();<br>
    }<br>
    <br>
    route[SANITY_CHECK]<br>
    {<br>
            if (!sanity_check()) {<br>
                    exit;<br>
            }<br>
    <br>
            if (!mf_process_maxfwd_header("10")) {<br>
                    send_reply("483", "Too Many Hops");<br>
                    exit;<br>
            }<br>
    <br>
            if ($ua == "friendly-scanner" ||<br>
                    $ua == "sundayddr" ||<br>
                    $ua =~ "sipcli" ) {<br>
                    exit;<br>
            }<br>
    <br>
            if ($si == IPADDRESS) {<br>
                    exit;<br>
            }<br>
    <br>
    }<br>
    <br>
    <br>
    route[CHECK_SOURCE_IP]<br>
    {<br>
            if (ds_is_from_list("1")) {<br>
                    setflag(FLAG_FROM_SWITCH);<br>
            } else {<br>
                    setflag(FLAG_FROM_USER);<br>
            }<br>
    }<br>
    <br>
    # Handle requests within SIP dialogs<br>
    route[WITHINDLG]<br>
    {<br>
            if (has_totag()) {<br>
                    # sequential request withing a dialog should<br>
                    # take the path determined by record-routing<br>
                    #lookup("location");<br>
                    if (loose_route()) {<br>
                            route(RELAY);<br>
                    } else {<br>
                            if (is_method("NOTIFY")) {<br>
                                    route(RELAY);<br>
                            }<br>
                            if (is_method("SUBSCRIBE") && uri ==
    myself) {<br>
                                    # in-dialog subscribe requests<br>
                                    exit;<br>
                            }<br>
                            if (is_method("ACK")) {<br>
                                    if (t_check_trans()) {<br>
                                            # no loose-route, but
    stateful ACK;<br>
                                            # must be an ACK after a 487<br>
                                            # or e.g. 404 from upstream
    server<br>
                                            t_relay();<br>
                                            exit;<br>
                                    } else {<br>
                                            # ACK without matching
    transaction ... ignore and discard<br>
                                            exit;<br>
                                    }<br>
                            }<br>
                            sl_send_reply("404","Not here");<br>
                    }<br>
                    exit;<br>
            }<br>
    }<br>
    <br>
    onreply_route[EXTERNAL_REPLY]<br>
    {<br>
            route(NAT_TEST_AND_CORRECT);<br>
    }<br>
    <br>
    <br>
    route[NAT_TEST_AND_CORRECT]<br>
    {<br>
            if (nat_uac_test("19")) {<br>
                    if (is_method("REGISTER")) {<br>
                            fix_nated_register();<br>
                    } else {<br>
                            fix_nated_contact();<br>
                    }<br>
                    force_rport();<br>
            }<br>
            if (has_body("application/sdp") &&
    nat_uac_test("8")) {<br>
                    fix_nated_sdp("10");<br>
            }<br>
    }<br>
    <br>
    route[RELAY]<br>
    {<br>
            if (!t_relay()) {<br>
                xlog("L_WARN", "RELAY failed!\n");<br>
                    sl_reply_error();<br>
            }<br>
            exit;<br>
    }<br>
    <br>
    route[NAT_DETECT] {<br>
        force_rport();<br>
        if(nat_uac_test("19")) {<br>
            if(is_method("REGISTER")) {<br>
                fix_nated_register();<br>
                add_path_received();<br>
                #save("location");<br>
            } else {<br>
                # Disabled, maybe unnecessary<br>
    #           if(is_first_hop())<br>
    #               set_contact_alias();<br>
                fix_nated_contact();<br>
            }<br>
    <br>
            if (sdp_content()) {<br>
                fix_nated_sdp("10");<br>
            }<br>
        }<br>
        return;<br>
    }<br>
    <br>
    Regards,<br>
    Iskren<br>
    <br>
    <div class="moz-cite-prefix">On 05/05/17 16:36, SamyGo wrote:<br>
    </div>
    <blockquote
cite="mid:CAJUJwtiVuEb6zw7VUW-yi8WahoHre4-eMH56HCRYj4fApSKL9g@mail.gmail.com"
      type="cite">
      <div dir="ltr">Hi,<br>
        Can you share the config file. Seems you've made changes to
        configuration file. Using save("location") w/o any
        authentication above it will result in anyone getting 200OK for
        a REGISTER. 
        <div><br>
        </div>
        <div>Looking at the config will help point you to the right way.</div>
        <div><br>
        </div>
        <div>Regards,</div>
        <div>Sammy</div>
        <div><br>
        </div>
      </div>
      <div class="gmail_extra"><br>
        <div class="gmail_quote">On Fri, May 5, 2017 at 10:56 AM, Iskren
          Hadzhinedev <span dir="ltr"><<a moz-do-not-send="true"
              href="mailto:iskren.hadzhinedev@ikiji.com" target="_blank">iskren.hadzhinedev@ikiji.com</a>></span>
          wrote:<br>
          <blockquote class="gmail_quote" style="margin:0 0 0
            .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi list!<br>
            <br>
            I'm using kamailio 4.2 for load-balancing and failover via
            dispatcher, but I'm having some NAT related issues and I was
            hoping that someone might point me in the right direction.<br>
            My setup is the following:<br>
            <br>
            PSTN - PBX - kamailio - NAT - client<br>
            <br>
            Calls from the NATed client to PSTN and/or PBX features
            (e.g. voicemail) work just fine.<br>
            However, when a call comes from PSTN to the client, kamailio
            sends the INVITE to the client's RFC1918 IP and I can't
            figure out how to send it to the correct destination. I
            tried loading the registrar and usrloc modules and used
            save("location") during REGISTER and lookup("location") just
            before loose_route(), but the end result was that kamailio
            replied to REGISTERs with any username/password with a 200
            OK and the endpoints never registered with the PBX.<br>
            I can attach the config file if that will help.<br>
            <br>
            Thanks for all input in advance!<br>
            <br>
            Regards,<br>
            Iskren<br>
            <br>
            ______________________________<wbr>_________________<br>
            Kamailio (SER) - Users Mailing List<br>
            <a moz-do-not-send="true"
              href="mailto:sr-users@lists.kamailio.org" target="_blank">sr-users@lists.kamailio.org</a><br>
            <a moz-do-not-send="true"
              href="https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users"
              rel="noreferrer" target="_blank">https://lists.kamailio.org/cgi<wbr>-bin/mailman/listinfo/sr-users</a><br>
          </blockquote>
        </div>
        <br>
      </div>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
Kamailio (SER) - Users Mailing List
<a class="moz-txt-link-abbreviated" href="mailto:sr-users@lists.kamailio.org">sr-users@lists.kamailio.org</a>
<a class="moz-txt-link-freetext" href="https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users">https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users</a>
</pre>
    </blockquote>
    <br>
  </body>
</html>