You are on page 1of 5

INSTALACION DE KAMAILIO

1.descargar kamailio y kamailio-mysql de la pagina oficial


2.instalar lo siguiente:
#yum -y install mysql-server
#rpm -i kamailio..rpm
#rpm -i kamailio-mysql..rpm
3.editar los siguientes archivos:
#gedit /etc/init.d/kamailio ->RUN_KAMAILIO=yes
#gedit /etc/kamailio/kamailio.cfg ->#!define WITH_MYSQL
->#!define WITH_AUTH
->#!define WITH_USRLOCDB
#gedit /etc/default/kamailio -> RUN_KAMAILI=yes
#gedit /etc/kamailio/kamctlrc -> SIP_DOMAIN=kamailio.org
-> DBENGINE=MYSQL

4.iniciar los servicios mysqld y kamailio


#service mysqld start
#service kamailio start
5.crear una base de datos
#kamdbctl create ->yes a todo
6.Ahora ya podemos crear cuentas:
#kamctl add "cuenta" "password"
MYSQL password for user 'kamailio@localhost': [enter]
Enter password: kamailiorw [enter]
new user "cuenta" added ----> LISTO!

INTEGRACION CON ASTERISK

1.Necesitamos cambiar la configuracion de kamailio -> kamailio.cfg

2.A�adir
#!define WITH_ASTERISK

####### Defined Values #########

...
#!ifndef DBURL
#!ifdef WITH_ASTERISK
#!define DBASTURL "mysql://asterisk:asterisk_password@localhost/asterisk"
#!endif
#!define DBURL "mysql://kamailio:kamailiorw@localhost/kamailio"
...

####### Custom Parameters #########

...
#!ifdef WITH_VOICEMAIL
..
#!endif

#!ifdef WITH_ASTERISK
asterisk.bindip = "192.168.178.25" desc "Asterisk IP Address"
asterisk.bindport = "5080" desc "Asterisk Port"
kamailio.bindip = "192.168.178.25" desc "Kamailio IP Address"
kamailio.bindport = "5060" desc "Kamailio Port"
#!endif

####### Modules Section ########

...
#!ifdef WITH_DEBUG
...
#!endif

#!ifdef WITH_ASTERISK
loadmodule "uac.so"
#!endif

# ----------------- setting module-specific parameters ---------------

# ----- tm params -----


...

# ----- rr params -----


...
modparam("rr", "append_fromtag", 0)
#!ifdef WITH_ASTERISK
modparam("rr", "append_fromtag", 1)
#!else

...

# ----- permissions params -----


#!ifdef WITH_IPAUTH
...
#!endif

#!ifdef WITH_ASTERISK
modparam("auth_db", "user_column", "name")
modparam("auth_db", "password_column", "sippasswd")
modparam("auth_db", "db_url", DBASTURL)
modparam("auth_db", "version_table", 0)
#!else
modparam("auth_db", "db_url", DBURL)
modparam("auth_db", "password_column", "password")
modparam("auth_db", "use_domain", MULTIDOMAIN)
#!endif

#!endif
# ----- alias_db params -----

####### Routing Logic ########

# Main SIP request routing logic


...
# Wrapper for relaying requests
route[RELAY] {
..
# Per SIP request initial checks
route[REQINIT] {
...
# Handle requests within SIP dialogs
route[WITHINDLG] {
...
# Handle SIP registrations
route[REGISTRAR] {
...
}
if (!save("location"))
sl_reply_error();

#!ifdef WITH_ASTERISK
route(REGFWD);
#!endif
exit;
}
...
# User location service
route[LOCATION] {
...
#!ifdef WITH_ALIASDB
...
#!endif

#!ifdef WITH_ASTERISK
if(is_method("INVITE") && (!route(FROMASTERISK))) {
# if new call from out there - send to Asterisk
# - non-INVITE request are routed directly by Kamailio
# - traffic from Asterisk is routed also directy by Kamailio
route(TOASTERISK);
exit;
}
#!endif

$avp(oexten) = $rU;
if (!lookup("location")) {

...

# Presence server processing


route[PRESENCE] {
...
# IP authorization and user uthentication
route[AUTH] {
#!ifdef WITH_AUTH

#!ifdef WITH_ASTERISK
# do not auth traffic from Asterisk - trusted!
if(route(FROMASTERISK))
return;
#!endif
...
if (is_method("REGISTER") || from_uri==myself)
{
# authenticate requests

#!ifdef WITH_ASTERISK
if (!auth_check("$fd", "sipusers", "1")) {
#!else
if (!auth_check("$fd", "subscriber", "1")) {
#!endif
if (!auth_check("$fd", "subscriber", "1")) {
auth_challenge("$fd", "0");
exit;
}
# user authenticated - remove auth header
if(!is_method("REGISTER|PUBLISH"))
...
route[NATDETECT] {
..
# RTPProxy control and singaling updates for NAT traversal
route[NATMANAGE] {
...
# Routing to foreign domains
route[SIPOUT] {
..
# PSTN GW routing
route[PSTN] {
...
# XMLRPC routing
#!ifdef WITH_XMLRPC
route[XMLRPC] {
...
# Routing to voicemail server
route[TOVOICEMAIL] {
...
#!ifdef WITH_VOICEMAIL
# serial forking
# - route to voicemail on busy or no answer (timeout)
if (t_check_status("486|408")) {
$du = $null;
route(TOVOICEMAIL);
exit;
}
#!endif
}

#!ifdef WITH_ASTERISK
# Test if coming from Asterisk
route[FROMASTERISK] {
if($si==$sel(cfg_get.asterisk.bindip)
&& $sp==$sel(cfg_get.asterisk.bindport))
return 1;
return -1;
}

# Send to Asterisk
route[TOASTERISK] {
$du = "sip:" + $sel(cfg_get.asterisk.bindip) + ":"
+ $sel(cfg_get.asterisk.bindport);
route(RELAY);
exit;
}

# Forward REGISTER to Asterisk


route[REGFWD] {
if(!is_method("REGISTER"))
{
return;
}
$var(rip) = $sel(cfg_get.asterisk.bindip);
$uac_req(method)="REGISTER";
$uac_req(ruri)="sip:" + $var(rip) + ":" + $sel(cfg_get.asterisk.bindport);
$uac_req(furi)="sip:" + $au + "@" + $var(rip);
$uac_req(turi)="sip:" + $au + "@" + $var(rip);
$uac_req(hdrs)="Contact: <sip:" + $au + "@"
+ $sel(cfg_get.kamailio.bindip)
+ ":" + $sel(cfg_get.kamailio.bindport) + ">\r\n";
if($sel(contact.expires) != $null)
$uac_req(hdrs)= $uac_req(hdrs) + "Expires: " + $sel(contact.expires) +
"\r\n";
else
$uac_req(hdrs)= $uac_req(hdrs) + "Expires: " + $hdr(Expires) + "\r\n";
uac_req_send();
}
#!endif

3. service kamailio restart -->LISTO!

You might also like