[SR-Users] How to run Kamailio as a stateful proxy

Thomas Bäumer thomas at ctrl-c.de
Wed Jan 28 17:41:20 CET 2015


Hello all,

we are are a small network-provider and selling internet via FTTC and
FTTH. To complete the portfolio we also sell telephony via a rented
ClassV Service with provisioning API, but its not our system and not in
our network.
To get more informations about Registration-Status and calls I have now
installed a kamailio as a statefull proxy between the subscriber and the
softwitch:

|----------|
|subscriber|\                                                ---------
|----------| \                                              /| Mobile|
              \                          --------------    / ---------
|----------|   \     ------------        |  Class V   |   /   --------
|subscriber|---------| Kamailio |--------| Softswitch |-------| PSTN |
|----------|   /     ------------        |            |   \   --------
              /                          --------------    \ ---------
|----------| /                                              \| World |
|subscriber|/                                                ---------
|----------|


I am really new in kamailio, so I just use the configuration named "Edge
Proxy Configuration" shown in the documentation to the outbound module,
see http://kamailio.org/docs/modules/4.2.x/modules/outbound.html
example 1.1. We dont need NAT and STUN because all our subscribers get
official IPv4 addresses.

Outgoing calls (subscriber -> PSTN) are working fine, all SIP messages
pass the Kamailio Proxy. But incoming Calls (World -> subscriber) miss
the proxy and will be routed  directly from the Softwitch to the subscriber.
I think because of the Contact-Header in the subscriber REGISTER:

Contact: <sip:49xxxxxxyyyyyy at 134.xx.yy.zz;uniq=E41120B46C92D3818E72B>

This is the IP of the subscriber FritzBox.

So I just added some lines to replace the Contact-Header in the REGISTER
to get all incoming Calls from the Softswitch to the Kamailio:


if (is_method("REGISTER")) {

   if (src_ip==CUSTOMER_NET) {
        remove_hf("Route");
        add_path();
        $du = "sip:REGISTRAR_IP:REGISTRAR_PORT";

        if ($ct != $null) {

subst('/^Contact:(.*)@[a-zA-Z0-9.]+(.*)$/Contact:\1 at KAMAILIO_IP\2/ig');
        }
   }
}

and now the Contact-Header looks better:

Contact: <sip:49xxxxxxyyyyyy at KAMAILIO_IP;uniq=E41120B46C92D3818E72B>

Now the subscriber is registered on the Softswitch with the IP from the
Kamailio. And now  the Kamailio get the incoming Call, but directly
route it back to the Softwitch and the call failed.

Now my questions:

 - Is the "Edge Proxy Configuration" right for this setup?
 - How the Kamailio keep all registered IPs and Lines to route an
   incoming Call to the right subscriber?
 - Why the Kamailio route an incoming call directly back to the
   Softswitch?


Thanks a lot.

Regards
  Thomas



More information about the sr-users mailing list