Re: Wrong Contact Header

Fred Posner via sr-users <[email protected]>
Newsgroups gmane.comp.voip.ser
Message-ID <[email protected]>
On Sep 16, 2025, at 5:45 PM, Fernando Lopes via sr-users <[email protected]> wrote:
> 
> Hello everyone,
> 
> I’m running into an issue with Kamailio (exposed to the public) talking to Asterisk. The problem only happens with UDP/TCP SIP (not with WebRTC), and it’s related to the 200 OK response from Asterisk.
> Asterisk is sending the 200 OK with its internal IP address in the Contact header, which Kamailio forwards to the client. As a result, the client tries to send the ACK directly to the internal IP, and it fails.
> 
> Logs (WebRTC → Kamailio → Asterisk) || In sngrep, the connection shows as: 10.5.0.8:5060 (Kamailio) <-> 10.5.0.2:5060 (Asterisk)
> SIP/2.0 200 OK
> Via: SIP/2.0/UDP 172.31.217.74:5060;rport=5060;received=10.5.0.8;branch=z9hG4bK0186.15eb7eeb80260f12a3a4d45264371b16.0
> Via: SIP/2.0/WSS 05gol16panaa.invalid;rport=65443;received=172.31.208.1;branch=z9hG4bK2464299
> Call-ID: i0c08fra5hdplpdj4pq4
> From: "916c67e8-652f-49ea-b288-2bbbee8dbf21" <sip:[email protected]>;tag=86ca2rhiqs
> To: <sip:[email protected]>;tag=b012b645-bf96-4fba-9166-f7a00b10290b
> CSeq: 2 INVITE
> Server: Asterisk PBX 18.24.3
> Contact: <sip:10.5.0.2:5060>
> Allow: OPTIONS, REGISTER, SUBSCRIBE, NOTIFY, PUBLISH, INVITE, ACK, BYE, CANCEL, UPDATE, PRACK, INFO, MESSAGE, REFER
> Supported: 100rel, timer, replaces, norefersub
> Content-Type: application/sdp
> Content-Length:   667
> 
> ACK sip:10.5.0.2:5060 SIP/2.0
> Via: SIP/2.0/UDP 172.31.217.74:5060;branch=z9hG4bK0186.94970c4407431a3133bec46208b4be06.0
> Via: SIP/2.0/WSS 05gol16panaa.invalid;rport=65443;received=172.31.208.1;branch=z9hG4bK3452625
> To: <sip:[email protected]>;tag=b012b645-bf96-4fba-9166-f7a00b10290b
> From: "916c67e8-652f-49ea-b288-2bbbee8dbf21" <sip:[email protected]>;tag=86ca2rhiqs
> CSeq: 2 ACK
> Call-ID: i0c08fra5hdplpdj4pq4
> Max-Forwards: 69
> Supported: outbound
> User-Agent: SIP.js/0.21.1
> Content-Length: 0
> 
> Logs (TCP call using MicroSIP → Kamailio → Asterisk)
> SIP/2.0 200 OK                                                                                                                                                                                                                              
> Via: SIP/2.0/UDP 172.31.217.74:5060;rport=5060;received=10.5.0.8;branch=z9hG4bK82df.7f15d0606c2de9f083b2757842de918f.0;i=1
> Via: SIP/2.0/TCP 172.31.208.1:57670;rport=57670;received=172.31.208.1;branch=z9hG4bKPj379b3f941943461182af8d639cd93122;alias
> Call-ID: 5fbb1276c10e4041b9d5bc746bd48035
> From: "6001" <sip:6001@localhost>;tag=009616b957db491cbea95fe3bfc123ee
> To: <sip:100@localhost>;tag=7345097c-95c0-42da-9b8e-1f39c5ec7f53                                                                                                                                                                            
> CSeq: 4449 INVITE
> Server: Asterisk PBX 18.24.3
> Contact: <sip:10.5.0.2:5060>
> Allow: OPTIONS, REGISTER, SUBSCRIBE, NOTIFY, PUBLISH, INVITE, ACK, BYE, CANCEL, UPDATE, PRACK, INFO, MESSAGE, REFER                                                                                                                         Supported: 100rel, timer, replaces, norefersub                                                                                                                                                                                              
> Session-Expires: 1800;refresher=uac
> Require: timer
> Content-Type: application/sdp
> Content-Length:   481
> 
> Any suggestions on how to fix this problem.
> I'm using a modified version of this: https://github.com/davidcsi/kamailio-private-public/blob/master/kamailio.cfg
> 
> Thank you.


Your example shows wss. Regardless, please see the nathelper module and set_contact_alias:

https://www.kamailio.org/docs/modules/stable/modules/nathelper.html#nathelper.set_contact_alias

The default kamailio config (also available here: https://github.com/kamailio/kamailio/blob/master/etc/kamailio.cfg) has a NATDETECT route with an example.



Fred Posner
Tel: +1 (352) 664-3733
Alt: +1 (224) 334-3733

Contact info at https://fredp.xyz



__________________________________________________________
Kamailio - Users Mailing List - Non Commercial Discussions -- [email protected]
To unsubscribe send an email to [email protected]
Important: keep the mailing list in the recipients, do not reply only to the sender!
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.