Set Contact Header in the OK reply for and Invite coming from Kamailio

Hi FS users,

I’m using FS as a media server behind a Kamailio, the Kamailio relays Invites from Users to FS, but when FS replies to the Invite with OK SDP offer, it includes Contact header with FS private IP and port, which causes the user to send ACK messages to Freeswitch directly instead of Kamailio, i was able to modify the Contact Header in Kamailio itself to remove FS IP and replce it with Kamailio IP so that kamailio is always in between the User and FS.

is there a way to set the contact header to a domain name or IP instead of the freeswitch IP address ? as in the example below, freeswitch OK reply contains the private ip and port 6060 in the contact header which causes the users to send ACK to it which breaks the call as Kamailio should be always in the way.

the dialpan is simple, just answer and play IVR demo of Freeswitch vanilla config.

example:

INVITE from Kamailio

INVITE sip:3000@MY_DOMAIN_NAME SIP/2.0
Via: SIP/2.0/UDP 10.10.0.21;branch=z9hG4bK1aa5.c0da7b6f89f0ded15b532d5dd28861df.0;i=55
Via: SIP/2.0/TLS 10.10.4.96:52945;received=10.10.4.96;branch=z9hG4bK.yAMQ5cb-5;rport=52945
From: sip:mahmood@sip.tsuki.solutions;tag=cAq4wnUaL
To: “3000” sip:3000@MY_DOMAIN_NAME
CSeq: 21 INVITE
Call-ID: 2PD328Ak1b
Max-Forwards: 69
Supported: replaces, outbound, gruu, path
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, NOTIFY, MESSAGE, SUBSCRIBE, INFO, PRACK, UPDATE
Content-Type: application/sdp
Content-Length: 517
Contact: sip:mahmood@10.10.4.96:52945;transport=tls;expires=3600;+sip.instance=“urn:uuid:d7e9fca1-f487-001f-821b-edd4b2012da0”;+org.linphone.specs=“lime”
User-Agent: LinphoneiOS/5.0.2 (iPhone) LinphoneSDK/5.2.32

v=0
o=mahmood 3522 3157 IN IP4 10.10.4.96
s=Talk
c=IN IP4 10.10.4.96
t=0 0
a=rtcp-xr:rcvr-rtt=all:10000 stat-summary=loss,dup,jitt,TTL voip-metrics
m=audio 7238 RTP/AVP 96 97 98 0 8 18 99 100 101
a=rtpmap:96 opus/48000/2
a=fmtp:96 useinbandfec=1
a=rtpmap:97 speex/16000
a=fmtp:97 vbr=on
a=rtpmap:98 speex/8000
a=fmtp:98 vbr=on
a=fmtp:18 annexb=yes
a=rtpmap:99 telephone-event/48000
a=rtpmap:100 telephone-event/16000
a=rtpmap:101 telephone-event/8000
a=rtcp-fb:* trr-int 1000
a=rtcp-fb:* ccm tmmbr

FreeSWITCH OK reply

SIP/2.0 200 OK
Via: SIP/2.0/UDP 10.10.0.21;branch=z9hG4bK1aa5.c0da7b6f89f0ded15b532d5dd28861df.0;i=55
Via: SIP/2.0/TLS 10.10.4.96:52945;received=10.10.4.96;branch=z9hG4bK.yAMQ5cb-5;rport=52945
From: sip:mahmood@MY_DOMAIN_NAME;tag=cAq4wnUaL
To: “3000” sip:3000@MY_DOMAIN_NAME;tag=1r3r5jvFZe62p
Call-ID: 2PD328Ak1b
CSeq: 21 INVITE
Contact: sip:3000@10.10.0.21:6060;transport=tls
User-Agent: FreeSWITCH-mod_sofia/1.10.9-release-21-a615e85afc~64bit
Accept: application/sdp
Allow: INVITE, ACK, BYE, CANCEL, OPTIONS, MESSAGE, INFO, UPDATE, REGISTER, REFER, NOTIFY
Supported: timer, path, replaces
Allow-Events: talk, hold, conference, refer
Content-Type: application/sdp
Content-Disposition: session
Content-Length: 245
Remote-Party-ID: “3000” sip:3000@MY_DOMAIN_NAME;party=calling;privacy=off;screen=no

v=0
o=FreeSWITCH 1689990552 1689990553 IN IP4 10.10.0.21
s=FreeSWITCH
c=IN IP4 10.10.0.21
t=0 0
m=audio 24066 RTP/AVP 96 99
a=rtpmap:96 opus/48000/2
a=fmtp:96 useinbandfec=1
a=rtpmap:99 telephone-event/48000
a=fmtp:99 0-15
a=ptime:20

You need to add a record route to your invite as it passes thru Kamailio otherwise its doing exactly what it should be doing.

Secondly, This might fix the public IP vs the private IP bits:

  1. Set ext-rtp-ip/ext-sip-ip with the prefix of ‘autonat:x.x.x.x’
  2. Set local-network-acl to rfc1918.auto

/b

1 Like

Oh right record route will override the contact on the UA end thus it sends the ACK to the last RR in the OK, and the UA is supposed to put the Contact header from the OK as the Request URI of the ACK then kamailio relays the ACK back to FS to finish session establishment.