<div dir="ltr"><div><div><div>Hello All,<br><br></div>I have been following bits of this guide <a href="http://kb.asipto.com/freeswitch:kamailio-3.3.x-freeswitch-1.2.x-sbc">http://kb.asipto.com/freeswitch:kamailio-3.3.x-freeswitch-1.2.x-sbc</a> and bits from other posts to get Kamailio 4.0 integrated with FusionPBX & Freeswitch 1.2.12 using Postgres instead of MySQL.<br>
<br></div><div>My reason for using Postgres is simply because Freeswitch now supports Postgres natively and FusionPBX also uses Postgres for its backend DB.  So it made sense to keep things consistent.<br><br></div><div>The main functions of Kamailio in this scenario are as follows:<br>
<br></div><div>- NAT Traversal<br>- Security, Anti-flood, some DDOS attack protection<br></div><div>- Load-balancing in future<br></div><div><br></div>So far I have the registrations working somewhat and the registrations are visible in the Kamailio locations table but I also Freeswitch also needs to have access to these registrations as well so that we have access to the functionality within FusionPBX.<br>
</div><div><br></div><div>Here are the relevant bits of my script with the real public IPs substituted:<br><br>#######<br><br></div><div># *** Value defines - IDs used later in config<br>#!ifdef WITH_PGSQL<br>#!define DBURL "postgres://kamailio:kamailiorw@localhost/kamailio"<br>
#!endif<br>.<br>.<br>#!ifdef WITH_FREESWITCH<br>#!define DBFSURL "postgres://<a href="http://fusionpbx:fusionpbx@1.2.3.4:5432/fusionpbx">fusionpbx:fusionpbx@1.2.3.4:5432/fusionpbx</a>"<br>#!endif<br>.<br>.<br>#!ifdef WITH_FREESWITCH<br>
freeswitch.bindip = "1.2.3.4" desc "FreeSWITCH IP Address"<br>freeswitch.bindport = "5060" desc "FreeSWITCH Port"<br>#<br>kamailio.bindip = "2.2.2.2" desc "Kamailio IP Address"<br>
kamailio.bindport = "5065" desc "Kamailio Port"<br>#!endif<br>.<br>.<br>#!ifdef WITH_POSTGRES<br>loadmodule "db_postgres.so"<br>#!endif<br>.<br>.<br>.<br># ----- usrloc params -----<br>/* enable DB persistency for location entries */<br>
#!ifdef WITH_USRLOCDB   <br>modparam("usrloc", "db_url", "postgres://kamailio:kamailiorw@localhost/kamailio")<br>modparam("usrloc", "db_mode", 2)<br>modparam("usrloc", "use_domain", MULTIDOMAIN)<br>
#!endif<br><br>   <br># ----- auth_db params -----<br>#!ifdef WITH_AUTH<br>modparam("auth_db", "calculate_ha1", yes)<br>modparam("auth_db", "load_credentials", "")<br><br>
#!ifdef WITH_FREESWITCH<br>modparam("auth_db", "user_column", "extension")  <br>modparam("auth_db", "password_column", "password")<br>modparam("auth_db", "domain_column", "user_context")<br>
modparam("auth_db", "db_url", DBFSURL)<br>modparam("auth_db", "version_table", 0)<br>modparam("auth_db", "use_domain", MULTIDOMAIN)<br>#!else<br>modparam("auth_db", "db_url", DBURL)<br>
modparam("auth_db", "password_column", "password")<br>modparam("auth_db", "use_domain", MULTIDOMAIN)   <br>#!endif<br>.<br>.<br># authentication<br>        route(AUTH);<br>
<br>        # record routing for dialog forming requests (in case they are routed)<br>        # - remove preloaded route headers<br>        remove_hf("Route");<br>        if (is_method("INVITE|SUBSCRIBE"))<br>
                record_route_preset("2.2.2.2");<br><br>        # account only INVITEs<br>        if (is_method("INVITE"))<br>        {<br>                setflag(FLT_ACC); # do accounting<br>        }<br>
<br>        # dispatch requests to foreign domains<br>        route(SIPOUT);<br><br>        # handle presence related requests<br>        route(PRESENCE);<br><br>        # handle registrations<br>        route(REGISTRAR);<br>
<br>        if ($rU==$null)<br>        {<br>                # request with no Username in RURI<br>                sl_send_reply("484","Address Incomplete");<br>                exit;<br>        }<br>.<br>
.<br>.<br># Authentication route<br>route[AUTH] {<br>#!ifdef WITH_AUTH<br><br>#!ifdef WITH_FREESWITCH<br>        # do not auth traffic from FreeSWITCH - trusted!<br>        if(route(FROMFREESWITCH))<br>                return;<br>
#!endif  <br><br>#!ifdef WITH_IPAUTH<br>        if((!is_method("REGISTER")) && allow_source_address())<br>        {<br>                # source IP allowed<br>                return;<br>        }<br>#!endif<br>
        <br>        if (is_method("REGISTER") || from_uri==myself)<br>        {<br>                # authenticate requests<br>#!ifdef WITH_FREESWITCH<br>                if (!auth_check("$fd", "v_extensions", "1")) {<br>
#!else<br>                if (!auth_check("$fd", "subscriber", "1")) {<br>#!endif<br>                        auth_challenge("$fd", "0");<br>                        exit;<br>
                }<br>                # user authenticated - remove auth header<br>                if(!is_method("REGISTER|PUBLISH"))<br>                        consume_credentials();<br>        }<br>        # if caller is not local subscriber, then check if it calls<br>
        # a local destination, otherwise deny, not an open relay here<br>        if (from_uri!=myself && uri!=myself)<br>        {<br>                sl_send_reply("403","Not relaying");<br>                exit;<br>
        }<br><br>#!endif<br>        return;<br>}<br>.<br>.<br>.<br># Routing to foreign domains<br>route[SIPOUT] {<br>        if (!uri==myself)<br>        {<br>                append_hf("P-hint: outbound\r\n");<br>
                route(RELAY);<br>        }<br>}<br>.<br>.<br>.<br># Handle SIP registrations<br>route[REGISTRAR] {<br>        if (is_method("REGISTER"))<br>        {<br>                if(isflagset(FLT_NATS))<br>
                {<br>                        setbflag(FLB_NATB);<br>                        # uncomment next line to do SIP NAT pinging<br>                        setbflag(FLB_NATSIPPING);<br>                }<br>                # without param, here would allows multiple contacts, with 0x04 param, last register wins (fifo)<br>
                #if (!save("location"))<br>                if (!save("location", "0x04"))<br>                        sl_reply_error();<br>        <br>#!ifdef WITH_FREESWITCH<br>                route(REGFWD);<br>
#!endif<br><br>                exit;<br>        }<br>}<br>.<br>.<br>.<br></div><div>#######<br><br>I hope I haven't missed anything important.<br><br>With my current config I am able to dial feature code in FusionPBX and 
also make outbound calls but not able to dial between extensions because as far as Freeswitch is concerned the extensions are not registered.<br><br></div><div>Any assistance would be greatly appreciated.<br><br></div><div>
Thanks<br><br>Errol<br><br></div><div><br><br><br></div><div><br></div><br><div><br><div><br><br></div></div></div>