1
votes

I am trying to configure opensips as load-balancer for freeswitch by following below link but the procedure written there seems very old and many issues are faced while following the steps mentioned in it.

https://freeswitch.org/confluence/display/FREESWITCH/Enterprise+deployment+OpenSIPS

Can someone please share some exact configuration example for this scenario which I can follow at latest ubuntu releases. Thanks

1
Hi, can someone please comment on it? Thankskaa

1 Answers

0
votes

We can use opensips or kamailio as a sip loadbalancer and for high availability services in several ways based on availability of resources. I wrote a step by step guide here

enter image description here

Install openSIPS :

Follow this guide to install openSIPS 2.4 and use below configuration to edit opensips.cfg .

if you are not configuring high availability and hosting mysql database locally on openSIPS only , then you may want to use localhost or 127.0.0.1

and also change database credentials and SIP listening address .

vi /etc/opensips/opensips.cfg

log_level=4

sip_warning=0

log_stderror=no

log_facility=LOG_LOCAL2

log_name="opensips"

debug_mode=yes

children=4

dns_try_ipv6=no

auto_aliases=no

#advertised_address="12.135.59.0"

mhomed=1

listen=udp:10.128.0.1:5060

mpath="/usr/lib64/opensips/modules"

loadmodule "db_mysql.so"

loadmodule "signaling.so"

loadmodule "sl.so"

loadmodule "tm.so"

loadmodule "rr.so"

loadmodule "uri.so"

loadmodule "dialog.so"

loadmodule "maxfwd.so"

loadmodule "textops.so"

loadmodule "mi_fifo.so"

loadmodule "dispatcher.so"

loadmodule "load_balancer.so"

loadmodule "sipmsgops.so"

loadmodule "proto_udp.so"

modparam("mi_fifo", "fifo_name", "/tmp/opensips_fifo")

modparam("dialog", "db_mode", 1)

#change database credentials below

#if this is the only openSIPS node in network and you are using HighAvailability use mysql database host as localhost or 127.0.0.1

modparam("dialog", "db_url", "mysql://abc:[email protected]/opensips") modparam("rr", "enable_double_rr", 0)

modparam("rr", "append_fromtag", 1)

modparam("tm", "fr_timer", 2)

#change database credentials below

modparam("dispatcher", "db_url", "mysql://abc:[email protected]/opensips")

modparam("dispatcher", "ds_ping_method", "OPTIONS")

modparam("dispatcher", "ds_ping_interval", 5)

modparam("dispatcher", "ds_probing_threshhold", 2)

modparam("dispatcher", "ds_probing_mode", 1)

modparam("load_balancer", "db_url", "mysql://abc:[email protected]/opensips")

modparam("load_balancer", "probing_method", "OPTIONS")

modparam("load_balancer", "probing_interval", 5)

route{



        if (!mf_process_maxfwd_header("10")) {



                sl_send_reply("483","Too Many Hops");



                exit;



        }





        if (!has_totag()) {



                record_route();



        }



        else {



                loose_route();



                t_relay();



                exit;



        }



        if (is_method("CANCEL")) {



                if (t_check_trans())



                        t_relay();



                exit;



        }



        if (is_method("INVITE")) {



                if (!load_balance("1","pstn","1")) {

log("sreekanth invite method\n");

                        send_reply("503","Service Unavailable");



                        exit;



                }



        }



        else if (is_method("REGISTER")) {



                if (!ds_select_dst("1", "4")) {



                        send_reply("503","Service Unavailable");



                        exit;



                }



        }



        else {



                send_reply("405","Method Not Allowed");



                exit;



        }



        if (!t_relay()) {



                sl_reply_error();



        }

}

Now we need to insert entries in loadbalance and dispatch tables of opensips database

INSERT INTO opensips.load_balancer (id, group_id, dst_uri, resources, probe_mode, description) VALUES ('1', '1','sip:10.10.10.5 ','vm=100;conf=100;transc=100;pstn=500', '1','FS1');

INSERT INTO opensips.load_balancer (id, group_id, dst_uri, resources, probe_mode, description) VALUES ('2', '1','sip:10.10.10.4 ','vm=100;conf=100;transc=100;pstn=500', '1','FS2');

and insert records in dispatcher table as well .

INSERT INTO opensips.dispatcher (id, setid, destination, socket, state, weight, priority, attrs, description) VALUES ('1', '1','sip:10.10.10.5:5060','','0', '1', '1','','FS1');

INSERT INTO opensips.dispatcher (id, setid, destination, socket, state, weight, priority, attrs, description) VALUES ('1', '1','sip:10.10.10.4:5060','','0', '1', '1','','FS2');

Configure Freeswitch :

In freeswitch /etc/freeswitch/vars.xml change domain to opensips domain name . And reload freeswitch