[SR-Users] basic Kamailio frontend to Asterisk

Daniel Tryba d.tryba at pocos.nl
Tue Aug 20 17:01:23 CEST 2019


On Tue, Aug 20, 2019 at 10:22:26AM -0400, Travis Ryan wrote:
> What role is Kamailio to my Asterisk? Just an Outbound proxy? Do I need to
> still register the trunk from each Asterisk box "thru" the Kamailio proxy,
> etc?
> 
> Also, I'm merely accepting outside calls and then validating the caller and
> bridging them back out to the PSTN, so I don't have any local SIP clients,
> etc., so no need to register the sip devices, etc.

The real question is what do you need kamailio to do? You answer this
with as a simple proxy.

A possible solution for you is to use kamilio with the dispatcher module. One
id (1) for the PSTN side, one id (2) for the Asterisk side. If a call comes in
from 1, route it to 2 and v.v.

This makes the kamailio machine the "endpoint" for both PSTN and
Asterisk side.

With the "default" config that comes with kamailio all you need to do is
strip out anything from the accounting bit in request_route (line 508)
https://github.com/kamailio/kamailio/blob/master/etc/kamailio.cfg
and insert something like:

if(ds_is_from_list("1",3))
{
	$avp(dispatcherid)="2";
}
else if(ds_is_from_list("2",3))
{
	$avp(dispatcherid)="1";
}
else
{
	send_reply("403", "Go away");
	exit;
}

route(DISPATCHER);
route(RELAY);

With route DISPATCHER being:
route[DISPATCHER]
{
	if(!ds_select_dst($avp(dispatcherid), "4"))
	{
		send_reply("501", "No dispatcher available");
		exit;
	}

	t_on_failure("RTF_DISPATCH");

	return;
}

See https://kamailio.org/docs/modules/stable/modules/dispatcher.html#dispatcher.ex.config
for more info on integrating the dispatcher module.

More advanced subjects to look at are:
-do you need an rtp proxy?
-do you need topology hiding?
-is NAT involved?

But leave them until you have a clue about how to use kamailio as a sip proxy in a
simple test environment (e.g. between 2 asterisk servers).



More information about the sr-users mailing list