Kamailio: Difference between revisions

From Alpine Linux
(Category:Telephony)
mNo edit summary
(2 intermediate revisions by one other user not shown)
Line 1: Line 1:
== Set up Kamailio on Alpine Linux ==
Kamailio (former OpenSER) is an Open Source SIP Server released under GPL, able to handle thousands of call setups per second. Among features: asynchronous TCP, UDP and SCTP, secure communication via TLS for VoIP (voice, video), SIMPLE instant messaging and presence, ENUM, least cost routing, load balancing, routing fail-over, accounting, authentication and authorization against MySQL, Postgres, Oracle, Radius, LDAP, XMLRPC control interface, SNMP monitoring. It can be used to build large VoIP servicing platforms or to scale up SIP-to-PSTN gateways, PBX systems or media servers like Asterisk, FreeSWITCH or SEMS.


Kamailio (former OpenSER) is an Open Source SIP Server released under GPL, able to handle thousands of call setups per second.  
This document will be a quick c/p guide to setup Kamailio 4.3.4 on Alpinelinux 3.3, and assume that you have already installed the alpinelinux base system.
Among features: asynchronous TCP, UDP and SCTP, secure communication via TLS for VoIP (voice, video), SIMPLE instant messaging
and presence, ENUM, least cost routing, load balancing, routing fail-over, accounting, authentication and authorization against
MySQL, Postgres, Oracle, Radius, LDAP, XMLRPC control interface, SNMP monitoring. It can be used to build large VoIP servicing
platforms or to scale up SIP-to-PSTN gateways, PBX systems or media servers like Asterisk™, FreeSWITCH™ or SEMS.


This document will be a quick c/p guide to setup Kamailio 3.1.1 on Alpinelinux 2.1, and assume that you have already installed the alpinelinux base system. What we will setup is the following:
= Upgrade Installation =


* Upgrade Installation
{{Cmd|echo 'http://dl-3.alpinelinux.org/alpine/v2.1/main/' >  /etc/apk/repositories
* Postgresql
apk upgrade -U}}
* Kamailio


== Upgrade Installation ==
= Install Postgresql =


echo 'http://dl-3.alpinelinux.org/alpine/v2.1/main/' >  /etc/apk/repositories
{{Cmd|apk add postgresql postgresql-client}}
apk upgrade -U
 
== Install Postgresql ==
 
apk add postgresql postgresql-client


* Setup postgresql
* Setup postgresql


#!sh
{{Cmd|/etc/init.d/postgresql setup}}
/etc/init.d/postgresql setup


* Direct logging information to syslog
== Direct logging information to syslog ==
The default behavior is to log activity to postmaster.log without rotation. This can result in large log files filling the ramdisk. Edit the postgresql.conf file to enable logging information to be sent to syslog (logs will appear in /var/log/messages which is rotated and older logs are automatically deleted).
The default behavior is to log activity to postmaster.log without rotation. This can result in large log files filling the ramdisk. Edit the postgresql.conf file to enable logging information to be sent to syslog (logs will appear in /var/log/messages which is rotated and older logs are automatically deleted).


The following command will update the file correctly.
The following command will update the file correctly.


#!sh
{{Cmd|<nowiki>sed "/^[# ]*log_destination/clog_destination = 'syslog'" -i /var/lib/postgresql/9.0/data/postgresql.conf</nowiki>}}
sed "/^[# ]*log_destination/clog_destination = 'syslog'" -i /var/lib/postgresql/9.0/data/postgresql.conf
 
== Start postgresql and enable auto start ==
 
{{Cmd|/etc/init.d/postgresql start
rc-update add postgresql}}


* Start postgresql and enable auto start
Create file for Kamailio to start after pg-restore when booting:


#!sh
{{Cmd|<nowiki>echo 'rc_after=pg-restore' > /etc/conf.d/kamailio</nowiki>}}
/etc/init.d/postgresql start
rc-update add postgresql


* Create file for Kamailio to start after pg-restore when booting:
= Install SIP Router (Kamailio) =


#!sh
==Install Kamailio ==
echo 'rc_after=pg-restore' > /etc/conf.d/kamailio


== Install SIP Router (Kamailio) ==
{{Cmd|apk add kamailio kamailio-presence kamailio-postgres}}
* Install kamailio  


apk add kamailio kamailio-presence kamailio-pcre kamailio-postgres
== Configuration of Kamailio ==


* Edit the kamctlrc file - uncomment and/or change the following variables. Please note that in your production environment it is recommended
Edit the kamctlrc file - uncomment and/or change the following variables. Please note that in your production environment it is recommended that usernames and passwords be customized (defaults as used below should be avoided if at all possible) for added security.
that usernames and passwords be customized (defaults as used below should be avoided if at all possible) for added security.  


sed "/^[# ]*SIP_DOMAIN/cSIP_DOMAIN=sip.<DOMAIN>.net" -i /etc/kamailio/kamctlrc
{{Cmd|<nowiki>sed "/^[# ]*SIP_DOMAIN/cSIP_DOMAIN=sip.<DOMAIN>.net" -i /etc/kamailio/kamctlrc
sed '/^[# ]*DBENGINE/cDBENGINE=PGSQL' -i /etc/kamailio/kamctlrc
sed '/^[# ]*DBENGINE/cDBENGINE=PGSQL' -i /etc/kamailio/kamctlrc
sed '/^[# ]*DBHOST/cDBHOST=localhost' -i /etc/kamailio/kamctlrc
sed '/^[# ]*DBHOST/cDBHOST=localhost' -i /etc/kamailio/kamctlrc
sed '/^[# ]*DBNAME/cDBNAME=openser' -i /etc/kamailio/kamctlrc
sed '/^[# ]*DBNAME/cDBNAME=openser' -i /etc/kamailio/kamctlrc
sed '/^[# ]*DBRWUSER/cDBRWUSER=openser' -i /etc/kamailio/kamctlrc
sed '/^[# ]*DBRWUSER/cDBRWUSER=openser' -i /etc/kamailio/kamctlrc
sed '/^[# ]*DBRWPW/cDBRWPW="openser"' -i /etc/kamailio/kamctlrc
sed '/^[# ]*DBRWPW/cDBRWPW="openser"' -i /etc/kamailio/kamctlrc
sed '/^[# ]*DBROUSER/cDBROUSER=openserro' -i /etc/kamailio/kamctlrc
sed '/^[# ]*DBROUSER/cDBROUSER=openserro' -i /etc/kamailio/kamctlrc
sed '/^[# ]*DBROPW/cDBROPW=openserro' -i /etc/kamailio/kamctlrc
sed '/^[# ]*DBROPW/cDBROPW=openserro' -i /etc/kamailio/kamctlrc
sed '/^[# ]*DBROOTUSER/cDBROOTUSER="postgres" ' -i /etc/kamailio/kamctlrc
sed '/^[# ]*DBROOTUSER/cDBROOTUSER="postgres" ' -i /etc/kamailio/kamctlrc</nowiki>}}


* Create Kamailio database
== Create the Kamailio database ==


echo postgres >/root/.pgpass
{{Cmd|<nowiki>echo postgres > /root/.pgpass
chmod 600 /root/.pgpass
chmod 600 /root/.pgpass
kamdbctl create openser
kamdbctl create openser</nowiki>}}


* Start Kamailio and setup for auto start on reboot
== Start Kamailio and setup for auto start on reboot ==


/etc/init.d/kamailio start
{{Cmd|<nowiki>/etc/init.d/kamailio start
rc-update add kamailio
rc-update add kamailio
echo 'rc_after=postgresql' >> /etc/conf.d/kamailio
echo 'rc_after=postgresql' >> /etc/conf.d/kamailio</nowiki>}}


* Create a few SIP ROUTER users (extensions)
= Create a few SIP ROUTER users (extensions) =


Note: You can add as many extensions you want to use this command: kamctl extension and password.  
{{Note|You can add as many extensions you want to use this command: kamctl extension and password.}}
Example:
Example:


kamctl add 5000 5000
{{Cmd|kamctl add 5000 5000
kamctl add 5001 5001
kamctl add 5001 5001}}


Xlite (or other Software-based IP Phone) can be used for this preliminary test.
Xlite (or other Software-based IP Phone) can be used for this preliminary test. You can register a soft-phone or sip-phone with the account "5000" and password "5000", using the SIP-Router aip as "domain" and other one with 5001 and call each other.
You can register a soft-phone or sip-phone with the account "5000" and password "5000", using the SIP-Router aip as "domain" and other one with 5001 and call each other.


[[Category:Telephony]]
[[Category:Telephony]]

Revision as of 18:36, 16 February 2016

Kamailio (former OpenSER) is an Open Source SIP Server released under GPL, able to handle thousands of call setups per second. Among features: asynchronous TCP, UDP and SCTP, secure communication via TLS for VoIP (voice, video), SIMPLE instant messaging and presence, ENUM, least cost routing, load balancing, routing fail-over, accounting, authentication and authorization against MySQL, Postgres, Oracle, Radius, LDAP, XMLRPC control interface, SNMP monitoring. It can be used to build large VoIP servicing platforms or to scale up SIP-to-PSTN gateways, PBX systems or media servers like Asterisk, FreeSWITCH or SEMS.

This document will be a quick c/p guide to setup Kamailio 4.3.4 on Alpinelinux 3.3, and assume that you have already installed the alpinelinux base system.

Upgrade Installation

echo 'http://dl-3.alpinelinux.org/alpine/v2.1/main/' > /etc/apk/repositories apk upgrade -U

Install Postgresql

apk add postgresql postgresql-client

  • Setup postgresql

/etc/init.d/postgresql setup

Direct logging information to syslog

The default behavior is to log activity to postmaster.log without rotation. This can result in large log files filling the ramdisk. Edit the postgresql.conf file to enable logging information to be sent to syslog (logs will appear in /var/log/messages which is rotated and older logs are automatically deleted).

The following command will update the file correctly.

sed "/^[# ]*log_destination/clog_destination = 'syslog'" -i /var/lib/postgresql/9.0/data/postgresql.conf

Start postgresql and enable auto start

/etc/init.d/postgresql start rc-update add postgresql

Create file for Kamailio to start after pg-restore when booting:

echo 'rc_after=pg-restore' > /etc/conf.d/kamailio

Install SIP Router (Kamailio)

Install Kamailio

apk add kamailio kamailio-presence kamailio-postgres

Configuration of Kamailio

Edit the kamctlrc file - uncomment and/or change the following variables. Please note that in your production environment it is recommended that usernames and passwords be customized (defaults as used below should be avoided if at all possible) for added security.

sed "/^[# ]*SIP_DOMAIN/cSIP_DOMAIN=sip.<DOMAIN>.net" -i /etc/kamailio/kamctlrc sed '/^[# ]*DBENGINE/cDBENGINE=PGSQL' -i /etc/kamailio/kamctlrc sed '/^[# ]*DBHOST/cDBHOST=localhost' -i /etc/kamailio/kamctlrc sed '/^[# ]*DBNAME/cDBNAME=openser' -i /etc/kamailio/kamctlrc sed '/^[# ]*DBRWUSER/cDBRWUSER=openser' -i /etc/kamailio/kamctlrc sed '/^[# ]*DBRWPW/cDBRWPW="openser"' -i /etc/kamailio/kamctlrc sed '/^[# ]*DBROUSER/cDBROUSER=openserro' -i /etc/kamailio/kamctlrc sed '/^[# ]*DBROPW/cDBROPW=openserro' -i /etc/kamailio/kamctlrc sed '/^[# ]*DBROOTUSER/cDBROOTUSER="postgres" ' -i /etc/kamailio/kamctlrc

Create the Kamailio database

echo postgres > /root/.pgpass chmod 600 /root/.pgpass kamdbctl create openser

Start Kamailio and setup for auto start on reboot

/etc/init.d/kamailio start rc-update add kamailio echo 'rc_after=postgresql' >> /etc/conf.d/kamailio

Create a few SIP ROUTER users (extensions)

Note: You can add as many extensions you want to use this command: kamctl extension and password.

Example:

kamctl add 5000 5000 kamctl add 5001 5001

Xlite (or other Software-based IP Phone) can be used for this preliminary test. You can register a soft-phone or sip-phone with the account "5000" and password "5000", using the SIP-Router aip as "domain" and other one with 5001 and call each other.