Hello!

I have the following architecture:
I am using a Voip SIP (with public access on IP 54.XXX.XXX.44) configured as a Trunk on Kamailio using UAC Module.

The issue I am facing is that the SIP messages replies I get from the VOIP provider are being destined to Kamailio's public IP (YY.YY.42.207) instead of Asterisk's IP (as sent on the message).

For example, this is the 200 message I sent to the VOIP provider (I clearly state that the contact is Asterisk sip:172.31.69.198:5080):

2022/04/07 14:17:19.260864 172.31.32.7:5060 -> 54.XXX.XXX.44:5060
SIP/2.0 200 OK
Via: SIP/2.0/UDP 54.XXX.XXX.44:5060;rport=5060;branch=z9hG4bK90b6.f7a6b0a4.0
Record-Route: <sip:YY.YY.42.207;lr;ftag=p0BjH21gpa3rc>
Call-ID: 464f21c3-3120-123b-91b2-026ef2fede4c
From: "419XXXXX998" <sip:38XXXX02@172.31.32.169>;tag=p0BjH21gpa3rc
To: <sip:38XXXX02@54.XXX.XXX.44>;tag=8c3bb09e-a909-4cb4-99a7-3c57aa8f946e
CSeq: 50116727 INVITE
Server: Asterisk PBX 18.11.0
Contact: <sip:172.31.69.198:5080>
Allow: OPTIONS, REGISTER, SUBSCRIBE, NOTIFY, PUBLISH, INVITE, ACK, BYE, CANCEL, UPDATE, PRACK, MESSAGE, REFER
Supported: 100rel, timer, replaces, norefersub
Content-Type: application/sdp
Content-Length:   239


v=0
o=- 1649321756 1649321759 IN IP4 172.31.69.198
s=Asterisk
c=IN IP4 172.31.69.198
t=0 0
m=audio 10010 RTP/AVP 8 101
a=rtpmap:8 PCMA/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=ptime:20
a=maxptime:150
a=sendrecv

But the ACK I get from them is destined to Kamailio instead of Asterisk:

2022/04/07 14:17:19.263469 54.XXX.XXX.44:5060 -> 172.31.32.7:5060
ACK sip:YY.YY.42.207:5060 SIP/2.0
Route: <sip:YY.YY.42.207;lr;ftag=p0BjH21gpa3rc>
Via: SIP/2.0/UDP 54.XXX.XXX.44:5060;branch=z9hG4bK90b6.f7a6b0a4.2
Max-Forwards: 69
From: "419XXXXX998" <sip:38XXXX02@172.31.32.169>;tag=p0BjH21gpa3rc
To: <sip:38XXXX02@54.XXX.XXX.44>;tag=8c3bb09e-a909-4cb4-99a7-3c57aa8f946e
Call-ID: 464f21c3-3120-123b-91b2-026ef2fede4c
CSeq: 50116727 ACK
Contact: <sip:voip.voip-sbc.6792.fab37901@54.XXX.XXX.44:5060>
Content-Length: 0

This causes Kamailio to not know where to forward the message to... Asterisk never gets the reply.

This is happening to one of the SIP Trunks I am using, with the other, everything is fine.

Is there anything I can do to work around it (other than contacting the provider to fix on their end)?

Thanks!

ps: I have attached the full SIP messages trail to help.