<div dir="ltr">Hello all,<div><br></div><div>(Note: I previously posted a more detailed version of this question on StackOverflow at <a href="https://stackoverflow.com/q/63760506/829970">https://stackoverflow.com/q/63760506/829970</a> . This version is simplified to fit better in an email.)</div><div><br></div><div>I have Kamailio 5.4.1 (and RTPEngine) running on an internal server with a private IP address 172.31.7.96 and One-to-one NAT to an external IP address. The external IP is 192.0.2.100. (Note: The internal IP addresses are all unedited, but the public IPs have been replaced with TEST-NET-1 and TEST-NET-2 example addresses.) I will eventually be doing transcoding with RTPEngine, but for now this is a simple SIP Proxy.<br></div><div><br></div><div>Kamailio is installed on Ubuntu 18.04 using the DEB packages from <a href="http://dev.kamailio.org/kamailio54">dev.kamailio.org/kamailio54</a> and is using the stock configuration that comes with those packages, except for the following changes:</div><div><br></div><div><pre style="margin-top:0px;margin-bottom:1.6em;padding:12px;border:0px;font-variant-numeric:inherit;font-variant-east-asian:inherit;font-stretch:inherit;line-height:1.30769;font-family:Consolas,Menlo,Monaco,"Lucida Console","Liberation Mono","DejaVu Sans Mono","Bitstream Vera Sans Mono","Courier New",monospace,sans-serif;font-size:13px;vertical-align:baseline;box-sizing:inherit;width:auto;max-height:600px;overflow:auto;border-radius:5px"><code style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-family:Consolas,Menlo,Monaco,"Lucida Console","Liberation Mono","DejaVu Sans Mono","Bitstream Vera Sans Mono","Courier New",monospace,sans-serif;vertical-align:baseline;box-sizing:inherit;background-color:transparent;white-space:inherit;border-radius:0px">#!define WITH_NAT
#!define WITH_RTPENGINE
#!define WITH_MYSQL
#!define WITH_AUTH
#!define WITH_IPAUTH

listen=udp:<a href="http://0.0.0.0:5060">0.0.0.0:5060</a> advertise <a href="http://192.0.2.100:5060">192.0.2.100:5060</a>

#!define DBURL "mysql://<a href="http://kamailio:REAL_PASSWORD_HERE@127.0.0.1/kamailio">kamailio:REAL_PASSWORD_HERE@127.0.0.1/kamailio</a>"</code></pre></div><div><br></div><div>I have internal SIP servers with private IP addresses in the <a href="http://172.31.7.0/24">172.31.7.0/24</a> range that I want to have send all SIP traffic through the Kamailio server. The internal servers are running a Java SIP client with the `OUTBOUND_PROXY` setting set to 172.31.7.96.</div><div><br></div><div>The problem I have is that the SIP `200 OK` message sent by Kamailio to my SIP server has its `Record-Route` header set to the public IP address `192.0.2.100` instead of the private address `172.31.7.96`. The SIP client therefore tries to send the `ACK` message back to the public address, but it has no route to the public address so the ACK never gets sent.</div><div><br></div><div>How can I configure Kamailio to use the public IP for external traffic but the private IP for communicating with internal machines on the same subnet?</div><div><br></div><div>I tried setting `mhomed=1`, but the machine isn't actually multi-homed so that didn't work.</div><div><br></div><div>I thought of adding a second listen line `<span style="background-color:transparent;font-family:Consolas,Menlo,Monaco,"Lucida Console","Liberation Mono","DejaVu Sans Mono","Bitstream Vera Sans Mono","Courier New",monospace,sans-serif;font-style:inherit;font-variant-ligatures:inherit;font-variant-caps:inherit;font-weight:inherit;white-space:inherit;font-size:13px">listen=udp:<a href="http://172.31.7.96:5061">172.31.7.96:5061</a></span>` and having the internal servers talk to port 5061, but that doesn't work because Kamailio uses the 5061 definition for the external side too.</div><div><br></div><div>I see in the docs that it is possible to name the listener lines, but I don't understand how to use those names in a way that would be relevant to my issue.</div><div><br></div><div>Thank you very much for your help,</div><div><br></div><div>Moshe</div></div>