[SR-Users] Fwd: kamailio registering on back-end asterisk with username and password

Paul Penev ppquant at gmail.com
Sun Sep 29 02:27:50 CEST 2013

Hello all,

I'm trying to implement a load balancer for asterisk servers using
kamailio and the tutorial at

I must put kamailio in front of the media servers (asterisk) without
modifying their configuration (like a transparent proxy). It's a live
system and I cannot touch it.

The problem is that the asterisks require the devices to authenticate
themselves (and register with user and password too).

The sample implementation constructs a register request from scratch,
but does not handle the authorisation part

I guess that the uac_req should contain the user and password fetched
from the asterisk database. I would really appreciate some hints on
how to proceed.

Here's the current implementation of the register from kamailio->asterisk.
# Forward REGISTER to Asterisk
route[REGFWD] {
$var(rip) = $sel(cfg_get.asterisk.bindip);
$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";
$uac_req(hdrs)= $uac_req(hdrs) + "Expires: " + $hdr(Expires) + "\r\n";

Thank you,

More information about the sr-users mailing list