Description

Hello,
I have faced an issue when mhomed working well only for udp destinations, and I believe that it is a bug.
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.
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.

The example

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)
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.

Networking

image

image

Kamailio config

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);

Reproduction

I have created a testing stand with almost default kamailio config so I can give full ssh access if you need it.
I just call from linphone to sip:111@server_ip and sip:1111@server_ip

SIP Traffic

image

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

image

``` 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 ```

Additional Information

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
Ubuntu 20.04.4 LTS


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <kamailio/kamailio/issues/3124@github.com>