Knowledge Updates

Query related to Kamailio Installation? Here is the one you were looking for

The Kamailio SIP server is the main Open Source software program for building SIP services like a SIP proxy, SIP Presence Server, SIP location server and much more. Kamailio used to handle thousands of call setups per second. Kamailio is the choice for building enterprise as well as carrier solutions with a rich configuration language, popularity and continues development. Kamailio runs on UNIX and Linux systems, ranging from embedded systems to huge scale multi-core servers.

Pre-requites for Kamailio installation:

The following packages are required before proceeding to the next steps.

  • git client: apt-get install git-core – it is recommended to have a recent version if your Linux distro has an old version.
  • gcc compiler: apt-get install gcc
  • flex – apt-get install flex
  • bison – apt-get install bison
  • libmysqlclient-dev – apt-get install libmysqlclient-dev
  • make – apt-get install make
  • if you want to enable more modules, some of them require extra libraries:
  • 1. libssl – apt-get install libssl-dev
  • 2. libcurl – apt-get install libcurl4-openssl- dev
  • 3. libxml2 – apt-get install libxml2-dev
  • 4. libpcre3 – apt-get install libpcre3-dev

Note: Kamailio (version 4.3.0) uses the directory /var/run/kamailio/ for creating FIFO and UnixSocket control files. You have to complete the section related to the installation of init.d script for creating /var/run/kamailio even if you plan to start Kamailio manually from command line. The alternative is to set different paths via parameters of mi_fifo and ctl modules.

Step1: First, Getting sources from GIT:

First of all, you have to create a directory on the file system where the sources will be stored.

1
2
  mkdir -p /usr/local/src/kamailio-devel
  cd /usr/local/src/kamailio-devel

you can Download the sources from GIT using the following commands.

1
2
3
  git clone --depth 1 --no-single-branch git://git.kamailio.org/kamailio kamailio
  cd kamailio
  git checkout -b 4.4 origin/4.4

Step2. Tuning Make files

The first step is to generate build config files.

1
  make cfg

Next step is to enable the MySQL module. Edit modules.lst file:

1
  nano -w modules.lst

Add db_mysql to the variable include_modules.

1
include_modules= db_mysql

Save the modules.lst and exit.

NOTE: this is one mechanism to enable modules which are not compiled by default, such as lcr, dialplan, presence – add the modules to include_modules variable inside the modules.lst file.

Alternative is to set ‘include_modules’ variable to specify what extra modules to be included for compilation when building Makefile cfg:

1
make include_modules="db_mysql dialplan" cfg

NOTE: If you want to install everything in one directory (so you can delete all installed files at once), say /usr/local/kamailio-devel, then set PREFIX variable to the install path in ‘make cfg …’ command:

1
make PREFIX="/usr/local/kamailio-devel" include_modules="db_mysql dialplan" cfg

NOTE: Previous release series 3.x.x used FLAVOUR mechanism to set the name of the application to kamailio. Starting with 4.0.0, the default is kamailio. From that version, if you want to build ser flavour, use FLAVOUR=ser in the make command to generate the build configs.

Step3. Compile Kamailio

Once you added the mysql module to the list of enabled modules, you can compile Kamailio:

1
  make all

You can get full compile flags output using:

1
  make Q=0 all

Step4. Install Kamailio

When the compilation is ready, install Kamailio with the following command:

1
  make install

Step5. Kamailio installation Path

The binaries and executable scripts were installed in:

1
  /usr/local/sbin

These are kamailio, kamdbctl, kamctl, kamcmd commond to manage SIP Server.

To be able to use the binaries from command line, make sure that ‘/usr/local/sbin’ is set in PATH environment variable.

1
2
  PATH=$PATH:/usr/local/sbin
  export PATH

Kamailio (OpenSER) modules are installed in:

1
  /usr/local/lib/kamailio/modules/

Note: On 64 bit systems, /usr/local/lib64 may be used.

The documentation and readme files are installed in:

1
  /usr/local/share/doc/kamailio/

The man pages are installed in:

1
2
  /usr/local/share/man/man5/
  /usr/local/share/man/man8/

The configuration file was installed in:

1
  /usr/local/etc/kamailio/kamailio.cfg

Step6. Create MySQL database

To create the MySQL database, first edit kamctlrc file to set the database server type:

1
  nano -w /usr/local/etc/kamailio/kamctlrc

Locate DBENGINE variable and set it to MYSQL:

1
DBENGINE=MYSQL

You can change other values in kamctlrc file, at least it is recommended to change the default passwords for the users to be created to connect to database. Once you are done updating kamctlrc file, run the script to create the database used by Kamailio:

1
  /usr/local/sbin/kamdbctl create

Step7. Edit configuration file

To fit your requirements for the VoIP platform, you have to edit the configuration file.

1
  /usr/local/etc/kamailio/kamailio.cfg

Follow the instruction in the comments to enable usage of MySQL. Basically, you have to add several lines at the top of config file, like:

1
2
3
#!define WITH_MYSQL
#!define WITH_AUTH
#!define WITH_USRLOCDB

Step8. The init.d script

The init.d script can be used to start/stop the Kamailio server in a nicer way. A sample of init.d script for Kamailio is provided at:

1
/usr/local/src/kamailio-devel/kamailio/pkg/kamailio/deb/debian/kamailio.init

Just copy the init file into the /etc/init.d/kamailio. Then change the permisions:

1
  chmod 755 /etc/init.d/kamailio

then edit the file updating the $DAEMON and $CFGFILE values:

1
2
  DAEMON=/usr/local/sbin/kamailio
  CFGFILE=/usr/local/etc/kamailio/kamailio.cfg

You need also setup a configuration file in the /etc/default/ directory. This file can be found at:

1
  /usr/local/src/kamailio-devel/pkg/kamailio/debian/kamailio.default

You need to rename the file to ‘kamailio’ after you’ve copied it. Then edit this file and set RUN_KAMAILIO=yes. Edit the other options at your convenience. Create the directory for pid file:

1
mkdir -p /var/run/kamailio

Default setting is to run Kamailio as user “kamailio” and group “kamailio”. For that you need to create the user:

1
2
3
4
5
6
adduser --quiet --system --group --disabled-password \
        --shell /bin/false --gecos "Kamailio" \
        --home /var/run/kamailio kamailio
 
# set ownership to /var/run/kamailio
chown kamailio:kamailio /var/run/kamailio

Then you can start/stop Kamailio using the following commands:

1
2
  /etc/init.d/kamailio start
  /etc/init.d/kamailio stop

Step9. Ready to use

Now everything is in place. You can start the VoIP service, creating new accounts and setting the phones. A new account can be added using ‘kamctl’ tool via ‘kamctl add ‘. (or try without the email)

1
kamctl add test testpasswd test@mysipserver.com
1
kamctl add test testpasswd test@mysipserver.com

If you are asked for SIP_DOMAIN environment variable do one of the following option.

1
2
3
  export SIP_DOMAIN=mysipserver.com
  edit '/root/.kamctlrc' and add:
  SIP_DOMAIN=mysipserver.com

Step10. Maintenance

The maintenance process is very simple right now. You have to be user ‘root’ and execute following commands:

1
2
3
4
5
  cd /usr/local/src/kamailio-devel/kamailio
  git pull origin
  make all
  make install
  /etc/init.d/kamailio restart

Now you have the latest Kamailio devel running on your system.

Kamailio is the choice for building enterprise as well as carrier solutions with a rich configuration language, popularity and continues development. We at GVenture Technology will fulfil all your necessary requirements.

Tagged:  

OpenSIPS Development: An important resource for joined communication

GVenture Technology takes on a pleasant ride to develop OpenSIPS applications. OpenSIPS (Open SIP Server) is a developed Open Source implementation of a SIP server that runs on Linux platforms and play in the infrastructure of an Internet Telephony Service Provider and it includes application-level functionality.

Why use OpenSIPS?

  • No vendor trap
  • Faster development cycle
  • Split work between parties
  • Easy synchronization with the mainstream via contributions ⇒ Unified effort for development
  • Performance and flexibility

Prerequisites:

  • Since OpenSIPS is known to work on most nix based systems, installing and running OpenSIPS requires some very basic Linux knowledge.
  • Also, since OpenSIPS is a SIP proxy, you will most likely need some basic SIP knowledge in order to deploy/debug OpenSIPS in some more advanced scenarios.
  • Last but not least, you will need some basic programming logic knowledge – The OpenSIPS configuration file is text-based, written in an OpenSIPS custom language, very similar to the C language.

Requirements:

gcc / suncc / icc : gcc >= 2.9x; 4.[012] recommended (it will work with older version but it might require some options tweaking for best performance)

  • bison or yacc (Berkley yacc)
  • flex
  • GNU make (on Linux this is the standard “make”, on FreeBSD and Solaris is called “gmake”) version >= 3.79.
  • sed and tr (used in the makefiles)
  • GNU tar (“gtar” on Solaris) and gzip if you want “make tar” to work
  • GNU install or BSD install (on Solaris “ginstall”) if you want “make install”, “make bin”, “make sunpkg” to work
  • openssl if you want to compile the TLS support
  • libsctp if you want to compile the SCTP support
  • libmysqlclient & libz (zlib) -libs and devel headers- if you want mysql DB support (the db_mysql module)
  • libpq / postgresql -libs and devel headers- if you want postgres DB support (the db_postgres module)
  • unixodbc -libs and devel headers- if you want unixodbc DB support (the db_unixodbc module)
  • libexpat if you want the jabber gateway support (the jabber module) or the XMPP gateway support
  • libxml2 if you want to use the cpl-c (Call Processing Language) or the presence modules (presence and pua*)
  • libradius-ng -libs and devel headers- if you want to use functionalities with radius support – authentication, accounting, group support, etc
  • unixodbc – libs and devel headers – if you want UNIXODBC support as DB underlayer
  • libxmlrpc-c3 – libs and devel headers – if you want to have XML-RPC support for the Management interface (MI)
  • libperl – libs and devel headers – if you want PERL connector to support perl scripting from you config file (perl module)
  • libsnmp9 – libs and devel headers – if you want SNMP client functionality (SNMP AgentX subagent) for opensips
  • libldap libs and devel headers v2.1 or greater – if you want LDAP support
  • libconfuse and devel headers – if you want to compile the carrier route module

Installation:

By following above 2 processes we have installed the OpenSIPS server on our system now we have to configure the server corresponding to our requirement.

OpenSIPS Installation:

1. System Update:  Update your system with latest updates and security patches using the following command.

1
# apt-get update

2. Installing Dependencies: After system update you need to install the missing packages using the ‘apt-get’ command if these are not already installed.

1
# apt-get install build-essential openssl bison flex

3. Installing MySQL Server: Let’s run the following commands to install MySQL server and it development libraries.

1
# apt-get install mysql-server libmysqlclient-dev

4. Download and extract OpenSIPS Package: We are going to download the package into the following directory using ‘wget’ command and the extract within th esame directory.

1
2
3
# cd /usr/src
# wget http://opensips.org/pub/opensips/latest/opensips-2.1.2.tar.gz
# tar -zxvf opensips-2.1.2.tar.gz

5. Compiling OpenSIPS Source: Moving step ahead let’s move into the opensips directory and run the command below to start the compilation process.

1
2
# cd opensips-2.1.2/
# make all

6. Installing OpenSIPS Source: Once the compilation process completes, you can start making its installation as shown below.

1
# make install

7. OpenSIPS Configuration: The OpenSIPS has been installed, now we are going to configure some of its basic parameters and startup script. Let’s first create a new directory for the OpenSIPS run files.

1
# mkdir /var/run/opensips

Now move to the following ‘debians’ directory and list the files in it.

1
# cd packaging/debian/

8. Starting OpenSIPS Service: All necessary configurations has been setup to proceed on starting OpenSIPS service. Simply run the following command to start OpenSIPS and the check its status, that should be active and running as shown in the image.

1
2
# /etc/init.d/opensips start
# systemctl status opensips

You can also check the state of OpenSIPS services and the port on which its running that is ‘5060’ by using the below commands.

1
2
# ps -ef | grep opensips
# netstat -alnp | grep opensips

CONFIGURATION

We have following directory where all files has be installed:

1
2
/usr/local/lib/opensips/ directory where all modules are installed
/usr/local/etc/opensips/ directory where all configuration you have make

FOR LOAD

Under Load-balancing format The below setting will create alternate call from one server and other alternately it will create same number of calls from each gateway.

1
2
3
4
5
6
log_stderror=yes
log_facility=LOG_LOCAL0
fork=yes
children=4
debug=2
listen=5060

MODULE PATH

1
mpath="/usr/local/lib/opensips/modules/"

Modules Section

DB_MYSQL

1
2
3
4
loadmodule "db_mysql.so"
modparam("db_mysql", "ping_interval", 300)
modparam("db_mysql", "timeout_interval", 10)
modparam("db_mysql", "auto_reconnect", 1)

SL

1
2
loadmodule "sl.so"
modparam("sl", "enable_stats", 1)

TM

1
2
3
4
5
6
7
8
9
10
11
12
loadmodule "tm.so"
modparam("tm", "fr_timer", 30)
modparam("tm", "fr_inv_timer", 120)
modparam("tm", "wt_timer", 5)
modparam("tm", "delete_timer", 2)
#modparam("tm", "noisy_ctimer", 0)
modparam("tm", "ruri_matching", 1)
modparam("tm", "via1_matching", 1)
modparam("tm", "unix_tx_timeout", 2)
modparam("tm", "restart_fr_on_each_reply", 1)
modparam("tm", "pass_provisional_replies", 0)
modparam("tm", "fr_inv_timer_avp", "$avp(s:callee_fr_inv_timer)")

RR

1
2
3
4
5
loadmodule "rr.so"
modparam("rr", "enable_full_lr", 0)
modparam("rr", "append_fromtag", 1)
modparam("rr", "enable_double_rr", 0)
modparam("rr", "add_username", 0)

MAXFWD

1
loadmodule "maxfwd.so"

USRLOC

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
loadmodule "usrloc.so"
modparam("usrloc", "user_column", "username")
modparam("usrloc", "domain_column", "domain")
modparam("usrloc", "contact_column", "contact")
modparam("usrloc", "expires_column", "expires")
modparam("usrloc", "q_column", "q")
modparam("usrloc", "callid_column", "callid")
modparam("usrloc", "cseq_column", "cseq")
modparam("usrloc", "methods_column", "methods")
modparam("usrloc", "flags_column", "flags")
modparam("usrloc", "user_agent_column", "user_agent")
modparam("usrloc", "received_column", "received")
modparam("usrloc", "socket_column", "socket")
modparam("usrloc", "use_domain", 0)
modparam("usrloc", "desc_time_order", 0)
modparam("usrloc", "timer_interval", 60)
modparam("usrloc", "db_mode", 2)
modparam("usrloc", "db_url" , "mysql://opensips:opensips@database/opensips")
modparam("usrloc", "matching_mode", 0)
modparam("usrloc", "cseq_delay", 20)
modparam("usrloc", "nat_bflag", 6)

REGISTRAR

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
loadmodule "registrar.so"
modparam("registrar", "method_filtering", 1)
modparam("registrar", "default_expires", 3600)
modparam("registrar", "min_expires", 60)
modparam("registrar", "max_expires", 0)
modparam("registrar", "default_q", 0)
modparam("registrar", "append_branches", 1)
modparam("registrar", "case_sensitive", 0)
modparam("registrar", "received_param", "received")
modparam("registrar", "max_contacts", 10)
modparam("registrar", "retry_after", 0)
modparam("registrar", "path_mode", 2)
modparam("registrar", "path_use_received", 0)
#modparam("registrar", "received_avp", "$avp(i:801)")
modparam("registrar", "aor_avp", "$avp(i:3223)")
modparam("registrar", "received_avp", "$avp(s:rcv)")

TEXTOPS

1
loadmodule "textops.so"

MI_FIFO

1
2
3
4
5
6
7
loadmodule "mi_fifo.so"
modparam("mi_fifo", "fifo_name", "/tmp/opensips_fifo")
#modparam("mi_fifo", "fifo_mode", 0660)
#modparam("mi_fifo", "fifo_group", "opensips")
#modparam("mi_fifo", "fifo_user", "opensips")
#modparam("mi_fifo", "reply_dir", "/tmp/")
#modparam("mi_fifo", "reply_indent", "\t")

URI

1
loadmodule "uri.so"

URI_DB

1
2
3
4
5
6
7
8
loadmodule "uri_db.so"
modparam("uri_db", "db_url", "mysql://opensips:opensips@database/opensips")
modparam("uri_db", "db_table", "uri")
modparam("uri_db", "use_uri_table", 1)
modparam("uri_db", "use_domain", 1)
modparam("uri_db", "user_column", "username")
modparam("uri_db", "domain_column", "domain")
modparam("uri_db", "uriuser_column", "uri_user")

xlog

1
2
3
loadmodule "xlog.so"
modparam("xlog", "force_color", 1)
modparam("xlog", "buf_size", 4096)

acc

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
loadmodule "acc.so"
modparam("acc", "db_url", "mysql://opensips:opensips@database/opensips")
modparam("acc", "early_media", 1)
modparam("acc", "report_ack", 1)
modparam("acc", "report_cancels", 1)
modparam("acc", "detect_direction", 1)
modparam("acc", "failed_transaction_flag", 3)
modparam("acc", "log_flag", 1)
modparam("acc", "log_missed_flag", 2)
modparam("acc", "db_flag", 1)
modparam("acc", "db_missed_flag", 2)
modparam("acc", "db_extra" , "ua=$hdr(User-Agent); src_user=$avp(i:100);
src_domain=$fd; src_port=$sp; dst_user=$rU; dst_domain=$rd; dst_port=$rp;
message=$mf; unixtime=$Ts; avp_var=$avp(s:can_uri); callstate=$avp(s:callstate);
usercode=$avp(i:1000); recieved=$avp(s:rcv); aor_avp=$avp(i:3223)")

auth

1
2
3
4
loadmodule "auth.so"
modparam("auth", "nonce_expire", 300)
modparam("auth", "rpid_suffix", ";party=calling;id-type=subscriber;screen=yes")
modparam("auth", "rpid_avp", "$avp(s:rpid)")

AVPOPS

1
2
3
4
5
6
7
8
9
10
11
loadmodule "avpops.so"
modparam("avpops", "db_url", "mysql://opensips:opensips@database/opensips")
modparam("avpops", "avp_table", "usr_preferences")
modparam("avpops", "use_domain", 0)
modparam("avpops", "uuid_column", "uuid")
modparam("avpops", "username_column", "username")
modparam("avpops", "domain_column", "domain")
modparam("avpops", "attribute_column", "attribute")
modparam("avpops", "value_column", "value")
modparam("avpops", "type_column", "type")
#modparam("avpops", "avp_aliases", "c_uri" )

DIALOG

1
2
3
4
5
6
loadmodule "dialog.so"
modparam("dialog", "enable_stats", 1)
modparam("dialog", "default_timeout", 21600)
modparam("dialog", "db_url", "mysql://opensips:opensips@database/opensips")
modparam("dialog", "db_mode", 1)
modparam("dialog", "dlg_flag", 4)

SIPTRACE

1
2
3
4
loadmodule "siptrace.so"
modparam("siptrace","db_url","mysql://opensips:opensips@database/opensips")
modparam("siptrace", "trace_on", 1)
modparam("siptrace", "trace_flag", 22)

MI_DATAGRAM

1
2
3
loadmodule "mi_datagram.so"
modparam("mi_fifo", "fifo_name", "/tmp/opensips_fifo")
modparam("mi_datagram", "socket_name", "udp:10.10.2.144:8080")

Routing Logic

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
 main request routing logic
 
route{
        sip_trace(); # Recording all sip signal for each calls connect through this server
        xlog("Recive call variable : $avp(s:rcv) $avp(i:3223)\n"); # prints the cli log
 
        if($fU==NULL){
                $avp(i:100)="0";
        }
        else
                $avp(i:100)=$fU;
 
        if (!mf_process_maxfwd_header("10")) {
                sl_send_reply("483","Too Many Hops");
                exit;
        }
 
        if (has_totag()) {
                if (loose_route()) {
                        if(is_method("BYE")){
		        #setting for call accounting
                                setflag(1);
                                setflag(3);
                        }
                        route(1);
                } else {
                        if ( is_method("ACK") ) {
                                if ( t_check_trans() ) {
                                        t_relay();
                                        exit;
                                } else {
                                        exit;
                                }
                        }
                        sl_send_reply("404","Not here");
                }
                exit;
        }
 
        if (is_method("CANCEL"))
        {
                if (t_check_trans())
                        t_relay();
                exit;
        }
 
       t_check_trans();
 
        # record routing
        if (!is_method("REGISTER|MESSAGE")){
                record_route();
        }
 
        # account only INVITEs
        if (is_method("INVITE")) {
	   if(from_uri=~".*@10.10.2.136" || from_uri=~".*@10.10.2.134"){
 
                }
                else{
                        avp_db_query("select id_skillgroup from subscriber u where username='$rU'", "$avp(i:2001)");
                        avp_db_query("select id from ast_skillgroup where id='$avp(i:2001)'", "$avp(i:2002)");
                        avp_db_query("select id, serverip, callerid from ast_servers where id_skillgroup='$avp(i:2002)'
                                      order by calls asc limit 1", "$avp(i:2003);$avp(i:2004);$avp(i:2005)");
                        avp_db_query("Update ast_servers SET calls=calls+1 WHERE id=$avp(i:2003)");
 
                        avp_pushto("$ru/domain","$avp(i:2004)");
 
                        if (!t_relay()) {
                                sl_reply_error();
                        };
                        exit;
                }
        }
 
         if (!uri==myself)
        {
                append_hf("P-hint: outbound\r\n");
                route(1);
        }
 
        if (is_method("PUBLISH"))
        {
                sl_send_reply("503", "Service Unavailable");
                exit;
        }
 
        if (is_method("REGISTER"))
        {
                # authenticate the REGISTER requests (uncomment to enable auth)
                xlog("User credentals : $avp(i:1000)\n");
                if (www_authorize("", "subscriber"))
                {
                        xlog("User credentals : $avp(i:1000)\n");
                        if (!save("location"))
                                sl_reply_error();
 
                        exit;
                }
                else{
                        www_challenge("", "0");
                        exit;
                }
 
                if (!check_to())
                {
                        sl_send_reply("403","Forbidden auth ID");
                        exit;
                }
        }
 
        if ($rU==NULL) {
                sl_send_reply("484","Address Incomplete");
                exit;
        }
 
        if (!lookup("location")) {
                switch ($retcode) {
                        case -1:
                        case -3:
                                t_newtran();
                                t_reply("404", "Not Found");
                                exit;
                        case -2:
                                sl_send_reply("405", "Method Not Allowed");
                                exit;
                }
        }
 
        setflag(2);
        xlog("Script is at the end\n");
        route(1);
   }
 
   route[1] {
        # for INVITEs enable some additional helper routes
        if (is_method("INVITE")) {
                avp_db_query("select uuid from subscriber where username = '$rU'", "$avp(s:callee_uuid)");
                $avp(s:can_uri) = $ru;
                xlog("User credentals : $avp(s:callee_uuid)\n");
                t_on_branch("2");
                t_on_reply("2");
                t_on_failure("1");
        }
 
        if (!t_relay()) {
                sl_reply_error();
        };
        exit;
   }
 
    branch_route[2] {
        xlog("new branch at $ru\n");
        $avp(s:can_uri) = $ru;
        $avp(s:callstate)="CALL REROUTED";
        add_rr_param(";foo=true;user=vivek");
        xlog("Call is forwared to asterisk\n");
   }
 
    onreply_route[2] {
        xlog("incoming reply\n");
   }
 
    failure_route[1] {
        if (t_was_cancelled()) {
                exit;
        }
   }

Above configuration is sampled corresponding to load balanced format where calls are forwarded to different gateway corresponding to our requirements and availability of gateway.

GVenture Technology will provide with vicinity to make yourself convenient and to have carefree talk to tell us about your project and then we can offer you all the bits and pieces essential for it.


Got Stuck in FreeSwitch Installation? Let us help you in the crisis.

FreeSWITCH whereas is an extensible open source cross-platform telephony platform designed to route and interconnects prominent communication protocols using audio, video, text or any other form of media. It can be used as a soft-client, carrier-class SoftSwitch or even as PBX.

FreeSwitch Installation:

Following are the needed steps to get it up and running.

Installing FreeSwitch Dependencies:

  • 1. Pre-requisites: We require using git to drag FreeSwitch from the GIT repo. To install GIT we require the EPEL repository installed:
1
2
[root@voip ~]# rpm -Uvh http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-5.noarch.rpm
[root@voip ~]# yum install git
  • 2. Install the required packages:
1
[root@voip src]# yum install autoconf automake gcc-c++ git-core libjpeg-devel libtool make ncurses-devel unixODBC-devel openssl-devel gnutls-devel libogg-devel libvorbis-devel curl-devel libtiff-devel libjpeg-devel python-devel expat-devel zlib zlib-devel bzip2 which
  • 3. Change directory and drag the source from the git repo :
1
2
[root@voip src]# cd /usr/local/src
[root@voip src]# git clone git://git.freeswitch.org/freeswitch.git
  • 4. Change into the recently downloaded source code directory:
1
[root@voip src]# cd freeswitch/
  • 5. Run the bootstrap and configure scripts to create the required modules.conf and get the code ready for compiling:
1
2
[root@voip freeswitch]# ./bootstrap.sh
[root@voip freeswitch]# ./configure --without-libcurl --without-pgsql
  • 6. Edit the modules.conf file. Remove the # in front of any modules you want to compile:
1
[root@voip freeswitch]# vim modules.conf
  • 7. Make and Install Freeswitch:
1
[root@voip freeswitch]# make && make install
  • 8. Install the default sounds:
1
[root@voip freeswitch]# make uhd-sounds-install && make uhd-moh-install
  • 9. Copy the init script and set the correct permissions:
1
2
[root@voip freeswitch]# cp build/freeswitch.init.redhat /etc/init.d/freeswitch
[root@voip init.d]# chmod 755 /etc/init.d/freeswitch
  • 10. Configure Freeswitch to start on boot:
1
2
[root@voip freeswitch]# chkconfig --add freeswitch
[root@voip freeswitch]# chkconfig freeswitch on
  • 11. You require modifying the default init script. It points to Freeswitch being installed in /opt/freeswitch/ however we installed it in /usr/local/freeswitch/ You require changing the lines:
1
2
3
4
5
FS_FILE=${FS_FILE-/opt/freeswitch/bin/freeswitch}
FS_HOME=${FS_HOME-/opt/freeswitch}
<strong>To</strong>
FS_FILE=${FS_FILE-/usr/local/freeswitch/bin/freeswitch}
FS_HOME=${FS_HOME-/usr/local/freeswitch}
  • 12. Next, we require changing the FreeSWITCH directory permissions as we will be running it under the FreeSWITCH account:
1
2
3
[root@voip local]# cd /usr/local
[root@voip local]# chown -R freeswitch freeswitch
[root@voip local]# chgrp -R freeswitch freeswitch
  • 13. For performance reasons, it is recommended to change the kernel boot parameters to disable the tick-less feature. To do this you require adding nohz=off to the end of your boot parameters in your grub.conf.
1
[root@voip freeswitch]# vim /boot/grub/grub.conf
  • Add to the end of the line starting with kernel to add nohz=off at the end. Mine becomes
1
kernel /vmlinuz-2.6.32-71.el6.x86_64 ro root=/dev/mapper/vg_voip-lv_root rd_LVM_LV=vg_voip/lv_root rd_LVM_LV=vg_voip/lv_swap rd_NO_LUKS rd_NO_MD rd_NO_DM LANG=en_US.UTF-8 SYSFONT=latarcyrheb-sun16 KEYBOARDTYPE=pc KEYTABLE=us crashkernel=auto rhgb quiet nohz=off
  • 14. Restart for the kernel parameters to take effect.

At Gventure Technology, Our FreeSWITCH Engineers will be providing an environment where your issues can be resolved ASAP.

Tagged:  

Having a problem with the installation of the Asterisk server? Read us for a simple procedure.

Asterisk is an open source framework build for communication applications. A communication server made of a normal computer by using Asterisk. IP PBX systems, VoIP gateways, conference server etc. are powered by Asterisk. It is used by small businesses, large businesses, call centres, carriers and government agencies, worldwide. Asterisk is the free and open source. Asterisk Development is one of the more user-friendly communications frameworks that are equipped with up to date networks and features enhanced media capabilities.

Asterisk Server Installation:

Pre-requisites for Asterisk installation:

  • System running with kernel-1.2.6 and their header files must be present in our system directory to compile asterisk on our system.
  • It should be written in c we require gcc with their supporting lib such as termcap, and open SSL.
  • Asterisk add-on requires MySQL header file to install the MySQL library, MySQL client and header to compile asterisk add-ons.
yum install bison bison-devel ncurses ncurses-devel zlib zlib-devel OpenSSL OpenSSL-devel gnutls-devel gcc gcc-c++ MySQL-server MySQL-client which flex make.

Download all files: Download below mentioned files as pre-requisites steps for the asterisk installation.

  1. Zaptel (http://downloads.asterisk.org/pub/telephony/zaptel/zaptel-1.4.12.1.tar.gz)
  2. libpri (http://downloads.digium.com/pub/libpri/libpri-1.4-current.tar.gz)
  3. Asterisk (http://downloads.asterisk.org/pub/telephony/asterisk/old-releases/asterisk-1.8.30.0.tar.gz)
  4. Asterisk-sounds (http://downloads.asterisk.org/pub/telephony/asterisk/releases/asterisk-sounds-1.2.1.tar.gz)
  5. Asterisk add-ons (http://downloads.asterisk.org/pub/telephony/asterisk/releases/asterisk-addons-1.4.7.tar.gz)

Step for Installation of an asterisk:

Copy all the files into your server (assuming you have copied all files into /us/src/) 30 Steps for installing asterisk on the system:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
tar -xzf zaptel-1.4.12.1.tar.gz
tar -xzf libpri-1.4.9.tar.gz
tar -xzf asterisk-1.4.20.tar.gz
tar -xzf asterisk-sounds-1.2.1.tar.gz
tar -xzf asterisk-addons-1.4.7.tar.gz
cd zaptel-1.4.12.1
./configure
make
make install
make config
service zaptel start
cd ..
cd libpri-1.4.9
make
make install
cd ..
cd asterisk-1.4.20
./configure
make
make install
make samples
make config
cd ..
cd asterisk-sounds
make install
cd ..
cd asterisk-addons-1.4.7
./configure
make
make install
service asterisk start

Step for Installation of an asterisk:

Copy all the files into your server (assuming you have copied all files into /us/src/) 30 Steps for installing asterisk on the system:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
tar -xzf zaptel-1.4.12.1.tar.gz
tar -xzf libpri-1.4.9.tar.gz
tar -xzf asterisk-1.4.20.tar.gz
tar -xzf asterisk-sounds-1.2.1.tar.gz
tar -xzf asterisk-addons-1.4.7.tar.gz
cd zaptel-1.4.12.1
./configure
make
make install
make config
service zaptel start
cd ..
cd libpri-1.4.9
make
make install
cd ..
cd asterisk-1.4.20
./configure
make
make install
make samples
make config
cd ..
cd asterisk-sounds
make install
cd ..
cd asterisk-addons-1.4.7
./configure
make
make install
service asterisk start
If all above commands run well then we have been installed new asterisk server on the current system.

Creating first sip extension:

Please add following line into sip.conf (/etc/asterisk/sip.conf)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
[common](!) ; this is template.
type=friend
context=internal
host=dynamic
disallow=all
allow=ulaw
allow=alaw
allow=g723
allow=g729
dtmfmode=rfc2833
 
[1000](common)
username=1000
secret=1000
 
[1001](common)
username=1001
secret=1001
 
[1002](common)
username=1002
secret=1002
 
[1003](common)
username=1003
secret=1003
 
[1004](common)
username=1004
secret=1004
Above we have created 5 extensions that can be used any sip client (xlite,cisco sip phone, ATA). All users will get registered. If it does not work then check out the firewall settings. Please disable those settings until setup is completed.

Creating First Dialplan:

As all extension cannot talk each other unless we did not configure its dial plan. We have to open extension.conf (/etc/asterisk/extension.conf). Add following lines [internal] exten=> _XXXX,1,Dial(SIP/${EXTEN}) Now the entire configured phone can talk. This makes asterisk simple platform in PBX, not many skills require to develop office PBX.

Creating First SIP Trunk:

Asterisk can make outbound and inbound calls, for outbound we require providing to terminate our calls, and did to get call routed to our system so for that we require having public IP.

Add following code to sip.conf:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
[trunk]
type=friend
context=internal
host=
disallow=all
allow=ulaw
allow=alaw
allow=g723
allow=g729
dtmfmode=rfc2833
 
After the update our sip.conf looks as follows:
 
[common](!) ; this is template.
type=friend
context=internal
host=dynamic
disallow=all
allow=ulaw
allow=alaw
allow=g723
allow=g729
dtmfmode=rfc2833
 
[1000](common)
username=1000
secret=1000
 
[1001](common)
username=1001
secret=1001
 
[1002](common)
username=1002
secret=1002
 
[1003](common)
username=1003
secret=1003
 
[1004](common)
username=1004
secret=1004
 
[trunk]
type=friend
context=internal
host=
disallow=all
allow=ulaw
allow=alaw
allow=g723
allow=g729
dtmfmode=rfc2833
 
Now you have to add one line to extension.conf:
 
exten =&gt; _XXXXXXX.,1,Dial(SIP/trunk1/${EXTEN})
 
So our extension.conf looks like:
 
[internal]
exten=&gt; _XXXX,1,Dial(SIP/${EXTEN})
exten =&gt; _XXXXXXX.,1,Dial(SIP/trunk1/${EXTEN})
As the above setting, it is simple to create an IP-PBX with the outbound trunk. Gventure will provide you one of the best services and will fulfil all of your demands in the Asterisk Development.

Tagged:  

Cyclic Replication Between MySQL 5.1 DB

Currently we are doing replication between two servers i.e. VPN3 and VPN4. Our project needed persistent backup of the business critical database on another server as we don't want to loose any data while server goes down. So we have implemented below mentioned steps. We are using MySQL 5.1 version of mysql. Any higher version is also suitable, as performance of replication has been increased in MySQL 5.6 and above. So below mentioned steps are tested successfully on MySQL5.1, however the same steps might work for other version, that you need to sort out.

  • Step 01: Add my.cnf files as mentioned in the /etc/my.cnf (this holds several mysql environment variables and values for smooth performance of the mysql).Run below queries on both the server to create a user which will handle replications between these two servers. mysql > create user 'replicator' identified by 'replicator';
  • Step 02: Once added these files according to server replication architecture you are following.Reboot the services of mysqld to take effect of changes. mysql> Service mysqld restart on all server you want to do replication settings.(Currently we are doing between two servers, but cyclic replication can be done between multiple servers as per project need).
  • Step 03: Create GRANT access for replication user on each server i.e. VPN3 and VPN4 On VPN3 run following command on mysql CLI MYSQL>GRANT REPLICATION SLAVE ON *.* TO 'replicator'@'10.3.140.70' IDENTIFIED BY 'replicator'; MYSQL> FLUSH PRIVILEGES; On VPN4 run following command on mysql CLI MYSQL> GRANT REPLICATION SLAVE ON *.* TO 'replicator'@'10.34.188.148' IDENTIFIED BY 'replicator'; MYSQL> FLUSH PRIVILEGES; You can verify the replication user added on mysql by running following commands. mysql> select user,host from mysql.user; Also verify the permissions status by running below command mysql> select * from mysql.user where user='replicator';
  • Step 04: Run mysql query on VPN4 server MYSQL> SHOW MASTER STATUS; +------------------+----------+--------------+------------------+ | File             | Position | Binlog_Do_DB | Binlog_Ignore_DB | +------------------+----------+--------------+------------------+ | mysql-bin.000002 | 35271224 |              |                  | +------------------+----------+--------------+------------------+ 1 row in set (0.00 sec) and then run below mentioned mysql command on slave i.e. on VPN3 server with above mentioned details of File and Position in it. MYSQL> CHANGE MASTER TO MASTER_HOST='192.168.1.21', MASTER_PORT=3306, MASTER_USER='replicator', MASTER_PASSWORD='replicator', MASTER_LOG_FILE='mysql-bin.000002', MASTER_LOG_POS=35271224;
  • Step 05: Run mysql query on VPN3 server MYSQL> SHOW MASTER STATUS; +------------------+----------+--------------+------------------+ | File             | Position | Binlog_Do_DB | Binlog_Ignore_DB | +------------------+----------+--------------+------------------+ | mysql-bin.000003 | 37416567 |              |                  | +------------------+----------+--------------+------------------+ 1 row in set (0.00 sec) and run this mysql command on slave i.e. on VPN4 server with above mentioned details of File and Position in it. MYSQL> CHANGE MASTER TO MASTER_HOST='192.168.1.21', MASTER_PORT=3306, MASTER_USER='replicator', MASTER_PASSWORD='replicator', MASTER_LOG_FILE='mysql-bin.000003', MASTER_LOG_POS=37416567;
  • Step 06: Run mysql query on VPN4 server MYSQL> START SLAVE; Wait 5 seconds , then on Server VPN4 MYSQL> SHOW SLAVE STATUS\G If Slave_IO_Running=Yes and Slave_SQL_Running=Yes, replication is working on VPN4
  • Step 07: Run mysql query on VPN3 server MYSQL> START SLAVE; Wait 5 seconds,then  on Server VPN3 MYSQL> SHOW SLAVE STATUS\G If Slave_IO_Running=Yes and Slave_SQL_Running=Yes, replication is working.

Now replication is successfully set on both the servers. Changes from one server will automatically copied to another mysql server. Changes always flow from Master Server to Slave Server. As this is asynchronous process so there is slight delay in the copy of data from one server to another server. Generally this process is used for persistent backup of the DB to another server. Since we have created both servers as Master and Slave as well. So any changes on server VPN4 will be reflected back to VPN3 and vice versa.

Tagged:  
MySQL,