Professional Documents
Culture Documents
Igor Olemskoi
Follow
yum -y update && yum -y groupinstall core && yum -y groupinstall base && yum
-y install epel-release
iptables -A INPUT -m state --state NEW -m udp -p udp --dport 5060 -j ACCEPT
Next, we create the /etc/yum.repos.d/kamailio.repo file:
[kamailio]
name=RPMs for Kamailio on CentOS 6
type=rpm-md
baseurl=http://rpm.kamailio.org/stable/CentOS_6/
gpgcheck=1
gpgkey=http://rpm.kamailio.org/stable/CentOS_6/repodata/repomd.xml.key
enabled=1
and install Kamailio:
chkconfig mysqld on
chkconfig httpd on
chkconfig kamailio on
We then need to uncomment one string in the
/etc/kamailio/kamctlrc file:
DBENGINE=MYSQL
and specify the SIP_DOMAIN. Since we are setting up the
system on the local network, it is sufficient to specify the IP
address, which in our case is:
SIP_DOMAIN=192.168.0.237
There are database connection parameters below the
SIP_DOMAIN too, but we have no need to change them in this
example.
kamdbctl create
answering ‘yes’ to all of the questions.
#!KAMAILIO
#!define WITH_MYSQL
#!define WITH_AUTH
#!define WITH_USRLOCDB
#!define WITH_PRESENCE
#!define WITH_ACCDB
These directives turn on the necessary modules. For example,
‘WITH_MYSQL’ enables the loading of mysql.so:
#!ifdef WITH_MYSQL
loadmodule "db_mysql.so"
#!endif
We can load any module manually, but directives are more
convenient. ‘WITH_AUTH’, for example, allows users to register
on Kamailio with a username and password.
loadmodule "rtimer.so"
loadmodule "sqlops.so"
And then we add a module parameter before the routing
section, which starts with “####### Routing Logic
########” string:
modparam("sqlops", "sqlcon",
"cb=>mysql://kamailio:kamailiorw@localhost/kamailio")
We also need to add another route after the last string of the
route segment (it should be around line #910):
route[CDRS] {
sql_query("cb","call kamailio_cdrs()","rb");
sql_query("cb","call kamailio_rating('default')","rb");
}
It’s now time to start Kamailio and check its status:
If fact, Kamailio can work without a database — you can set all
the necessary parameters in the configuration file or in
external files, but using a database is more convenient
especially in large projects. Additionally, the database is used
by the Siremis web-interface, which we are about to install.
cd /usr/src
wget http://siremis.asipto.com/pub/downloads/siremis/siremis-4.3.0.tgz
cp -a siremis*/. /var/www/html
cd /var/www/html
make prepare
rm -rf /var/www/html/Makefile
rm -rf /var/www/html/Changelog
rm -rf /var/www/html/README
<Directory "/var/www/html/siremis">
AllowOverride All
Order allow,deny
<FilesMatch "\.xml$">
Order deny,allow
Deny from all
</FilesMatch>
<FilesMatch "\.inc$">
Order deny,allow
</FilesMatch>
</Directory><Directory "/var/www/html/openbiz">
AllowOverride All
Order deny,allow
</Directory><Directory "/var/www/html/misc">
AllowOverride All
Order deny,allow
</Directory>
Siremis 4.3.0 needs the ‘date.timezone’ parameter from the
php.ini, so let’s assign it (Europe/Moscow in this example):
date.timezone = Europe/Moscow
Siremis also requires a separate database. First, we’ll add a
user:
Now we can restart Apache and move to the final stage of the
installation of Siremis. Open your-ip/siremis in the browser:
Please note that there are default user passwords for Kamailio
and Siremis already entered into the form, and if you haven’t
changed them before, you don’t need to enter them manually
now.
Let’s try to make the first call through our brand new Kamailio.
We need to add a domain to the ‘Domain List’ in the ‘SIP
Admin’ menu. Kamailio will serve only domains (or IP
addresses) that are listed there.
loadmodule "dispatcher.so"
We also need to add two parameters:
The connection settings to the database with the Asterisk
servers list
The servers checking frequency, which helps avoid sending
calls to unavailable servers
modparam("dispatcher", "db_url",
"mysql://kamailio:kamailiorw@localhost/kamailio")
Let’s add the following condition to the start of the main route:
if ( method=="INVITE" ) {
ds_select_dst("1","4");
sl_send_reply("100","Trying");
forward();
exit();
}
When an INVITE request (an invitation to start a conversation)
comes, one of the servers from the group ‘1’ is chosen using
the strategy ‘4’ (round-robin). Then we send an answer to the
caller and transfer the call to its destination. Please note that
now every INVITE will be processed in this manner. Thus, we
won’t be able to call from 101 to 102 anymore, because such
a call will be dispatched to one of the Asterisk servers.
Inbound INVITE request will also be sent to the Asterisk
servers without any source checking.
[kamailio]
host=192.168.0.237
port=5060
insecure=invite
type=friend
context=from-pstn
Now we can use the web interface to add the Asterisk servers
to the Kamailio database:
‘Setid’ sets a group for the server, ‘Priority’ is not used in the
«round-robin» strategy, but may be used in other strategies,
‘Flags’ here means that this server is inactive by default, but
its state must be checked.
loadmodule "uac.so"
We will also set two parameters which are mandatory in this
case:
modparam("uac", "reg_db_url",
"mysql://kamailio:kamailiorw@localhost/kamailio")
modparam("rr", "append_fromtag", 0)
and replace it with:
modparam("rr", "append_fromtag", 1)
Now we can configure the registration. In order to load the
‘uac’ module, Kamailio must first be restarted: