Showing posts with label opensip. Show all posts
Showing posts with label opensip. Show all posts

Monday, 30 March 2015

opensips control panel installation (source : packetpub)

OpenSIPS Control Panel

This tool, also known as opensips-cp, is the new graphical user interface for the SIP proxy. It was designed to be the primary tool to provision parameters for the OpenSIPS modules in the database.
GUI for OpenSIPS 1.6
The screenshot shows the tools available for OpenSIPS Control Panel. This tool is focused on the provisioning of system parameters. As it is usual for the VoIP providers to develop their own interface with the end users, the tools to manage end users are not available. Developed using PHP, opensips-cp currently features the following modules:
  • CDRviewer
  • dialplan
  • domains
  • dispatcher
  • drouting
  • load balancer
  • Mi
  • Monit
  • nathelper
  • pdt
  • Permissions
  • siptrace
  • smonitor

Installation of opensips-cp

The step-by-step instructions to install opensips-cp in a server with Debian 5.0 are as follows:
Installation instructions change very often. For updates, check the opensips-cp project's website athttp://opensipscp.sourceforge.net/.
Step 1: Install Apache and PHP as follows:
apt-get install apache2 php5
Step 2: Install php5-mysql and php5-xmlrpc packages, and set the right parameters in the php.ini file. (It has been done for you to save time.)
apt-get install php5-mysql php5-xmlrpc php-pear
vi /etc/php5/apache2/php.ini
Please verify that you have set the short_open_tag = On ; option in your php.ini file.
Step 3: Download opensips-cp and untar the file.
Download opensips-cp from http://opensips-cp.sourceforge.net/index.php?req=download (or copy from DVD) and copy the opensip-cp_3.0.tgz file to /var/www as follows:
cd /var/www
wget http://sourceforge.net/projects/opensips-cp/files/opensipscp/
3.0/opensips-cp_3.0.tgz/download
tar -xzvf opensips-cp_3.0.tgz
chown www-data:www-data opensips-cp -R
Step 4: Install MDB2.
pear install MDB2
pear install MDB2#mysql
pear install log
Step 5: Configure Apache for OpenSIPS Control Panel. Edit the apache2.conf file.
vi /etc/apache2/apache2.conf
After doing so, include the following line below the last line:
Alias /cp "/var/www/opensips-cp/web"
Also, change the owner of the log file:
chown www-data:www-data /var/www/opensips-cp/config/access.log
Step 6: Install the cdr table schema:
cd /var/www/opensips-cp/web/tools/cdrviewer
mysql -D opensips -p < cdrs.sql
mysql -u root -p
mysql> use opensips
mysql -D opensips -p < opensips_cdrs_1_6.mysql
Step 7: Edit the cron_job/generate-cdrs.sh file and change the MySQL connection data (hostname, username, password, and database) as follows:
cd /var/www/opensips-cp/cron-job
vi generate_cdrs.sh
Step 8: Edit the /etc/crontab file and add the following line for a three-minute interval:
vi /etc/crontab
*/3 * * * * root /var/www/opensips-cp/cron_job/generate-cdrs.sh
Step 9: For the smonitor module, you must add two tables to the OpenSIPS database:
cd /var/www/opensips-cp/web/tools/smonitor
mysql -p opensips <tables.sql
Step 10: Add a cron job that collects data from the OpenSIPS machine(s). Here is a cron job that collects data at a one-minute interval. (This interval is not arbitrary. It must be set to one minute by design.)
vi /etc/crontab
* * * * * root php /var/www/opensips-cp/cron_job/get_opensips_stats.php >
/dev/null
The cron jobs do not need to run as root. You might want to change the user.
Step 11: Restart OpenSIPS and Apache.

Installing Monit

Monit is a system-monitoring utility that allows an admin to easily monitor files, processes, directories, or devices on your system. It can also be used for automatic maintenance/repairs by executing particular commands when errors arise. Providing instructions on how to install Monit is beyond the scope of this article, but we have provided some here in order to avoid errors when you select the Monit tool in the OpenSIPS-CP.
The step-by-step instructions are as follows:
Step 1: To install Monit on your server, simply use apt-get:
apt-get install monit
Step 2: Once installed, you'll find the main configuration file.
vi /etc/monit/monitrc
  set daemon 120
  set logfile syslog facility log_daemon
  set alert root@localhost
  set httpd port 2812 and
  use address yourdomain.com
  allow localhost # allow localhost to connect to the server and
  allow youripaddress # allow 192.168.1.2 to connect to the server,
  # You can give only one per entry
  allow admin:monit # user name and password for authentication.
  check process opensips with pidfile /var/run/opensips.pid
  #Below is actions taken by monit when service got stuck.
  start program = "/etc/init.d/opensips start"
  stop program = "/etc/init.d/opensips stop"
  # Admin will notify by mail if below of the condition satisfied.
  if cpu is greater than 70% for 2 cycles then alert
  if cpu > 90% for 5 cycles then restart
Step 3: After modifying the configuration file, you should check for the syntax to make sure that everything is correct. To do this, run:
# monit -t
Step 4: Edit the /etc/default/monit file and change the parameters as follows:
# You must set this variable to for 1 monit to start
startup=1
# To change the intervals which monit should run uncomment
# and change this variable.
# CHECK_INTERVALS=180

Configuring OpenSIPS Control Panel

Step 1: Configure the database access parameters. Edit the db.inc.php file, which is valid for all modules. You may change the database parameters for a single module inside the module configuration section.
For example:
cd /var/www/opensips-cp/config
vi db.inc.php
  //database host
  $config->db_host = "localhost";
  //database port - leave empty for default
  $config->db_port = "";
  //database connection user
  $config->db_user = "root";
  //database connection password
  $config->db_pass = "opensips";
  //database name
  $config->db_name = "opensips";
  if ($config->db_port != "")$config->db_host=$config->db_host":"
  $config->db_port;
Step 2: Configure the FIFO access in the boxes.global.inc.php file:
cd /var/www/opensips-cp/config/
vi boxes.global.inc.php
  $box_id=0;
  // mi host:port pair || fifo_file
  $boxes[$box_id]['mi']['conn']="/tmp/opensips_fifo";
  // monit host:port
  $boxes[$box_id]['monit']['conn']="127.0.0.1:2812";
  $boxes[$box_id]['monit']['user']="admin";
  $boxes[$box_id]['monit']['pass']="monit";
  $boxes[$box_id]['monit']['has_ssl']=0;
  // description (appears in mi , monit )
  $boxes[$box_id]['desc']="Primary SIP server";
  $boxes[$box_id]['assoc_id']=1;
  // enable local smonitor charts on this box : 0=disabled 1=enabled
  // (cron)
  $boxes[$box_id]['smonitor']['charts']=1;
Step 3: Access http://server_ip_address/cp and check each module for the correct functionality.

Monday, 17 November 2014

Opensips TLS Support

Preface

Secure call can be achieved by enabling TLS. Once implemented SIP UA can choose to use transport TLS instead of UDP or TCP. The advantage of choosing TLS is that the SIP traffic exchanged between SIP UA and OpenSIPS will be encrypted, meaning it will take a considerable amount of time and effort to read it without the encryption key, if not possible.
Please note that the media it self will not be protected by this setup. In order to also secure the media, SIP UA need to be configured to use mandatory SRTP. That will force SIP UA to encrypt the media before transfer.
Several free SIP UA examples known to work or provide TLS and SRTP:
To enable TLS support in OpenSIPS we need to follow these steps:
  1. OpenSIPS and its modules compiled with option TLS=1
  2. Create TLS certificates
  3. Configure opensips.cfg with TLS options
  4. Verify config and test
We already done the first step on compile time, so we will start with step 2 in this chapter.

Step 2: Create TLS certificates

Before we start please remember that our OpenSIPS is in /root/src/opensips/opensips-1.9.1-tls/ and our installed OpenSIPS config files are in /usr/local/etc/opensips/.
Copy example openssl certificates to /usr/local/etc/opensips/tls/:
 cd /root/src/opensips/opensips-1.9.1-tls/
 cp -rR etc/tls /usr/local/etc/opensips/
Re-create local root Certificate Authority (CA). First we need to edit the ca.conf:
 cd /usr/local/etc/opensips/tls/
 vi ca.conf
Look for Please update sentence somewhere in ca.conf, they are near the bottom of the file. Update certificates parameters to suit your setups. If possible the commonName parameter is unique.
Save ca.conf and exit editor.
Run this command to re-create root CA in /usr/local/etc/opensips/tls/rootCA/:
 opensipsctl tls rootCA
Continue the process creating certificates, now we need to create our server certificate:
 cd /usr/local/etc/opensips/tls/
 cp user.conf server.conf
 vi server.conf
Look for Please update sentence somewhere in server.conf, they are quite easy to find. Update certificates parameters to suit your setups. Make sure that commonName parameter is pointing to OpenSIPS server IP, or your domain name that will be use as OpenSIPS server IP.
Run this command to create server certificate in /usr/local/etc/opensips/tls/server/:
 opensipsctl tls userCERT server
There will be 3 important files created, they are:
  • /usr/local/etc/opensips/tls/server/server-cert.pem
  • /usr/local/etc/opensips/tls/server/server-privkey.pem
  • /usr/local/etc/opensips/tls/server/server-calist.pem.

Step 3: Configure opensips.cfg with TLS options

Edit /usr/local/etc/opensips/opensips.cfg and locate for option disable_tls. By default it should have sets disable_tls=yes, meaning TLS is disabled.
Change disable_tls=yes to disable_tls=no and then paste below options:
 disable_tls = no
 listen = tls:192.168.56.45:5061
 tls_verify_server = 1
 tls_verify_client = 1
 tls_require_client_certificate = 0
 tls_method = TLSv1
 tls_certificate = "/usr/local/etc/opensips/tls/server/server-cert.pem"
 tls_private_key = "/usr/local/etc/opensips/tls/server/server-privkey.pem"
 tls_ca_list = "/usr/local/etc/opensips/tls/server/server-calist.pem"
Save the file.
Please note that our OpenSIPS 101 in this exercise is 192.168.56.45. You should change this IP to your real OpenSIPS IP.

Step 4: Verify config and test

Verify your config:
 opensips -c
Restart OpenSIPS:
 /etc/init.d/opensips.init restart
Verify whether OpenSIPS is listening in port 5061:
 netstat -lnptu | grep opensips
Use server-calist.pem on client side, do not copy other files from /usr/local/etc/opensips/tls/server/.
You can use SIP UA with TLS supports to test TLS connection to OpenSIPS. SIP UA such as Minisip and SFLphone in Linux or MicroSIP and Blink in Windows are good to use as they are free and easy to use.
On SIP UA, if possible we should disable other protocol (sometime referred as transport) and make sure we have only select TLS. Use port 5061 instead of 5060 to connect to OpenSIPS using TLS.
Some SIP UA do not have special feature to load certificates from its GUI. In this case you should import your server-calist.pem into your OS certificate repository (sometime referred as key store).
Same goes to mobile devices such as Android phone or iPhone, you should load server-calist.pem into its certificate repository rather then to load it from mobile SIP UA GUI.
Debugging SIP traffics over TLS on port 5061:
 ngrep -p -q -W byline port 5061
You should notice packets are captured but displayed as unreadable characters.
Try to make calls in TLS mode, and also try with mandatory SRTP enabled.

E-mail Newsletter

Sign up now to receive breaking news and to hear what's new with us.

Recent Articles

© 2014 VOIP4Learn. WP themonic converted by Bloggertheme9. Powered by Blogger.
TOP