Installation of OpenSIPS 1.6

Exclusive offer: get 50% off this eBook here
Building Telephony Systems with OpenSIPS 1.6

Building Telephony Systems with OpenSIPS 1.6 — Save 50%

Build scalable and robust telephony systems using SIP

£16.99    £8.50
by Flavio E. Goncalves | January 2010 | Networking & Telephony Open Source

The installation is just the beginning of the work. It is very important to install OpenSIPS correctly from the source code. It can be installed much faster from the Debian packages or using the apt-get utility. However, installation from the source code is much more flexible as it allows you to select the modules to be compiled.
In this article,by Flavio E. Goncalves, we will see how to:

  • Install Linux prepared for OpenSIPS
  • Download OpenSIPS source and its dependencies
  • Compile and install OpenSIPS with MySQL and RADIUS support
  • Start and stop OpenSIPS
  • Configure Linux systems to start OpenSIPS at boot time

So, we won't use any shortcuts in the installation. I strongly advise you to install OpenSIPS using Debian.

If you choose to install on another platform, you will have to deal with init scripts and fix the installation of the other packages.

Hardware requirements

There are no minimum hardware requirements for OpenSIPS. It will run on an ordinary PC. The best bets we have are from performance tests realized on the 1.2 version. A PC with the following specifications was capable of 28 million complete calls per hour. The testing server was an ordinary desktop—Intel(R) Core(TM)2 CPU 6300 @ 1.86GHz, 1 GB of memory, and 100 MBps Ethernet card. Unfortunately, there are currently no formulas for OpenSIPS dimensioning. The correct hardware, CPU, and memory shall be obtained empirically.

Software requirements

The OpenSIPS software runs on a variety of platforms such as Linux, BSD, and Solaris. Some generic packages are available to certain versions of Linux and Solaris. These packages can be downloaded from www.opensips.org/Resources/Downloads. The following packages are required to compile OpenSIPS.

  • gcc (or any other C compiler as suncc or icc)
  • bison or yacc (Berkley yacc)
  • flex
  • GNU make
  • GNU tar
  • GNU install
  • libxml2-dev (if you want to use the presence modules)
  • libxml-rpc (for mi_xmlrpc)

Some modules such as MySQL, POSTGRES, RADIUS, and others will require additional packages for compilation.


Books from Packt

Beginning OpenVPN 2.0.9
Beginning OpenVPN 2.0.9

Asterisk 1.4 – the Professional’s Guide
Asterisk 1.4 – the Professional’s Guide

Cacti 0.8 Network Monitoring
Cacti 0.8 Network Monitoring

FreePBX 2.5 Powerful Telephony Solutions
FreePBX 2.5 Powerful Telephony Solutions

Funambol Mobile Open Source
Funambol Mobile Open Source

Zabbix 1.8 Network Monitoring [RAW]
Zabbix 1.8 Network Monitoring [RAW]

Asterisk 1.6
Asterisk 1.6

Building Enterprise Ready Telephony Systems with sipXecs 4.0
Building Enterprise Ready Telephony Systems with sipXecs 4.0

 


Lab—installing Linux for OpenSIPS

All of these labs were prepared using a VMware virtual machine with Debian installed. You may download it from http://cdimage.debian.org/debian-cd/.

Warning:
The instructions for this lab formats the computer. Back up all the data on your PC before proceeding or follow these instructions in a virtual environment such as VMware or XEN.

The steps for installing Linux are as follows:

Step 1: Insert the CD and boot the computer using Debian. Press Enter to start the installation.

OpenSIPS 1.6

Here, you can also select boot and installation options. Sometimes you may need to choose some hardware-specific parameters for your installation. Press F1 for help, if needed.

Step 2:Choose a language of your preference for use in the installation process.

OpenSIPS 1.6

Downloading and installing OpenSIPS v1.6.

Step 3: Choose the keyboard layout.

OpenSIPS 1.6

It is very common to have to choose a keyboard layout, especially in European and Asian countries.

Step 4: Choose the Hostname.

OpenSIPS 1.6

It is important to choose the name of the server because later you will use this name to access the server.

Step 5: Choose the Domain name.

OpenSIPS 1.6

The domain name is obvious but important because OpenSIPS use domains to distinguish users, so be sure to enter the domain name correctly.

Step 6: Choose a Partitioning method.

OpenSIPS 1.6

Linux geeks, certainly, will use the manual option. For the purpose of learning, you can simply use the entire disk. Consult a Linux specialist for the best partitioning scheme for your server.

Step 7: Select disk to partition.

OpenSIPS 1.6

Now select the disk being used to install Linux.

Step 8 : Select All files in one partition (recommended for new users).

OpenSIPS 1.6

Again, you can choose how to partition the system. Let's stick with the default installation again. Some advanced users may want to change it.

Step 9: Now Finish the partitioning and write changes to disk.

OpenSIPS 1.6

Now finish the partitioning step and write changes to the disk. However, never do it if you want to preserve your disk. After the partitioning, all the pre-existing content of the disk will be erased. So think carefully before doing this. I use VMware to test OpenSIPS; it is free and creates a virtual machine where I can work safely

Step 10: Write changes to the disk.

OpenSIPS 1.6

Here comes the scary part. Confirm that you want to erase all the content of the disk. Well, think twice or even thrice before saying Yes.

WARNING:
All data on the disk will be destroyed!

Step 11: Now Configure time zone.

OpenSIPS 1.6

Select the time zone. It is important to have the correct time zone, mainly for reports. If you don't see it correctly, you will end up with voicemail messages having the wrong time.

Step 12: Set the Root password to OpenSIPs.

OpenSIPS 1.6

Choose a password for your root user. This is the most important password on the system.

Building Telephony Systems with OpenSIPS 1.6 Build scalable and robust telephony systems using SIP
Published: January 2010
eBook Price: £16.99
Book Price: £27.99
See more
Select your format and quantity:

Step 13: Re-enter password to verify.

OpenSIPS 1.6

Please re-enter the password for confirmation purpose. Try to use a password that is hard to crack (a password having minimum eight characters comprising of letters, numbers, and some special characters such as "*" or "#").

Step 14: Enter the Full name for the new user as opensips

OpenSIPS 1.6

Some systems require you to create at least one user. Let's do it, starting with the full username.

Step 15: Enter the name for the user account as opensips.

OpenSIPS 1.6

Step 16: Enter the password for the user account as opensips and re-enter to confirm.

OpenSIPS 1.6

Enter the password and confirm it. Again, try to use a password that is hard to crack.

Step 17: Configure the package manager. Select Yes to use a mirror.

OpenSIPS 1.6

During the process of installation, we will use several packages distributed by Debian.

Step 18: Select a mirror country.

OpenSIPS 1.6

This screen will allow you to select the place from where you will download the packages.

Step 19: Select ftp.debian.org or your preferred mirror. Select the one nearest to your network to speed up the download of the packages.

OpenSIPS 1.6

Step 20: Leave the Http proxy information blank or enter the appropriate parameters.

OpenSIPS 1.6

If you use an HTTP proxy such as Squid or Microsoft SA Server, please enter the appropriate parameters to allow Internet access for downloads.

Step 21: Select No to package popularity survey.

OpenSIPS 1.6

The popularity package survey generates statistics about the most downloaded packages.

Step 22: Select Standard system.

OpenSIPS 1.6

Debian comes in several predefined installations such as desktop, server, and standard system. The desktop installation, as an example, installs a GUI for Linux such as GNOME or KDE. We don't need this for our installation. Therefore, choose Standard system. Later, we will manually install components such as the Web server, Mail server, and SQL database.

Step 23: Select Yes to install the GRUB boot loader.

OpenSIPS 1.6

GRUB is a boot load manager for your server. It allows you to dual boot systems and do some tricks during the boot process.

Step 24: Finish the Installation.

OpenSIPS 1.6

Finish the installation and boot the system. The system will now reboot automatically.

Step 25: Just after the reboot, install SSH as follows:

apt-get install ssh
Building Telephony Systems with OpenSIPS 1.6 Build scalable and robust telephony systems using SIP
Published: January 2010
eBook Price: £16.99
Book Price: £27.99
See more
Select your format and quantity:

Downloading and installing OpenSIPS v1.6.x

Although it is easier to install OpenSIPS using the Debian packages, we will go through the compilation process. It is more flexible and we may need to recompile OpenSIPS a few times in this material to include other modules. The step-by-step installation process is as follows:

Step 1: Install the dependencies.

apt-get install gcc bison flex make openssl libmysqlclient-dev
libradiusclient-ng2 libradiusclient-ng-dev mysql-server libxmlrpc-c3-dev

The MySQL server is not really a dependency, but we will install it at this moment to make things easier.

Step 2: Download the source pack ages and decompress them. (Replace x with the current version.) There are two packages—tls and no-tls. The tls package contains the tls directory and some changes in the core to support encryption for the signaling.

cd /usr/src
wget http://opensips.org/pub/opensips/1.6.x/
src/opensips-1.6.x-tls_src.tar.gz

tar -xzvf opensips-1.6.x-tls_src.tar.gz

Step 3: Compile and install the core and the modules. Include the db_mysql and aaa_radius modules.

cd opensips-1.6.x.tls
make prefix=/ all include_modules="db_mysql aaa_radius"
make prefix=/ install include_modules="db_mysql aaa_radius"

Step 4: Make the required adjustments

mkdir /var/run/opensips

Warning:
The detailed instructions change often. Please check the OpenSIPS website for updates.

OpenSIPS console

OpenSIPS comes with a new administration utility called osipsconsole. This utility is written in the PERL language and uses some additional libraries. To install, carry out the following instructions:

Step 1: Download the dependencies.

apt-get install libdbi-perl libdbd-mysql-perl libfrontier-rpc-perl
libterm-readline-gnu-perl

Step 2: Try running the console

osipsconsole

In the console prompt, try using the help and quit commands.

Lab—running OpenSIPS at the Linux boot

In order to run OpenSIPS at the Linux boot, perform the following steps:

Step 1: Include OpenSIPS in the Linux boot

cd /usr/src/opensips-1.6.x-tls/packaging/debian
cp opensips.default /etc/default/opensips
cp opensips.init /etc/init.d/opensips
update-rc.d opensips defaults 99

Step 2: Edit the /etc/opensips/opensips.cfg and remove the fork=no line (even if it was with C-style remarks). The init script looks for the instruction fork=no, even if commented.

Step 3: Make sure that the opensips.init script has the necessary permissions.

cd /etc/init.d
chmod 755 opensips

Step 4: Edit /etc/default/opensips, and change the memory parameter to 128 MB and RUN_OPENSIPS to yes.

Step 5: Edit the init script to make sure that the daemon is pointing to the correct directory.

vi /etc/init.d/opensips

The file before making changes:

DAEMON=/usr/sbin/opensips

The file before after changes:

DAEMON=/sbin/opensips

Step 6: Restart the computer to see if OpenSIPS starts. Confirm this using:

ps-ef |grep opensips

It is highly recommended that you change the username and password used to run OpenSIPS in the /etc/init.d/opensips file.

OpenSIPS v1.6.x directory structure

After the installation, OpenSIPS will create a file structure. It is important to understand the file structure in order to locate the main folders where the system is stored. You will need this information to update or remove the software.

Configuration files (etc/opensips)

These are the files copied to this directory. The files include the RADIUS dictionary to be used for OpenSIPS, the main configuration file opensips.cfg, the opensipsctl resource file, opensipsctlrc, and the osipsconsole resource file, osipconsolerc.

opensips-1:/etc/opensips # ls -l
total 20
-rw-r--r-- 1 root staff 1559 2009-10-09 16:59 dictionary.opensips
-rw-r--r-- 1 root staff 1559 2009-10-09 17:04 dictionary.opensips.
sample
-rw------- 1 root staff 12437 2009-10-09 18:34 opensips.cfg
-rw-r--r-- 1 root staff 3661 2009-08-24 11:27 opensipsctlrc
-rw-r--r-- 1 root staff 2878 2009-05-19 14:02 osipsconsolerc

Modules (/lib/opensips/modules)

This directory contains all the modules compiled for OpenSIPS. It is where you should look for missing modules.

opensips-1:/lib/opensips/modules# ls

aaa_radius.so diversion.so options.so rr.so
acc.so domainpolicy.so path.so seas.so
alias_db.so domain.so pdt.so signaling.so
auth_aaa.so drouting.so peering.so siptrace.so
auth_db.so enum.so permissions.so sl.so
auth_diameter.so exec.so pike.so sms.so
auth.so gflags.so presence_dialoginfo.so speeddial.so
avpops.so group.so presence_mwi.so sst.so
b2b_entities.so imc.so presence.so statistics.so
benchmark.so lcr.so presence_xcapdiff.so stun.so
call_control.so load_balancer.so presence_xml.so textops.so
cfgutils.so localcache.so pua_bla.so tm.so
closeddial.so mangler.so pua_dialoginfo.so uac_redirect.so
db_flatstore.so maxfwd.so pua_mi.so uac.so
db_mysql.so mediaproxy.so pua.so uri_db.so
db_text.so mi_datagram.so pua_usrloc.so uri.so
db_virtual.so mi_fifo.so pua_xmpp.so userblacklist.so
dialog.so msilo.so qos.so usrloc.so
dialplan.so nathelper.so ratelimit.so xlog.so
dispatcher.so nat_traversal.so registrar.so

Binaries (/sbin)

This is where the binary files are found. It is useful to know where these directories are, in case you want to uninstall OpenSIPS.

openip s-1:/sbin# ls -l o p*
total 2832
-rwxr-xr-x 1 root staff 2594007 2009-10-09 17:04 opensips
-rwxr-xr-x 1 root staff 52695 2009-10-09 17:04 opensipsctl
-rwxr-xr-x 1 root staff 6270 2009-10-09 17:04 opensipsdbctl
-rwxr-xr-x 1 root staff 13442 2009-10-09 17:04 opensipsunix
-rwxr-xr-x 1 root staff 212692 2009-10-09 17:04 osipsconsole

Log files

The initialization log can be seen at syslog (/var/log) as follows:

Sep 10 14:25:56 Opensips-1 Opensips: init_tcp: using epoll_lt as the io watch
method (auto detected)
Sep 10 14:25:56 Opensips-1 /sbin/Opensips[7791]: INFO: statistics manager
successfully initialized
Sep 10 14:25:56 Opensips-1 /sbin/Opensips[7791]: StateLess module -
initializing
Sep 10 14:25:56 Opensips-1 /sbin/Opensips[7791]: TM - initializing...
Sep 10 14:25:56 Opensips-1 /sbin/Opensips[7791]: Maxfwd module- initializing
Sep 10 14:25:56 Opensips-1 /sbin/Opensips[7791]: INFO:ul_init_locks: locks
array size 512
Sep 10 14:25:56 Opensips-1 /sbin/Opensips[7791]: TextOPS - initializing
Sep 10 14:25:56 Opensips-1 /sbin/Opensips[7791]: INFO: udp_init: SO_RCVBUF is
initially 109568
Sep 10 14:25:56 Opensips-1 /sbin/Opensips[7791]: INFO: udp_init: SO_RCVBUF is
finally 262142
Sep 10 14:25:56 Opensips-1 /sbin/Opensips[7791]: INFO: udp_init: SO_RCVBUF is
initially 109568
Sep 10 14:25:56 Opensips-1 /sbin/Opensips[7791]: INFO: udp_init: SO_RCVBUF is
finally 262142
Sep 10 14:25:56 Opensips-1 /sbin/Opensips[7792]: INFO:mi_fifo:mi_child_
init(1): extra fifo listener processes created

Redirecting OpenSIPS log files

By default, the log files are sent to the syslog and are shown at /var/log/syslog. Sometimes this is not good, because you have OpenSIPS logs mixed with other system's logs. You may redirect the logs to a specific file by changing the syslog configuration file.

Step 1: Redirecting log files to local 0 facility.

Change the opensips.cfg file and include the following command:

log_facility=LOG_LOCAL0

Step 2: Create the log file in the /var/log directory

cd /var/log
touch opensips.log

Step 3: Change the file /etc/syslog.conf and include the highlighted command.

lpr.* -/var/log/lpr.log
mail.* -/var/log/mail.log
user.* -/var/log/user.log
local0.* -/var/log/opensips.log

Step 4: Restart the syslog server and OpenSIPS and check the file /var/log/opensips.log.

/etc/init.d/sysklogd restart
/etc/init.d/opensips restart
cat /var/log/syslog

Startup options

OpenSIPS can be started using the init scripts or using the opensipsctl utility. If you start OpenSIPS using init scripts, you can stop OpenSIPS using init scripts only. The same is valid if you start using opensipsctl utility.

Starting, stopping, and restarting OpenSIPS using the init scripts:

/etc/init.d/opensips start|stop|restart

Starting, stopping, and restarting OpenSIPS using the opensipsctl utility:

opensipsctl start|stop|restart

The OpenSIPS executable has several startup options. The following options allow you to change the configuration of the DAEMON. Some of the most useful options are:

  • -c to check the configuration file
  • -D –E dddddd to check module loading (don't use for production, it binds only the first interface)

There are many other options that allow you to fine-tune your configuration. For each option, there is a related core parameter that you can put in the configuration file.

debian:/sbin# opensips -h
version: opensips 1.6.0-notls (i386/linux)
Usage: opensips -l address [-l address ...] [options]

Options:

-f     file                  Configuration file (default //etc/opensips/opensips.cfg)

-c                           Check configuration file for errors

-C                          Similar to '-c' but in addition checks the flags of exported

                              functions from included route blocks

-l                            address Listen on the specified address/interface (multiple -l  mean

                              listening on more addresses). The address format is

                              [proto:]addr[:port], where proto=udp|tcp

                              and  addr= host|ip_address|interface_name. E.g: -l locahost,

                               -l udp:127.0.0.1:5080, -l eth0:5062. The default behavior

                              is to listen on all the interfaces.

-n    processes      Number of child processes to fork per interface

                             (default: 8)

-r                          Use dns to check if is necessary to add a "received=" 

                             field to a via

-R                         Same as '-r' but use reverse dns;

                             (to use both use '-rR')

-v                         Turn on "via:" host checking when forwarding replies

-d                         Debugging mode (multiple -d increase the level)

-D                         Do not fork into daemon mode

-E                         Log to stderr

-T                         Disable tcp

-N    processes    Number of tcp child processes (default: equal to '-n')

-W                       method poll method

-V                        Version number

-h                         This help message

-b    nr                 Maximum receive buffer size which will not be exceeded by  auto-probing procedure even if OS allows

-m    nr                Size of shared memory allocated in Megabytes

-w    dir               Change the working directory to "dir" (default "/")

-t    dir                 Chroot to "dir" 

-u    uid                Change uid.

-g    gid                Change gid

-P    file                Create a pid file

-G   file                Create a pgid file.

Summary

In this article, you have learned how to install and prepare Linux for the OpenSIPS installation. We have downloaded and compiled OpenSIPS with the Radius and MySQL modules. After the installation, we included the OpenSIPS init file to start OpenSIPS at boot time.

 

If you have read this article you may be interested to view :

 

About the Author :


Flavio E. Goncalves

Flavio E.Goncalves was born in 1966 in Brazil. Having always had a strong interest in computers, he got his first personal computer in 1983 and since then it has been almost an addiction. He received his degree in Engineering in 1989 with a focus on computer-aided design and computer-aided manufacturing.

He is also the CEO of V.Office Networks in Brazil—a consulting company dedicated to the areas of Networks, Security, and Telecommunications and a training center since its foundation in 1996. Since 1993, he has participated in a series of certification programs and been certificated as Novell MCNE/MCNI, Microsoft MCSE/MCT, Cisco CCSP/CCNP/CCDP, Asterisk dCAP, and some others.

He started writing about open source software because he thinks that the way certification programs were organized in the past was very good for helping learners. Some books today are written by strictly technical people who, sometimes, do not have a clear idea of how people learn. He tried to use his 15 years of experience as an instructor to help people learn about the open source telephony software. His experience with networks, protocol analyzers, and IP telephony combined with his teaching experience give him an edge to write this book. This is the third book written by him; the first one was "Configuration Guide for Asterisk PBX“, BookSurge Publishing.

As the CEO of V.Office, Flavio E. Goncalves balances his time between family, work, and fun. He is a father of two children and lives in Florianopolis, Brazil, one of the most beautiful places in the world. He dedicates his free time to water sports such as surfing and sailing.

You can contact him at flavio@asteriskguide.com, or visit his website www.asteriskguide.com.

Books From Packt

Beginning OpenVPN 2.0.9
Beginning OpenVPN 2.0.9

Asterisk 1.4 – the Professional’s Guide
Asterisk 1.4 – the Professional’s Guide

Cacti 0.8 Network Monitoring
Cacti 0.8 Network Monitoring

FreePBX 2.5 Powerful Telephony Solutions
FreePBX 2.5 Powerful Telephony Solutions

Funambol Mobile Open Source
Funambol Mobile Open Source

Zabbix 1.8 Network Monitoring [RAW]
Zabbix 1.8 Network Monitoring [RAW]

Asterisk 1.6
Asterisk 1.6

Building Enterprise Ready Telephony Systems with sipXecs 4.0
Building Enterprise Ready Telephony Systems with sipXecs 4.0

Code Download and Errata
Packt Anytime, Anywhere
Register Books
Print Upgrades
eBook Downloads
Video Support
Contact Us
Awards Voting Nominations Previous Winners
Judges Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software
Resources
Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software