<p></p>
<h3 dir="auto">Description</h3>
<p dir="auto">Hello,<br>
I have faced an issue when mhomed working well only for udp destinations, and I believe that it is a bug.<br>
I have kamailio behind NAT with two network interfaces and I make a call from a softphone to kamailio and change $rd on kamailio side.<br>
If kamailio forward call to the UDP destination, mhomed option chooses the correct Via and the correct interface for sending. But if the destination is tls, mhomed chooses first described listen interface from the config file (as described in the documentation.</p>
<h4 dir="auto">The example</h4>
<p dir="auto">So in my example when I call to sip:111@kamailio_ip kamailio going to send this call to $rd="1.1.1.1" and set Via and Record-Route to 10.0.0.32 (it is ok, because IP route to 1.1.1.1 via 10.0.0.32)<br>
when I call to sip:1111@kamailio_ip kamailio going to send this call to $rd="192.168.10.100:5061;transport=tls" BUT set Via and Record-Route to 10.0.0.32 (this is wrong because IP route to 192.168.10.100 is 192.168.10.145), but if in config file the first listen interface is 192.168.10.145, kamailio sends Via correct.</p>
<h4 dir="auto">Networking</h4>
<p><a target="_blank" rel="noopener noreferrer" href="https://user-images.githubusercontent.com/1487709/170417427-573f4038-b214-407e-907b-ed66b1f1d060.png"><img width="743" alt="image" src="https://user-images.githubusercontent.com/1487709/170417427-573f4038-b214-407e-907b-ed66b1f1d060.png" style="max-width: 100%;"></a></p>
<p><a target="_blank" rel="noopener noreferrer" href="https://user-images.githubusercontent.com/1487709/170417453-0a3925bf-bab4-4784-b3e7-6acfd4e35d93.png"><img width="511" alt="image" src="https://user-images.githubusercontent.com/1487709/170417453-0a3925bf-bab4-4784-b3e7-6acfd4e35d93.png" style="max-width: 100%;"></a></p>
<h4 dir="auto">Kamailio config</h4>
<pre class="notranslate"><code class="notranslate">auto_aliases=yes
mhomed=1
tcp_connection_match=1 # I have tried with and without this option

listen=udp:10.0.0.32:5060
listen=tls:10.0.0.32:5061
listen=udp:192.168.10.145:5060
listen=tls:192.168.10.145:5061

.....
modparam("rr", "enable_full_lr", 1)
modparam("rr", "append_fromtag", 1)
#modparam("rr", "enable_double_rr", 2) # I have tried with and without this option
.....
# routing
if $rU == "111" {
    $rd="1.1.1.1";
} else {
   $rd="192.168.10.100:5061;transport=tls";
}
route(RELAY);
</code></pre>
<h4 dir="auto">Reproduction</h4>
<p dir="auto">I have created a testing stand with almost default kamailio config so I can give full ssh access if you need it.<br>
I just call from linphone to sip:111@server_ip and sip:1111@server_ip</p>
<h4 dir="auto">SIP Traffic</h4>
<p><a target="_blank" rel="noopener noreferrer" href="https://user-images.githubusercontent.com/1487709/170420217-882d236b-243f-4ffd-ae9a-7afe80222e22.png"><img width="554" alt="image" src="https://user-images.githubusercontent.com/1487709/170420217-882d236b-243f-4ffd-ae9a-7afe80222e22.png" style="max-width: 100%;"></a></p>
<pre class="notranslate"><code class="notranslate">INVITE sip:111@1.1.1.1 SIP/2.0
Record-Route: <sip:10.0.0.32;lr=on;ftag=GRIfZymtj;nat=yes>
Via: SIP/2.0/UDP 10.0.0.32;branch=z9hG4bKc662.d4fa02b9991c45869263fc4359af8d84.0
Via: SIP/2.0/UDP 10.5.7.0:52360;received=210.1.88.115;branch=z9hG4bK.mH58YeIkv;rport=35775
From: <sip:akam@10.5.7.0>;tag=GRIfZymtj
To: sip:111@130.61.43.152
CSeq: 20 INVITE
Call-ID: FR3BLskG9-
Max-Forwards: 69
Supported: replaces, outbound, gruu
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, NOTIFY, MESSAGE, SUBSCRIBE, INFO, PRACK, UPDATE
Content-Type: application/sdp
Content-Length: 613
</code></pre>
<p><a target="_blank" rel="noopener noreferrer" href="https://user-images.githubusercontent.com/1487709/170420360-a7889e57-b072-4220-9d28-0dcd39eb860b.png"><img width="584" alt="image" src="https://user-images.githubusercontent.com/1487709/170420360-a7889e57-b072-4220-9d28-0dcd39eb860b.png" style="max-width: 100%;"></a></p>
```
INVITE sip:1111@192.168.10.100:5061;transport=tls SIP/2.0
Record-Route: 
Record-Route: 
Via: SIP/2.0/TLS 10.0.0.32:5061;branch=z9hG4bK6a2.4ff69c3e304e238936a5528da681cd49.0
Via: SIP/2.0/UDP 10.5.7.0:52360;received=210.1.88.115;branch=z9hG4bK.BPohOzqtI;rport=35775
From: ;tag=cIRc7nj00
To: sip:1111@130.61.43.152
CSeq: 20 INVITE
Call-ID: 40PEbKneY0
```
<h3 dir="auto">Additional Information</h3>
<pre class="notranslate"><code class="notranslate">root@mhomed-tls:/etc/kamailio# kamailio -v
version: kamailio 5.5.4 (x86_64/linux)
flags: USE_TCP, USE_TLS, USE_SCTP, TLS_HOOKS, USE_RAW_SOCKS, DISABLE_NAGLE, USE_MCAST, DNS_IP_HACK, SHM_MMAP, PKG_MALLOC, Q_MALLOC, F_MALLOC, TLSF_MALLOC, DBG_SR_MEMORY, USE_FUTEX, FAST_LOCK-ADAPTIVE_WAIT, USE_DNS_CACHE, USE_DNS_FAILOVER, USE_NAPTR, USE_DST_BLOCKLIST, HAVE_RESOLV_RES, TLS_PTHREAD_MUTEX_SHARED
ADAPTIVE_WAIT_LOOPS 1024, MAX_RECV_BUFFER_SIZE 262144, MAX_URI_SIZE 1024, BUF_SIZE 65535, DEFAULT PKG_SIZE 8MB
poll method support: poll, epoll_lt, epoll_et, sigio_rt, select.
id: unknown
compiled with gcc 9.3.0
</code></pre>
<ul dir="auto">
<li><strong>Operating System</strong>:</li>
</ul>
<pre class="notranslate"><code class="notranslate">Ubuntu 20.04.4 LTS
</code></pre>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />Reply to this email directly, <a href="https://github.com/kamailio/kamailio/issues/3124">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/ABO7UZKQBQC7GHOEVLUNO6DVL4B5DANCNFSM5W7TSQNA">unsubscribe</a>.<br />You are receiving this because you are subscribed to this thread.<img src="https://github.com/notifications/beacon/ABO7UZMSZVQWDTFNDZRZTA3VL4B5DA5CNFSM5W7TSQNKYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4STT37QA.gif" height="1" width="1" alt="" /><span style="color: transparent; font-size: 0; display: none; visibility: hidden; overflow: hidden; opacity: 0; width: 0; height: 0; max-width: 0; max-height: 0; mso-hide: all">Message ID: <span><kamailio/kamailio/issues/3124</span><span>@</span><span>github</span><span>.</span><span>com></span></span></p>
<script type="application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/kamailio/kamailio/issues/3124",
"url": "https://github.com/kamailio/kamailio/issues/3124",
"name": "View Issue"
},
"description": "View this Issue on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>