Hello Daniel (and of course the whole community J),

 

thanks for the reply. Now it works in most cases.

But I have one SIP client which handles the SIP communication very accurate and this client is actual internal registered. If I make a call from an external client to this internal client the following error is coming.

Error message: INVITE message: Remote host ‘193.16.163.58’ is not matching with configured register server ‘203.207.111.58’ or proxy server

And no call is possible.

If I change this special client with another SIP client it  works, but I can see in the debugging information that the SIP server is not routing in the desired way.

In the INVITE message the URI is not with the URI from the internal network (debugging information below) and this is the reason the special client is responding with “Error message”. In the SDP the URI IP address is correct.

My question is: Is it possible to change the URI in the To header to the right domain?

 

 

Cheers,

Kai Ohnacker

 

 

 

My setting is:

Kamailio with two interfaces in two domains.

Internal: 203.207.111.58

External: 193.16.163.58

 

My config:

Route{      

 if(is_method("REGISTER")) {

                if(dst_ip==203.207.111.58){

                        setbflag(20);

                }else{

                        setbflag(21);

                }

        }

}

 

And

Route [NATMANAGE]

 

        if(dst_ip==203.207.111.58 && isbflagset(20)){

                        rtpproxy_manage("coii");

        }else if(dst_ip==203.207.111.58 && isbflagset(21)){

                        rtpproxy_manage("coie");

        }else if(dst_ip==193.16.163.58 && isbflagset(20)){

                        rtpproxy_manage("corei");

        }else if(dst_ip==193.16.163.58 && isbflagset(21)){

                        rtpproxy_manage("coee");

        }

 

 

 

Debugging information at the destination client (internal):

 

INVITE sip:8000@10.99.217.42:5060 SIP/2.0

Record-Route: <sip:203.207.111.58;r2=on;lr=on;nat=yes>

Record-Route: <sip:193.16.163.58;r2=on;lr=on;nat=yes>

Via: SIP/2.0/UDP 203.207.111.58;branch=z9hG4bK9ed6.83de5667d5ceb951adb58a0f7d6909cd.0

Via: SIP/2.0/UDP 193.16.163.39:38771;rport=44934;branch=z9hG4bK802b882b077be511bce30c32c5410478

From: "PhonerLite" <sip:5000@193.16.163.58>;tag=2462361638

To: sip:8000@193.16.163.58 <- this URI IP is wrong. It should be 8000@203.207.111.58

Call-ID: 802B882B-077B-E511-BCE1-0C32C5410478@172.16.216.174

CSeq: 37 INVITE

Contact: <sip:5000@193.16.163.39:38771;alias=193.16.163.39~44934~1>

Allow: INVITE, OPTIONS, ACK, BYE, CANCEL, INFO, NOTIFY, MESSAGE, UPDATE

Max-Forwards: 69

Supported: 100rel, replaces, from-change

P-Early-Media: supported

User-Agent: SIPPER for PhonerLite

P-Preferred-Identity: <sip:5000@193.16.163.58>

Content-Type: application/sdp

Content-Length: 331

 

v=0

o=- 618137597 1 IN IP4 203.207.111.58

s=SIPPER for PhonerLite

c=IN IP4 203.207.111.58

t=0 0

m=audio 20038 RTP/AVP 9 8 0 107 101

a=rtpmap:9 G722/8000

a=rtpmap:8 PCMA/8000

a=rtpmap:0 PCMU/8000

a=rtpmap:107 opus/48000/2

a=rtpmap:101 telephone-event/8000

a=fmtp:101 0-16

a=ssrc:636280517

a=sendrecv

a=nortpproxy:yes

 

 

-------------------------------------------

11:57:25,299: T: 203.207.111.58:5060 (UDP)

SIP/2.0 200 OK

Via: SIP/2.0/UDP 203.207.111.58;branch=z9hG4bK9ed6.83de5667d5ceb951adb58a0f7d6909cd.0

Via: SIP/2.0/UDP 193.16.163.39:38771;rport=44934;branch=z9hG4bK802b882b077be511bce30c32c5410478

Record-Route: <sip:203.207.111.58;r2=on;lr=on;nat=yes>

Record-Route: <sip:193.16.163.58;r2=on;lr=on;nat=yes>

From: "PhonerLite" <sip:5000@193.16.163.58>;tag=2462361638

To: <sip:8000@193.16.163.58>;tag=802b882b077be511b35b430b8303a094

Call-ID: 802B882B-077B-E511-BCE1-0C32C5410478@172.16.216.174

CSeq: 37 INVITE

Contact: <sip:8000@10.99.217.42:5060>

Content-Type: application/sdp

Allow: INVITE, OPTIONS, ACK, BYE, CANCEL, INFO, NOTIFY, MESSAGE, UPDATE

Supported: replaces, from-change

Server: SIPPER for PhonerLite

Content-Length:   309

 

v=0

o=- 2073314527 1 IN IP4 10.99.217.42 <- client specific IP address

s=SIPPER for PhonerLite

c=IN IP4 10.99.217.42

t=0 0

m=audio 5062 RTP/AVP 8 107 0 9 101

a=rtpmap:9 G722/8000

a=rtpmap:8 PCMA/8000

a=rtpmap:0 PCMU/8000

a=rtpmap:107 opus/48000/2

a=rtpmap:101 telephone-event/8000

a=fmtp:101 0-16

a=ssrc:906481595

a=sendrecv

 

 

Von: Daniel-Constantin Mierla [mailto:miconda@gmail.com]
Gesendet: Mittwoch, 21. Oktober 2015 12:57
An: Ohnacker, Kai [CBC] <kai.ohnacker@cbc.de>; sr-users@lists.sip-router.org
Betreff: Re: AW: [SR-Users] Routing between 2 domains

 

Hello,

I spotted at least one issue: you set the branch flag (with setbflag()) but then you test message/transaction flags with isflagset() -- to test branch flags you have to use isbflagset().

Cheers,
Daniel

On 21/10/15 11:42, kai.ohnacker@cbc.de wrote:

Hello Daniel,

 

thanks for the reply. I try out your suggestion, but this is not working. There is no sound transmitted and the connection ended after 23 seconds (I think a timer is expired). 

Scenario is:

Kamailio route all internal calls only internal (external vice versa)

Kamailio route all internal to external through rtpproxy (also vice versa)                           

 

INT_IP: 203.207.111.58

EXT_IP: 193.16.163.58

 

Here my code:

request_route {

        if(is_method("REGISTER")) {

                if(dst_ip==203.207.111.58){

                        setbflag(20);

                }else{

                        setbflag(21);

                }

        }

}

 

Route [NATMANAGE]

 

 

        if(dst_ip==203.207.111.58 && isflagset(20)){

                        rtpproxy_manage("coii");

        }else if(dst_ip==203.207.111.58 && isflagset(21)){

                        rtpproxy_manage("coie");

        }else if(dst_ip==193.16.163.58 && isflagset(20)){

                        rtpproxy_manage("coei");

        }else if(dst_ip==193.16.163.58 && isflagset(21)){

                        rtpproxy_manage("coee");

        }

 

Alternative try

 

if(from_uri=~".*@203.207.111.58" && isflagset(20)){

                        rtpproxy_manage("coii");

        }else if(from_uri=~".*@203.207.111.58" && isflagset(21)){

                        rtpproxy_manage("coie");

        }else if(from_uri=~".*@193.16.163.58" && isflagset(20)){

                        rtpproxy_manage("coei");

        }else if(from_uri=~".*@193.16.163.58" && isflagset(21)){

                        rtpproxy_manage("coee");

        }

 

Another try

 

 

        if(from_uri=~".*@203.207.111.58" && isflagset(20)){

                        rtpproxy_manage("coii");

        }else if(from_uri=~".*@203.207.111.58" && isflagset(21)){

                        rtpproxy_manage("coie");

        }else if(from_uri=~".*@193.16.163.58" && isflagset(20)){

                        rtpproxy_manage("coei");

        }else if(from_uri=~".*@193.16.163.58" && isflagset(21)){

                        rtpproxy_manage("coee");

        }

 

RTPproxy config

 

EXTRA_OPTS="-l 203.207.111.58/193.16.163.58 -m 20000 -M 20100 -d WARN:LOG_LOCAL1"

 

Some debugging information are in the txt file. TCPdump debugging does not shows interesting informations…

 

Has somebody a good idea which could be helpful? Do you need some more information?

 

 

Cheers,

Kai

 

 

Von: sr-users [mailto:sr-users-bounces@lists.sip-router.org] Im Auftrag von Daniel-Constantin Mierla
Gesendet: Montag, 12.
Oktober 2015 14:26
An: Kamailio (SER) - Users Mailing List <sr-users@lists.sip-router.org>
Betreff: Re: [SR-Users] Routing between 2 domains

 

Hello,

the src_ip is not a local IP, so do not match it with INT_IP or EXT_IP. The dst_ip is local ip, but the one on which the interface was received.

You can test the $fs to see what socket is going to be used for sending out.

Or set some branch flag for each interface when the registration is processed and check that in branch route

if(is_method("REGISTER")) {
if(dst_ip==INT_IP){
   setbflag(20);
}else{
   setbflag(21);
}
}

then in route[NATMANGE] have conditions like:

if(src_ip==INT_IP && isflagset(20)) {
   # internal to internal
} else if(src_ip==INT_IP && isflagset(21)) {
   # internal to external
} else if ...


Cheers,
Daniel

On 08/10/15 11:14, kai.ohnacker@cbc.de wrote:

Hello community,

 

I work with Kamailio 4.2.0 which is placed between two networks (with two interfaces) and RTPproxy in bridge mode.

The task from Kamailio is to handle the calls from internal networks to internal networks only on the internal Interface without bridging. For external networks vice versa. If the call comes from external to internal, then the RTPproxy should work in bridge mode and vice versa. I adapt the example with IPv4 and IPv6 routing, but this is not working for internal to external calls and vice versa (http://kb.asipto.com/kamailio:kamailio-mixed-ipv4-ipv6). Only external calls and only internal calls works. I think the cause of this behavior is the routing which I implemented to the RTPmanage part in the Kamailio config.

The error message is given by the internal device. (call from external to internal)

If I make a call from internal to external, the RTP stream is only in one direction.

 

Internal Interface IP: 203.207.111.58

External Interface IP: 193.16.163.58

 

The RTPproxy config is:

CONTROL_SOCK=udp:127.0.0.1:9000

EXTRA_OPTS="-l 203.207.111.58/193.16.163.58 -d WARN:LOG_LOCAL1"

 

Kamailio.cfg:

#!define INT_IP 10.96.0.0/14

#!define EXT_IP 193.0.0.0/8

 

# RTPProxy control and singaling updates for NAT traversal

route[NATMANAGE] {

#!ifdef WITH_NAT

        if (is_request()) {

                if(has_totag()) {

                        if(check_route_param("nat=yes")) {

                                setbflag(FLB_NATB);

                        }

                }

        }

        if (!(isflagset(FLT_NATS) || isbflagset(FLB_NATB)))

                return;

 

#       rtpproxy_manage("co");

 

# Start Test routing

 

        if((src_ip==INT_IP && dst_ip==EXT_IP)){

                        rtpproxy_manage("cowie");

                        }

        if((src_ip==EXT_IP && dst_ip==INT_IP)){

                        rtpproxy_manage("cowei");

                        }

 

        if (is_request()) {

                if (!has_totag()) {

                        if(t_is_branch_route()) {

                                add_rr_param(";nat=yes");

                        }

                }

        }

        if (is_reply()) {

                if(isbflagset(FLB_NATB)) {

                        if(is_first_hop())

                                set_contact_alias();

                }

        }

#!endif

        return;

}

 

Can someone help me with the right routing? Do you need some more debugging information?

 

Cheers,

Kai

 





_______________________________________________
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
sr-users@lists.sip-router.org
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users




-- 
Daniel-Constantin Mierla
http://twitter.com/#!/miconda - http://www.linkedin.com/in/miconda
Book: SIP Routing With Kamailio - http://www.asipto.com



-- 
Daniel-Constantin Mierla
http://twitter.com/#!/miconda - http://www.linkedin.com/in/miconda
Book: SIP Routing With Kamailio - http://www.asipto.com