Hi
You also uploaded a pcap trace, using this link (which you sent directly to me).
-
https://1drv.ms/u/s!AkdU9Y6p5WVyjnrodIHt6EgS-h3UI read it and it's clear what's going wrong.
This is your desired flow.
192.168.0.11 ---> 192.168.0.2 ---> 122.97.130.198
192.168.0.11 <--- 36.140.122.12 <--- 122.97.130.198
In this, your INVITE goes to the public IP address (122.97.130.198) like this.
INVITE sip:+8618626439917@122.97.130.198:15060;user=phone SIP/2.0
Record-Route: <sip:36.140.122.12:7080;lr;ftag=5c1a6b917a705e9e;did=2c4.8532;nat=yes;vst=AAAAAAAAAAAAAAAAAAAAAAAAAAALAAAIARYfAx4cCw4IAgE1MDYwO3VzZXI9cGhvbmU->
Via: SIP/2.0/UDP 36.140.122.12:7080;branch=z9hG4bKe61a.5fe9d645ef1bbe470ca6d57fa20375bf.0
Via: SIP/2.0/UDP 192.168.0.11:45642;received=192.168.0.11;branch=z9hG4bK98457cb5b0e44505;rport=45642
The 200-OK goes to the UAC (192.168.0.11) like this.
SIP/2.0 200 OK
Via: SIP/2.0/UDP 36.140.122.12:7080;rport=7080;branch=z9hG4bKe61a.5fe9d645ef1bbe470ca6d57fa20375bf.0
Via: SIP/2.0/UDP 192.168.0.11:45642;received=192.168.0.11;branch=z9hG4bK98457cb5b0e44505;rport=45642
Record-Route: <sip:192.168.0.159;r2=on;lr=on;nat=yes>
Record-Route: <sip:122.97.130.198:15060;r2=on;lr=on;nat=yes>
Record-Route: <sip:36.140.122.12:7080;lr;ftag=5c1a6b917a705e9e;did=2c4.8532;nat=yes;vst=AAAAAAAAAAAAAAAAAAAAAAAAAAALAAAIARYfAx4cCw4IAgE1MDYwO3VzZXI9cGhvbmU->
The problem is, as you know, that the ACK from the UAC is routed to the public IP address 36.140.122.12, whereas you want it to be sent to the private IP address.
For this, double record-routing is required, as suggested earlier in this thread.
My best guess is that your proxy has one IP address. A problem is that we now know that you have your listen directive set to listen on the private interface, but always advertise the public IP address, but this is not what you want. You want to advertise one address in one direction and another in the other direction. You want two Record-Route header fields when relaying the initial INVITE.
I see two possible solutions (but there may be others).
- Get your proxy server to listen on two addresses, and force the socket when relaying messages. This can be cumbersome and tricky.
- Try using the record_route_preset() function from the rr module. This can be used to write the two Record-Route header fields exactly as you want (in the correct order, of course).
I recommend the second option, because it would be simpler for me to implement. I don't know how to do it in KEMI, though.
https://kamailio.org/docs/modules/5.7.x/modules/rr.html#rr.f.record_route_presetJames