Hi all, can anyone help me to find out what is wrong with my setup, i have an asterisk behind a kamailio, kamailio is proxying all packages  to the outside.

when the call is bridge it gets disconnected after a few seconds, it seems that our voip carrier is sending a bye because we didn't answer to their 200 ok properly, but as the trace shows we did only that kamailio is answering to the contact header ip not the ip that is sending the ok.

I am sorry i sent a too long message before i will try skim it a bit. 

any help is appreciated .

thanks.

my setup 

request_route {

        if (!mf_process_maxfwd_header("10")) {
                sl_send_reply("483","Too Many Hops");
                exit;
        }


        if(is_method("OPTIONS")) {
            # send reply for each options request
            sl_send_reply("200", "ok");
            exit();
         }

   if(method=="BYE") {
   #Account BYE transactions

};


if (method=="CANCEL") {
if (t_check_trans()) t_relay();

exit;
};



 if (loose_route()) {


t_relay();
                exit;
       }


 if (is_method("INVITE")) { 


                record_route();

        }
f (!t_relay_to_udp("3.1.1.1", "5060")) {
sl_reply_error();
exit;
};
exit
};

here is a trace to a call made to a hotel.
i had changed the real ips for obvious reasons.
thanks.


asterisk ip 1.1.1.1
kamailio internal 1.1.1.2
kamailio external 2.0.0.1
Voip Carrier 3.1.1.1
voip contact ip 3.1.1.2

U 2013/10/23 17:26:20.354248 1.1.1.2:5060 -> 3.1.1.2:5060
Via: SIP/2.0/UDP 2.0.0.1:5060;branch=z9hG4bKcydzigwkX.
Via: SIP/2.0/UDP 1.1.1.1:5060;branch=z9hG4bK280c4e9c;rport=5060.
Route: <sip:2.0.0.1;lr=on;ftag=as4bc322e9>,<sip:3.1.1.1;lr;ftag=as4bc322e9;did=8b8.d7ef5a05>.
Max-Forwards: 16.
From: "+19812457865" <sip:+19812457865@1.1.1.1>;tag=as4bc322e9.
To: <sip:76890723276341079@3.1.1.2>;tag=3591552407-393967.
CSeq: 102 ACK.
User-Agent: Asterisk PBX 1.8.15-cert2.
Content-Length: 0.
.


U 2013/10/23 17:26:36.355580 3.1.1.1:5060 -> 1.1.1.2:5060
Max-Forwards: 69.
Route: <sip:2.0.0.1;lr=on;ftag=as4bc322e9>.
To: "+19812457865" <sip:+19812457865@1.1.1.1>;tag=as4bc322e9.
From: <sip:76890723276341079@3.1.1.1>;tag=3591552407-393967.
CSeq: 2 BYE.
Allow: INVITE, BYE, OPTIONS, CANCEL, ACK, REGISTER, NOTIFY, INFO, REFER, SUBSCRIBE, PRACK, UPDATE.
Via: SIP/2.0/UDP 3.1.1.1:5060;branch=z9hG4bKce8a.db93afa3.0.
Via: SIP/2.0/UDP 3.1.1.2:5060;branch=z9hG4bK96003ecbb11f5deaf6014235140e6952.
Content-Length: 0.

U 2013/10/23 17:26:20.354248 1.1.1.2:5060 -> 3.1.1.2:5060
ACK sip:76890723276341079@3.1.1.2:5060 SIP/2.0.
Via: SIP/2.0/UDP 2.0.0.1:5060;branch=z9hG4bKcydzigwkX.
Via: SIP/2.0/UDP 1.1.1.1:5060;branch=z9hG4bK280c4e9c;rport=5060.
Route: <sip:2.0.0.1;lr=on;ftag=as4bc322e9>,<sip:3.1.1.1;lr;ftag=as4bc322e9;did=8b8.d7ef5a05>.
Max-Forwards: 16.
From: "+19812457865" <sip:+19812457865@1.1.1.1>;tag=as4bc322e9.
To: <sip:76890723276341079@3.1.1.2>;tag=3591552407-393967.
Contact: <sip:+19812457865@1.1.1.1:5060>.
Call-ID: 7d0ca48c1d48c14d104fac1f59194ae0@1.1.1.1:5060.
CSeq: 102 ACK.
User-Agent: Asterisk PBX 1.8.15-cert2.
Content-Length: 0.
.


U 2013/10/23 17:26:36.355580 3.1.1.1:5060 -> 1.1.1.2:5060
BYE sip:+19812457865@1.1.1.1:5060 SIP/2.0.
Max-Forwards: 69.
Route: <sip:2.0.0.1;lr=on;ftag=as4bc322e9>.
To: "+19812457865" <sip:+19812457865@1.1.1.1>;tag=as4bc322e9.
From: <sip:76890723276341079@3.1.1.1>;tag=3591552407-393967.
Call-ID: 7d0ca48c1d48c14d104fac1f59194ae0@1.1.1.1:5060.
CSeq: 2 BYE.
Allow: INVITE, BYE, OPTIONS, CANCEL, ACK, REGISTER, NOTIFY, INFO, REFER, SUBSCRIBE, PRACK, UPDATE.
Via: SIP/2.0/UDP 3.1.1.1:5060;branch=z9hG4bKce8a.db93afa3.0.
Via: SIP/2.0/UDP 3.1.1.2:5060;branch=z9hG4bK96003ecbb11f5deaf6014235140e6952.
Contact: <sip:76890723276341079@3.1.1.2:5060>.
Content-Length: 0.