Upgrade 3CX to v18 and get it hosted free!

Asterisk and OpenSER integration.

Author image

Nice Diagram of Openser and Asterisk integration OpenSer+Asterisk

Satish Patel

+91-9818875535 E-mail: [email protected]
home page:- http://www.linuxbug.org

        [SIP_Client]------------------------->[OpenSER]-----------------------[Asterisk]-----------------[PSTN]

Let’s talk about something interesting. I have been working on IP telephony systems for the last year. I have implemented IP PBX solutions for many organizations. I have good expertise on telephony and Asterisk systems. Basically Asterisk is not a SIP server but it can support the SIP protocol. That’s why Asterisk can handle only 200 to 300 SIP device registrations, and that on large productions it doesn’t to work great. Finally, I have decided to implement Asterisk on a large production with the help of OpenSER. OpenSER is pure SIP server and a lightweight binary, so it can handle 10,000 call per second. I am using OpenSER in front of Asterisk. OpenSER handles my call SIP registration requests, and Asterisk handles my PSTN functionality because OpenSER doesn’t support telephony hardware. Asterisk provides media application services like VoiceMail, Conference, IVR, and PSTN functions.

I am going to show you how to integrate this combined system: OpenSER and Asterisk.

My configuration example.

 $cat /usr/local/etc/openser/openser.cfg
 
 debug=6
 fork=yes
 log_stderror=yes
 port=5060
 children=4
 fifo="/tmp/ser_fifo"
 loadmodule "/usr/local/lib/ser/modules/sl.so"
 loadmodule "/usr/local/lib/ser/modules/tm.so"
 loadmodule "/usr/local/lib/ser/modules/rr.so"
 loadmodule "/usr/local/lib/ser/modules/maxfwd.so"
 loadmodule "/usr/local/lib/ser/modules/usrloc.so"
 loadmodule "/usr/local/lib/ser/modules/registrar.so"
 loadmodule "/usr/local/lib/ser/modules/textops.so"
 modparam("usrloc", "db_mode", 0)
 modparam("rr", "enable_full_lr", 1)
 route{
        if (!mf_process_maxfwd_header("10")) {
                sl_send_reply("483","Too Many Hops");
                break;
        };
        if (msg:len >=  2048 ) {
                sl_send_reply("513", "Message too big");
                break;
        };
 
        if (!method=="REGISTER") record_route();
        if (loose_route()) {
                append_hf("P-hint: rr-enforced\r\n");
                route(1);
                break;
        };
        if (!uri==myself) {
                append_hf("P-hint: outbound\r\n");
                route(1);
                break;
        };
        if (uri==myself) {
                if (method=="REGISTER") {
                        save("location");
                        break;
                };
                if(method=="INVITE") {
                        if (uri =~ "sip:5[0-9]@*"){
                        route(3);
                        break;
                }
                }
                lookup("aliases");
                if (!uri==myself) {
                        append_hf("P-hint: outbound alias\r\n");
                        route(1);
                        break;
                };
                if (!lookup("location")) {
                        sl_send_reply("404", "Not Found");
                        break;
                };
        };
        append_hf("P-hint: usrloc applied\r\n");
        route(1);
 }
 route[1]
 {
        if (!t_relay()) {
                sl_reply_error();
        };
 }
 route[3]{
 
   if (uri =~ "sip:5[0-9]@*"){
        log(1, "Forwarding to Asterisk \n");
        rewritehostport("192.168.104.20:5060");
        route(1);
        break;
    }

Asterisk configuration for openser

sip.conf

[203.124.16.109]
 type=friend ; We allow incoming and outgoing calls. Use peer if you are only doing MWI
 context=outgoing ; This is the context incoming calls land in
 host=<openser_server_ip> ; This is the hostname or IP address of your SER server
 fromdomain=<openser_server_ip> ; This is your SER_DOMAIN
 insecure=very ; This allows incoming calls from the phones routing through ser to be passed into asterisk
 mailbox=user@context

extention.conf

 [globals]
 SERADDRESS=xxx.xxx.xxx.xxx

 [outgoing]
 exten => _XXXX,1,Dial(SIP/${EXTEN}@${SERADDRESS},20,r)
 exten => _0XXXXXXXXXX,1,Dial(Zap/g1/${EXTEN},60) 

Related Posts:

Get 3CX - Absolutely Free!
Link up your team and customers Phone System Live Chat Video Conferencing

Hosted or Self-managed. Up to 10 users free forever. No credit card. Try risk free.

3CX
A 3CX Account with that email already exists. You will be redirected to the Customer Portal to sign in or reset your password if you've forgotten it.