<div dir="ltr">Hello,<div><br></div><div><div>First of all, thanks in advance for your time.</div><div><br></div><div>

I am running OpenSIPS 1.9.2 and I am using the load_balancer module to balance outbound calls.  Some of my gateways are on LAN and some of them are external to my network.  There is NATing involved and I am using set_advertised_address to ensure Via headers are properly constructed for the INVITE and I am also using record_route_preset to ensure the Record-Route headers are correct.  I am also using mhomed=1.  Now to the problem.</div>


<div><br></div><div>Let&#39;s say during call setup the first gateway chosen is on the LAN.  If this call setup fails it hits the failure route and another destination is chosen.  It also sends an ACK to the first destination to let it know we received the negative response and the ACK contains the correct IP address in the Via header.  Now, when the second gateway that&#39;s chosen is external and that call setup also fails, the ACK that is returned to the second gateway for the negative response still contains the local LAN address in the Via headers even though the INVITE to the second gateway had the correct IP Address in the Via.  In fact, every other gateway chosen after that will ACK with the local LAN address.  I&#39;ve tried everything I can think of to try and change this IP address, but I can&#39;t seem to do it.  I would really appreciate someone&#39;s insight into this.</div>


<div><br></div><div>Thanks,</div><div>Seth</div><div><br></div><div>Here is a trace:</div><div><br></div><div><div>U 2014/08/21 19:27:27.791679 <a href="http://172.16.1.105:5060" target="_blank">172.16.1.105:5060</a> -&gt; <a href="http://172.16.1.115:5060" target="_blank">172.16.1.115:5060</a></div>


<div>INVITE <a href="mailto:sip%3A19999999876@172.16.1.115" target="_blank">sip:19999999876@172.16.1.115</a> SIP/2.0</div><div>Via: SIP/2.0/UDP 172.16.1.105;rport;branch=z9hG4bKFg352a70a3UDe</div><div>Max-Forwards: 67</div>

<div>From: &quot;SCHIP OR&quot; &lt;<a href="mailto:sip%3A12122558005@172.16.1.115" target="_blank">sip:19999999999@172.16.1.115</a>&gt;;tag=Kmmp7H4SHtegB</div>
<div>To: &lt;<a href="mailto:sip%3A19999999876@172.16.1.115" target="_blank">sip:19999999876@172.16.1.115</a>&gt;</div><div>Call-ID: 8dc4b6c9-a42d-1232-879e-07071b1d0b50</div><div>CSeq: 63995759 INVITE</div><div>Contact: &lt;sip:gw+opensips@172.16.1.105:5060;transport=udp;gw=opensips&gt;</div>


<div>User-Agent: FS5</div><div>Allow: INVITE, ACK, BYE, CANCEL, OPTIONS, MESSAGE, INFO, UPDATE, REGISTER, REFER, NOTIFY</div><div>Supported: timer, precondition, path, replaces</div><div>Allow-Events: talk, hold, conference, refer</div>


<div>Content-Type: application/sdp</div><div>Content-Disposition: session</div><div>Content-Length: 231</div><div>X-FS-Support: update_display,send_info</div><div>Remote-Party-ID: &quot;SCHIP OR&quot; &lt;<a href="mailto:sip%3A12122558005@172.16.1.115" target="_blank">sip:1</a><a href="mailto:sip%3A12122558005@172.16.1.115" target="_blank">9999999999</a>@<a href="http://172.16.1.115">172.16.1.115</a>&gt;;party=calling;screen=yes;privacy=off</div>


<div><br></div><div>v=0</div><div>o=FreeSWITCH 1408638865 1408638866 IN IP4 172.16.1.105</div><div>s=FreeSWITCH</div><div>c=IN IP4 172.16.1.105</div><div>t=0 0</div><div>m=audio 24782 RTP/AVP 9 0 8 3 101</div><div>a=rtpmap:101 telephone-event/8000</div>


<div>a=fmtp:101 0-16</div><div>a=silenceSupp:off - - - -</div><div>a=ptime:20</div><div><br></div><div>U 2014/08/21 19:27:27.792287 <a href="http://172.16.1.115:5060" target="_blank">172.16.1.115:5060</a> -&gt; <a href="http://172.16.1.105:5060" target="_blank">172.16.1.105:5060</a></div>


<div>SIP/2.0 100 Giving a try</div><div>Via: SIP/2.0/UDP 172.16.1.105;received=172.16.1.105;rport=5060;branch=z9hG4bKFg352a70a3UDe</div><div>From: &quot;SCHIP OR&quot; &lt;<a href="mailto:sip%3A12122558005@172.16.1.115" target="_blank">sip:1</a><a href="mailto:sip%3A12122558005@172.16.1.115" target="_blank">9999999999</a>@<a href="http://172.16.1.115">172.16.1.115</a>&gt;;tag=Kmmp7H4SHtegB</div>


<div>To: &lt;<a href="mailto:sip%3A19999999876@172.16.1.115" target="_blank">sip:19999999876@172.16.1.115</a>&gt;</div><div>Call-ID: 8dc4b6c9-a42d-1232-879e-07071b1d0b50</div><div>CSeq: 63995759 INVITE</div><div>Server: OpenSIPS (1.9.2-notls (x86_64/linux))</div>


<div>Content-Length: 0</div><div><br></div><div><br></div><div>U 2014/08/21 19:27:27.797418 <a href="http://172.16.1.115:5060" target="_blank">172.16.1.115:5060</a> -&gt; <a href="http://172.16.1.2:5060" target="_blank">172.16.1.2:5060</a></div>

<div>INVITE <a href="mailto:sip%3A19999999876@172.16.1.2" target="_blank">sip:19999999876@172.16.1.2</a> SIP/2.0</div>
<div>Record-Route: &lt;sip:172.16.1.115:5060;lr;ftag=Kmmp7H4SHtegB;schip=edd1.ce072fd2&gt;</div><div>Via: SIP/2.0/UDP 172.16.1.115:5060;branch=z9hG4bK3854.62532862.0</div><div>Via: SIP/2.0/UDP 172.16.1.105;received=172.16.1.105;rport=5060;branch=z9hG4bKFg352a70a3UDe</div>


<div>Max-Forwards: 66</div><div>From: &quot;SCHIP OR&quot; &lt;<a href="mailto:sip%3A12122558005@172.16.1.115" target="_blank">sip:1</a><a href="mailto:sip%3A12122558005@172.16.1.115" target="_blank">9999999999</a>@<a href="http://172.16.1.115">172.16.1.115</a>&gt;;tag=Kmmp7H4SHtegB</div>
<div>To: &lt;<a href="mailto:sip%3A19999999876@172.16.1.115" target="_blank">sip:19999999876@172.16.1.115</a>&gt;</div>

<div>Call-ID: 8dc4b6c9-a42d-1232-879e-07071b1d0b50</div><div>CSeq: 63995759 INVITE</div><div>Contact: &lt;sip:gw+opensips@172.16.1.105:5060;transport=udp;gw=opensips&gt;</div><div>User-Agent: FS5</div><div>Allow: INVITE, ACK, BYE, CANCEL, OPTIONS, MESSAGE, INFO, UPDATE, REGISTER, REFER, NOTIFY</div>


<div>Supported: timer, precondition, path, replaces</div><div>Allow-Events: talk, hold, conference, refer</div><div>Content-Type: application/sdp</div><div>Content-Disposition: session</div><div>Content-Length: 251</div>

<div>
X-FS-Support: update_display,send_info</div><div>Remote-Party-ID: &quot;SCHIP OR&quot; &lt;<a href="mailto:sip%3A12122558005@172.16.1.115" target="_blank">sip:1</a><a href="mailto:sip%3A12122558005@172.16.1.115" target="_blank">9999999999</a>@<a href="http://172.16.1.115">172.16.1.115</a>&gt;;party=calling;screen=yes;privacy=off</div>

<div>
<br></div><div>v=0</div><div>o=FreeSWITCH 1408638865 1408638866 IN IP4 172.16.1.109</div><div>s=FreeSWITCH</div><div>c=IN IP4 172.16.1.109</div><div>t=0 0</div><div>m=audio 39274 RTP/AVP 9 0 8 3 101</div><div>a=rtpmap:101 telephone-event/8000</div>


<div>a=fmtp:101 0-16</div><div>a=silenceSupp:off - - - -</div><div>a=ptime:20</div><div>a=schipmangled:yes</div><div><br></div><div>U 2014/08/21 19:27:27.797732 <a href="http://172.16.1.2:5060" target="_blank">172.16.1.2:5060</a> -&gt; <a href="http://172.16.1.115:5060" target="_blank">172.16.1.115:5060</a></div>


<div>SIP/2.0 100 Giving a try</div><div>Via: SIP/2.0/UDP 172.16.1.115:5060;branch=z9hG4bK3854.62532862.0</div><div>Via: SIP/2.0/UDP 172.16.1.105;received=172.16.1.105;rport=5060;branch=z9hG4bKFg352a70a3UDe</div><div>From: &quot;SCHIP OR&quot; &lt;<a href="mailto:sip%3A12122558005@172.16.1.115" target="_blank">sip:1</a><a href="mailto:sip%3A12122558005@172.16.1.115" target="_blank">9999999999</a>@<a href="http://172.16.1.115">172.16.1.115</a>&gt;;tag=Kmmp7H4SHtegB</div>


<div>To: &lt;<a href="mailto:sip%3A19999999876@172.16.1.115" target="_blank">sip:19999999876@172.16.1.115</a>&gt;</div><div>Call-ID: 8dc4b6c9-a42d-1232-879e-07071b1d0b50</div><div>CSeq: 63995759 INVITE</div><div>Server: OpenSIPS (1.9.2-notls (x86_64/linux))</div>


<div>Content-Length: 0</div><div><br></div><div>U 2014/08/21 19:27:27.880492 <a href="http://172.16.1.2:5060" target="_blank">172.16.1.2:5060</a> -&gt; <a href="http://172.16.1.115:5060" target="_blank">172.16.1.115:5060</a></div>

<div>SIP/2.0 488 Destinations Exhausted</div>
<div>Via: SIP/2.0/UDP 172.16.1.115:5060;branch=z9hG4bK3854.62532862.0</div><div>Via: SIP/2.0/UDP 172.16.1.105;received=172.16.1.105;rport=5060;branch=z9hG4bKFg352a70a3UDe</div><div>From: &quot;SCHIP OR&quot; &lt;<a href="mailto:sip%3A12122558005@172.16.1.115" target="_blank">sip:1</a><a href="mailto:sip%3A12122558005@172.16.1.115" target="_blank">9999999999</a>@<a href="http://172.16.1.115">172.16.1.115</a>&gt;;tag=Kmmp7H4SHtegB</div>


<div>To: &lt;<a href="mailto:sip%3A19999999876@172.16.1.115" target="_blank">sip:19999999876@172.16.1.115</a>&gt;;tag=5e9fb1280a969f03e7584717dc0b2ef5-7492</div><div>Call-ID: 8dc4b6c9-a42d-1232-879e-07071b1d0b50</div><div>

CSeq: 63995759 INVITE</div>
<div>Server: OpenSIPS (1.9.2-notls (x86_64/linux))</div><div>Content-Length: 0</div><div><br></div><div>######</div><div>This ACK has the correct Via because the INVITE was to a local gateway</div><div>######</div><div><br>


</div><div>U 2014/08/21 19:27:27.880799 <a href="http://172.16.1.115:5060" target="_blank">172.16.1.115:5060</a> -&gt; <a href="http://172.16.1.2:5060" target="_blank">172.16.1.2:5060</a></div><div>ACK <a href="mailto:sip%3A19999999876@172.16.1.2" target="_blank">sip:19999999876@172.16.1.2</a> SIP/2.0</div>


<div><b>Via: SIP/2.0/UDP 172.16.1.115:5060;branch=z9hG4bK3854.62532862.0</b></div><div>From: &quot;SCHIP OR&quot; &lt;<a href="mailto:sip%3A12122558005@172.16.1.115" target="_blank">sip:1</a><a href="mailto:sip%3A12122558005@172.16.1.115" target="_blank">9999999999</a>@<a href="http://172.16.1.115">172.16.1.115</a>&gt;;tag=Kmmp7H4SHtegB</div>

<div>
Call-ID: 8dc4b6c9-a42d-1232-879e-07071b1d0b50</div><div>To: &lt;<a href="mailto:sip%3A19999999876@172.16.1.115" target="_blank">sip:19999999876@172.16.1.115</a>&gt;;tag=5e9fb1280a969f03e7584717dc0b2ef5-7492</div><div>CSeq: 63995759 ACK</div>


<div>Max-Forwards: 70</div><div>User-Agent: OpenSIPS (1.9.2-notls (x86_64/linux))</div><div>Content-Length: 0</div><div><br></div><div><br></div><div>U 2014/08/21 19:27:27.881441 <a href="http://172.16.1.115:5060" target="_blank">172.16.1.115:5060</a> -&gt; <a href="http://ext.ern.al.gw:5060" target="_blank">ext.ern.al.gw:5060</a></div>


<div>INVITE <a href="http://sip:19999999876@ext.ern.al.gw:5060" target="_blank">sip:19999999876@ext.ern.al.gw:5060</a> SIP/2.0</div><div>Record-Route: &lt;sip:opn.sips.ext.ip:5060;ftag=Kmmp7H4SHtegB;lr&gt;</div><div>Record-Route: &lt;sip:172.16.1.115:5060;ftag=Kmmp7H4SHtegB;lr&gt;</div>


<div>Via: SIP/2.0/UDP opn.sips.ext.ip:5060;branch=z9hG4bK3854.62532862.1</div><div>Via: SIP/2.0/UDP 172.16.1.105;received=172.16.1.105;rport=5060;branch=z9hG4bKFg352a70a3UDe</div><div>Max-Forwards: 66</div><div>From: &quot;SCHIP OR&quot; &lt;<a href="mailto:sip%3A12122558005@172.16.1.115" target="_blank">sip:1</a><a href="mailto:sip%3A12122558005@172.16.1.115" target="_blank">9999999999</a>@<a href="http://172.16.1.115">172.16.1.115</a>&gt;;tag=Kmmp7H4SHtegB</div>


<div>To: &lt;<a href="mailto:sip%3A19999999876@172.16.1.115" target="_blank">sip:19999999876@172.16.1.115</a>&gt;</div><div>Call-ID: 8dc4b6c9-a42d-1232-879e-07071b1d0b50</div><div>CSeq: 63995759 INVITE</div><div>Contact: &lt;sip:gw+opensips@172.16.1.105:5060;transport=udp;gw=opensips&gt;</div>


<div>User-Agent: FS5</div><div>Allow: INVITE, ACK, BYE, CANCEL, OPTIONS, MESSAGE, INFO, UPDATE, REGISTER, REFER, NOTIFY</div><div>Supported: timer, precondition, path, replaces</div><div>Allow-Events: talk, hold, conference, refer</div>


<div>Content-Type: application/sdp</div><div>Content-Disposition: session</div><div>Content-Length: 249</div><div>X-FS-Support: update_display,send_info</div><div>Remote-Party-ID: &quot;SCHIP OR&quot; &lt;<a href="mailto:sip%3A12122558005@172.16.1.115" target="_blank">sip:1</a><a href="mailto:sip%3A12122558005@172.16.1.115" target="_blank">9999999999</a>@<a href="http://172.16.1.115">172.16.1.115</a>&gt;;party=calling;screen=yes;privacy=off</div>


<div><br></div><div>v=0</div><div>o=FreeSWITCH 1408638865 1408638866 IN IP4 8.34.49.250</div><div>s=FreeSWITCH</div><div>c=IN IP4 8.34.49.250</div><div>t=0 0</div><div>m=audio 40528 RTP/AVP 9 0 8 3 101</div><div>a=rtpmap:101 telephone-event/8000</div>


<div>a=fmtp:101 0-16</div><div>a=silenceSupp:off - - - -</div><div>a=ptime:20</div><div>a=schipmangled:yes</div><div><br></div><div>U 2014/08/21 19:27:27.888532 <a href="http://ext.ern.al.gw:5060" target="_blank">ext.ern.al.gw:5060</a> -&gt; <a href="http://172.16.1.115:5060" target="_blank">172.16.1.115:5060</a></div>


<div>SIP/2.0 100 Trying</div><div>Via: SIP/2.0/UDP opn.sips.ext.ip:5060;branch=z9hG4bK3854.62532862.1</div><div>Via: SIP/2.0/UDP 172.16.1.105;received=172.16.1.105;rport=5060;branch=z9hG4bKFg352a70a3UDe</div><div>From: &quot;SCHIP OR&quot; &lt;<a href="mailto:sip%3A12122558005@172.16.1.115" target="_blank">sip:1</a><a href="mailto:sip%3A12122558005@172.16.1.115" target="_blank">9999999999</a>@<a href="http://172.16.1.115">172.16.1.115</a>&gt;;tag=Kmmp7H4SHtegB</div>


<div>To: &lt;<a href="mailto:sip%3A19999999876@172.16.1.115" target="_blank">sip:19999999876@172.16.1.115</a>&gt;;tag=gK0cc2566e</div><div>Call-ID: 8dc4b6c9-a42d-1232-879e-07071b1d0b50</div><div>CSeq: 63995759 INVITE</div>

<div>Content-Length: 0</div>
<div><br></div><div><br></div><div>U 2014/08/21 19:27:27.912504 <a href="http://ext.ern.al.gw:5060" target="_blank">ext.ern.al.gw:5060</a> -&gt; <a href="http://172.16.1.115:5060" target="_blank">172.16.1.115:5060</a></div>

<div>SIP/2.0 404 Not Found</div>
<div>Via: SIP/2.0/UDP opn.sips.ext.ip:5060;branch=z9hG4bK3854.62532862.1</div><div>Via: SIP/2.0/UDP 172.16.1.105;received=172.16.1.105;rport=5060;branch=z9hG4bKFg352a70a3UDe</div><div>From: &quot;SCHIP OR&quot; &lt;<a href="mailto:sip%3A12122558005@172.16.1.115" target="_blank">sip:1</a><a href="mailto:sip%3A12122558005@172.16.1.115" target="_blank">9999999999</a>@<a href="http://172.16.1.115">172.16.1.115</a>&gt;;tag=Kmmp7H4SHtegB</div>


<div>To: &lt;<a href="mailto:sip%3A19999999876@172.16.1.115" target="_blank">sip:19999999876@172.16.1.115</a>&gt;;tag=gK0cc2566e</div><div>Call-ID: 8dc4b6c9-a42d-1232-879e-07071b1d0b50</div><div>CSeq: 63995759 INVITE</div>

<div>Reason: Q.850;cause=1</div>
<div>Content-Length: 0</div><div><br></div><div><div>######</div><div>This ACK has an incorrect Via because the INVITE was to sent to an external gateway</div><div>######</div></div><div><br></div><div>U 2014/08/21 19:27:27.912687 <a href="http://172.16.1.115:5060" target="_blank">172.16.1.115:5060</a> -&gt; <a href="http://ext.ern.al.gw:5060" target="_blank">ext.ern.al.gw:5060</a></div>


<div>ACK <a href="http://sip:19999999876@ext.ern.al.gw:5060" target="_blank">sip:19999999876@ext.ern.al.gw:5060</a> SIP/2.0</div><div><b>Via: SIP/2.0/UDP 172.16.1.115:5060;branch=z9hG4bK3854.62532862.1</b></div><div>From: &quot;SCHIP OR&quot; &lt;<a href="mailto:sip%3A12122558005@172.16.1.115" target="_blank">sip:1</a><a href="mailto:sip%3A12122558005@172.16.1.115" target="_blank">9999999999</a>@<a href="http://172.16.1.115">172.16.1.115</a>&gt;;tag=Kmmp7H4SHtegB</div>


<div>Call-ID: 8dc4b6c9-a42d-1232-879e-07071b1d0b50</div><div>To: &lt;<a href="mailto:sip%3A19999999876@172.16.1.115" target="_blank">sip:19999999876@172.16.1.115</a>&gt;;tag=gK0cc2566e</div><div>CSeq: 63995759 ACK</div><div>

Max-Forwards: 70</div>
<div>User-Agent: OpenSIPS (1.9.2-notls (x86_64/linux))</div><div>Content-Length: 0</div></div><div><br></div>
</div></div>