<!DOCTYPE html>
<html><head>
    <meta charset="UTF-8">
</head><body><p>Hi, first of all, here's the architecture of what I'm trying to do :</p><p>Public client --> Kamailio and there is a private freeswitch behind  kamailio. I use rtpproxy to connect the client and the freeswitch that is used at media server.</p><p>If a call is not answered from userA to userB and userB doesn't have a voicemail configured, I route the Invite to FreeSwitch and I change the destination user to 666666 that take care of playing a nice message that the user doesn't have a voicemail.</p><p>My problem is that the SDP Connection doesn't get updated to the right IP. It get changed to the external IP instead of the internal.</p><p>Here's the original INVITE Packet :</p><p>13:21:22.824290 IP 8.8.8.16.30893 > 8.8.8.18.5060: SIP: INVITE sip:<a class="mailto-link" href="mailto:101@mydomain.com">101@mydomain.com</a> SIP/2.0 <br>Eh....@.?...........x......mINVITE sip:<a class="mailto-link" href="mailto:101@mydomain.com">101@mydomain.com</a> SIP/2.0 <br>Via: SIP/2.0/UDP 192.168.0.236:5060;branch=z9hG4bK-3e3b9e22 <br>From: <a class="mailto-link" href="mailto:sip:102@mydomain.com">102</a>;tag=cacbdfac40ddd17ao0 <br>To: <sip:<a class="mailto-link" href="mailto:101@mydomain.com">101@mydomain.com</a>> <br>Remote-Party-ID: <a class="mailto-link" href="mailto:sip:102@mydomain.com">102</a>;screen=yes;party=calling <br>Call-ID: 3ae5b914-591b8732@192.168.0.236 <br>CSeq: 101 INVITE <br>Max-Forwards: 70 <br>Contact: <a class="mailto-link" href="mailto:sip:102@192.168.0.236:5060;ref=102">102</a> <br>Expires: 240 <br>User-Agent: Cisco/SPA122-1.3.5r(003) <br>Content-Length: 263 <br>Allow: ACK, BYE, CANCEL, INFO, INVITE, NOTIFY, OPTIONS, REFER <br>Supported: replaces <br>Content-Type: application/sdp <br><br>v=0 <br>o=- 16833207 16833207 IN IP4 192.168.0.236 <br>s=- <br>c=IN IP4 192.168.0.236 <br>t=0 0 <br>m=audio 16396 RTP/AVP 0 100 101 <br>a=rtpmap:0 PCMU/8000 <br>a=rtpmap:100 NSE/8000 <br>a=fmtp:100 192-193 <br>a=rtpmap:101 telephone-event/8000 <br>a=fmtp:101 0-15 <br>a=ptime:20 <br>a=sendrecv<br><br></p><p>Note that 192.168.0.x in the internal network of the clients and 8.8.8.16 is the public IP of the client and 8.8.8.18 is the kamailio ip.</p><p>Here's the INVITE packet sent from kamailio to Freeswitch</p><p>13:21:32.947196 IP 172.16.0.18.5060 > 172.16.0.19.5080: SIP: INVITE sip:666666666666666@172.16.0.19:5080 SIP/2.0 <br>E... ...@.      ...e...e.......P1INVITE sip:666666666666666@172.16.0.19:5080 SIP/2.0 <br>Record-Route: <sip:8.8.8.18;lr=on;ftag=cacbdfac40ddd17ao0;did=f3f.205> <br>Test-Pascal: SDP avec freeswitch <br>Via: SIP/2.0/UDP 172.16.0.18;branch=z9hG4bK31ea.e52b370f8248032680211fc7c253902a.1 <br>Via: SIP/2.0/UDP 192.168.0.236:5060;rport=30893;received=8.8.8.16;branch=z9hG4bK-3e3b9e22 <br>From: <a class="mailto-link" href="mailto:sip:102@mydomain.com">102</a>;tag=cacbdfac40ddd17ao0 <br>To: <sip:<a class="mailto-link" href="mailto:101@mydomain.com">101@mydomain.com</a>> <br>Remote-Party-ID: <a class="mailto-link" href="mailto:sip:102@mydomain.com">102</a>;screen=yes;party=calling <br>Call-ID: 3ae5b914-591b8732@192.168.0.236 <br>CSeq: 101 INVITE <br>Max-Forwards: 69 <br>Contact: <a class="mailto-link" href="mailto:sip:102@192.168.0.236:5060;ref=102;alias=8.8.8.16~30893~1">102</a> <br>Expires: 240 <br>User-Agent: Cisco/SPA122-1.3.5r(003) <br>Content-Length: 279 <br>Allow: ACK, BYE, CANCEL, INFO, INVITE, NOTIFY, OPTIONS, REFER <br>Supported: replaces <br>Content-Type: application/sdp <br><br>v=0 <br>o=- 16833207 16833207 IN IP4 8.8.8.18 <br>s=- <br>c=IN IP4 8.8.8.18 <br>t=0 0 <br>m=audio 46134 RTP/AVP 0 100 101 <br>a=rtpmap:0 PCMU/8000 <br>a=rtpmap:100 NSE/8000 <br>a=fmtp:100 192-193 <br>a=rtpmap:101 telephone-event/8000 <br>a=fmtp:101 0-15 <br>a=ptime:20 <br>a=sendrecv <br>a=nortpproxy:yes<br></p><p>Note that 172.16.0.18 is the internal IP of kamailio and 172.16.0.19 is the internal IP of FreeSwitch</p><p>Here's the revealing par of kamailio configuration that us use when falling back to freeswitch :</p><p>failure_route[TOVOICEMAIL] {</p><p>$ru = "sip:666666666666666@" + $sel(cfg_get.freeswitch.bindip)<br>+ ":" + $sel(cfg_get.freeswitch.bindport);<br>$du = "sip:666666666666666@"+ $sel(cfg_get.freeswitch.bindip)<br>+ ":" + $sel(cfg_get.freeswitch.bindport);<br>force_send_socket(udp:172.16.0.18:5060);<br></p><p>if (is_request()) { <br>       xlog("L_INFO","$ft -- NATMANAGE -- Request"); <br>       if(has_totag()) { <br>           if(check_route_param("nat=yes")) { <br>               setbflag(FLT_NATS); <br>           } <br>       } <br>   }<br><br>       if(nat_uac_test("8")) { <br>           xlog("L_INFO","---------------------------------------------------"); <br>           xlog("L_INFO","---------------------------------------------------"); <br>           xlog("L_INFO","SDP Body avant : $fu --> $du | $ru"); <br>           xlog("L_INFO","---------------------------------------------------"); <br>           xlog("L_INFO","$ft -- RTPMANAGE(FreeSwitch) : NAT SDP"); <br>           rtpproxy_manage("1cowei",'192.168.101.18'); <br>           insert_hf("Test-Pascal: SDP avec freeswitch\r\n"); <br>           xlog("L_INFO","---------------------------------------------------"); <br>       }    <br>       else { <br>           xlog("L_INFO","$ft -- RTPMANAGE(FreeSwitch) : PAS DE NAT SDP"); <br>           rtpproxy_manage("cowrei"); <br>       }    <br>   if (is_reply()) { <br>       xlog("L_INFO","$ft -- NATMANAGE -- Reply"); <br>       if(isbflagset(FLT_NATS)) { <br>           if(is_first_hop()) <br>               set_contact_alias(); <br><br>       } <br>       if ( $si == $sel(cfg_get.freeswitch.bindip) && is_method("SUBSCRIBE") ) { <br>           remove_hf("Contact"); <br>           insert_hf("Contact: \<a class="mailto-link" href="mailto:sip:$fU@8.8.8.18:5060">$fU\</a>\r\n","Expires"); <br><br>       } <br>       else { <br>           fix_nated_contact(); <br>       } <br><br>   }<br><br>if ( is_method("INVITE") )<br>       setflag(FLT_DIALOG);<br><br>if (!t_relay()) { <br>       xlog("L_INFO","$ft -- ERROR Relay : $rc"); <br>       sl_reply_error(); <br>   }<br><br>------------------------------------------------</p><p>This configuration is working if the call is not going through failure_route</p><p>I use Kamailio version 5.0.1 on Debian.</p><p>Thank you</p><p><br></p><p>Pascal</p></body></html>