Reopening. (https://github.com/kamailio/kamailio/issues/3932#issuecomment-2252138364)
It's bug.
Please see highlighted on screenshot.

Hey Team,
Thank you for the awesome software
### Description
Neither option work:
`listen=... advertise some.custom.hostname.io` `listen=... advertise some.custom.hostname.io:0`
to make Kamailio present only hostname(without port) in Record-Route headers, affects NAPTR/SRV.
### Troubleshooting
============ _Hostname without port - still gives port 5081 in Record-Route_
**kamailio.cfg** ... `listen=tls:KAM_LOC_IP:5081 advertise some.custom.io name "provider_socket_tls"` ...
**sngrep, 200 OK for INVITE** ... `Record-Route: sip:some.custom.io:5081;transport=tls;r2=on;lr;did=494.6e51` ...
**kamcmd corex.list_sockets** ... ``` { af: IPv4 proto: tls name: 172.17.57.164 addrlist: { addr: 172.17.57.164 } port: 5081 sockstr: tls:172.17.57.164:5081 mcast: no mhomed: no virtual: no sockname: provider_socket_tls advertise: tls:some.custom.io:0 } ``` ...
======== _Hostname with port 0 - still gives port 5081 in Record-Route_
kamailio.cfg ... `listen=tls:KAM_LOC_IP:5081 advertise some.custom.io:0 name "provider_socket_tls"` ...
sngrep, 200 OK for INVITE ... `Record-Route: sip:some.custom.io:5081;transport=tls;r2=on;lr;did=042.7721` ...
kamcmd corex.list_sockets ... ``` { af: IPv4 proto: tls name: 172.17.57.164 addrlist: { addr: 172.17.57.164 } port: 5081 sockstr: tls:172.17.57.164:5081 mcast: no mhomed: no virtual: no sockname: provider_socket_tls advertise: tls:some.custom.io:0 } ``` ...
============ _Hostname with explicit different port 8888 - gives that port 8888 in Record-Route (to confirm config works)_
kamailio.cfg ... `listen=tls:KAM_LOC_IP:5081 advertise some.custom.io:8888 name "provider_socket_tls"` ...
sngrep, 200 OK for INVITE ... `Record-Route: sip:some.custom.io:8888;transport=tls;r2=on;lr;did=dae.ac31` ...
kamcmd corex.list_sockets ... ``` { af: IPv4 proto: tls name: 172.17.57.164 addrlist: { addr: 172.17.57.164 } port: 5081 sockstr: tls:172.17.57.164:5081 mcast: no mhomed: no virtual: no sockname: provider_socket_tls advertise: tls:some.custom.io:8888 } ``` ...
#### Reproduction
Please see Troubleshooting section
#### Debugging Data
Please see Troubleshooting section
#### Log Messages
N/A
#### SIP Traffic
Please see Troubleshooting section
### Possible Solutions
N/A
### Additional Information
* **Kamailio Version** - output of `kamailio -v`
``` version: kamailio 5.8.2 (x86_64/linux) dbe51d flags: USE_TCP, USE_TLS, USE_SCTP, TLS_HOOKS, USE_RAW_SOCKS, DISABLE_NAGLE, USE_MCAST, DNS_IP_HACK, SHM_MMAP, PKG_MALLOC, MEM_JOIN_FREE, 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_SEND_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: dbe51d compiled on 07:13:22 Jul 17 2024 with gcc 12.2.0) ```
* **Operating System**:
``` [dev]root@[voiceproxy]:~# lsb_release -a No LSB modules are available. Distributor ID: Debian Description: Debian GNU/Linux 12 (bookworm) Release: 12 Codename: bookworm [dev]root@[voiceproxy]:~# uname -a Linux i-0875d7720d6152612 6.1.0-23-cloud-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.99-1 (2024-07-15) x86_64 GNU/Linux [dev]root@[voiceproxy]:~# cat /etc/*relea* ID=ec2 VERSION="20240702-1796" PRETTY_NAME="Debian GNU/Linux 12 (bookworm)" NAME="Debian GNU/Linux" VERSION_ID="12" VERSION="12 (bookworm)" VERSION_CODENAME=bookworm ID=debian HOME_URL="https://www.debian.org/" SUPPORT_URL="https://www.debian.org/support" BUG_REPORT_URL="https://bugs.debian.org/" ```
* **Might be related** : https://github.com/kamailio/kamailio/issues/1884
Hey Team, Let me know if this ticket would benefit of any additional information/clarification. Thank you.
I jus tested with latest 5.8 and master branches and all is fine -- the advertise is a hostname without port or with port 0 and the Via and Record-Route do not have any port in it.
Can you retest with these versions and see if headers are ok? If not, be sure you don't use other functions to add record route where the port is explicitly provided. Otherwise, you may have to provide the config in order to see what is specific to it.
Preparing config.
Re-tested on latest Master: ``` # kamailio -V version: kamailio 6.0.0-dev2 (x86_64/linux) 2bcd29 flags: USE_TCP, USE_TLS, USE_SCTP, TLS_HOOKS, USE_RAW_SOCKS, DISABLE_NAGLE, USE_MCAST, DNS_IP_HACK, SHM_MMAP, PKG_MALLOC, MEM_JOIN_FREE, 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_SEND_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: 2bcd29 compiled on 02:01:14 Sep 12 2024 with gcc 12.2.0 ```
Script to prepare config: ``` # cat cfg_prep.sh #!/bin/bash
KAM_LOCAL_IPV4=${1:-"192.168.0.114"}
mkdir -p /etc/kamailio/
curl -s https://raw.githubusercontent.com/kamailio/kamailio/master/etc/kamailio.cfg -o /etc/kamailio/kamailio.cfg_orig_master
sed -e "s|# listen=udp:10.0.0.10:5060|# listen=udp:10.0.0.10:5060\n\ listen=udp:${KAM_LOCAL_IPV4}:5060 advertise name3 name "sockname3"\n\ listen=udp:${KAM_LOCAL_IPV4}:5070 advertise name2:0 name "sockname2"\n\ listen=udp:${KAM_LOCAL_IPV4}:5080 advertise name1 name "sockname1"\n\ |g" \ -e 's|# - define WITH_PSTN|#!define WITH_PSTN|g' \ -e 's|pstn.gw_ip = "" desc "PSTN GW Address"|pstn.gw_ip = "8.8.8.8" desc "PSTN GW Address"|g' \ -e 's|pstn.gw_port = "" desc "PSTN GW Port"|pstn.gw_port = "5081" desc "PSTN GW Port"|g' \ -e 's|# normalize target number for pstn gateway|$fsn = "sockname1";|g' \ /etc/kamailio/kamailio.cfg_orig_master ``` To generate config issue the following(where 192.168.2.22 is local Kamailio ipv4): ``` bash ./cfg_prep.sh 192.168.2.22 > /etc/kamailio.cfg ```
Call from somewhere to udp:kamailio_ip:5070
This is export from sngrep while testing: ``` 2024/09/12 05:18:10.163960 192.168.1.201:63333 -> 192.168.1.114:5070 INVITE sip:00111111@192.168.1.114:5070 SIP/2.0 Via: SIP/2.0/UDP 192.168.1.201:63333;rport;branch=z9hG4bKPjKODU-8Rj6qEaa0zRs8y8YIXZizScJ0w9 Max-Forwards: 70 From: "www" sip:fff@192.168.1.114;tag=DFPm.aaF4b7t-6i.D4iPRlVKDhsERLmh To: sip:00111111@192.168.1.114 Contact: "www" sip:fff@192.168.1.201:63333;ob Call-ID: IWoCmeJg5FuclMQJxrRPYiEp.bKObBxV CSeq: 26703 INVITE Allow: PRACK, INVITE, ACK, BYE, CANCEL, UPDATE, INFO, SUBSCRIBE, NOTIFY, REFER, MESSAGE, OPTIONS Supported: replaces, 100rel, norefersub User-Agent: Telephone 1.6 Content-Type: application/sdp Content-Length: 348
v=0 o=- 3935107090 3935107090 IN IP4 192.168.1.201 s=pjmedia b=AS:84 t=0 0 a=X-nat:0 m=audio 4004 RTP/AVP 8 0 101 c=IN IP4 192.168.1.201 b=TIAS:64000 a=rtcp:4005 IN IP4 192.168.1.201 a=sendrecv a=rtpmap:8 PCMA/8000 a=rtpmap:0 PCMU/8000 a=rtpmap:101 telephone-event/8000 a=fmtp:101 0-16 a=ssrc:566268823 cname:02ea4a2263a8ffac
2024/09/12 05:18:10.165079 192.168.1.114:5070 -> 192.168.1.201:63333 SIP/2.0 100 trying -- your call is important to us Via: SIP/2.0/UDP 192.168.1.201:63333;rport=63333;branch=z9hG4bKPjKODU-8Rj6qEaa0zRs8y8YIXZizScJ0w9;received=192.168.1.201 From: "www" sip:fff@192.168.1.114;tag=DFPm.aaF4b7t-6i.D4iPRlVKDhsERLmh To: sip:00111111@192.168.1.114 Call-ID: IWoCmeJg5FuclMQJxrRPYiEp.bKObBxV CSeq: 26703 INVITE Server: kamailio (6.0.0-dev2 (x86_64/linux)) Content-Length: 0
2024/09/12 05:18:10.165566 192.168.1.114:5080 -> 8.8.8.8:5081 INVITE sip:+111111@8.8.8.8:5081 SIP/2.0 Record-Route: sip:name1:5080;r2=on;lr Record-Route: sip:name2:5070;r2=on;lr Via: SIP/2.0/UDP name1:5080;branch=z9hG4bK9e32.8824aa0f912d2eef54ed88beef9ccede.0 Via: SIP/2.0/UDP 192.168.1.201:63333;received=192.168.1.201;rport=63333;branch=z9hG4bKPjKODU-8Rj6qEaa0zRs8y8YIXZizScJ0w9 Max-Forwards: 69 From: "www" sip:fff@192.168.1.114;tag=DFPm.aaF4b7t-6i.D4iPRlVKDhsERLmh To: sip:00111111@192.168.1.114 Contact: "www" sip:fff@192.168.1.201:63333;ob Call-ID: IWoCmeJg5FuclMQJxrRPYiEp.bKObBxV CSeq: 26703 INVITE Allow: PRACK, INVITE, ACK, BYE, CANCEL, UPDATE, INFO, SUBSCRIBE, NOTIFY, REFER, MESSAGE, OPTIONS Supported: replaces, 100rel, norefersub User-Agent: Telephone 1.6 Content-Type: application/sdp Content-Length: 348
v=0 o=- 3935107090 3935107090 IN IP4 192.168.1.201 s=pjmedia b=AS:84 t=0 0 a=X-nat:0 m=audio 4004 RTP/AVP 8 0 101 c=IN IP4 192.168.1.201 b=TIAS:64000 a=rtcp:4005 IN IP4 192.168.1.201 a=sendrecv a=rtpmap:8 PCMA/8000 a=rtpmap:0 PCMU/8000 a=rtpmap:101 telephone-event/8000 a=fmtp:101 0-16 a=ssrc:566268823 cname:02ea4a2263a8ffac ```
We can see ports are present in headers: ``` Record-Route: sip:name1:5080;r2=on;lr Record-Route: sip:name2:5070;r2=on;lr Via: SIP/2.0/UDP name1:5080;branch=z9hG4bK9e32.8824aa0f912d2eef54ed88beef9ccede.0 Via: SIP/2.0/UDP 192.168.1.201:63333;received=192.168.1.201;rport=63333;branch=z9hG4bKPjKODU-8Rj6qEaa0zRs8y8YIXZizScJ0w9 ```
@miconda
Thank you
Can you try with latest git master branch?
I could reproduce when it was bridging between sockets and different ports. Let's see if works as expected.
Hey Daniel,
Appreciate quick response on this one.
With my tests on latest master, Record-Route headers are looking good.
Still had port present in VIA header:
Via: SIP/2.0/TLS `kamailio.dns.name222:5071`;branch=z9hG4bK83fc.e394332204faf76799e7cb02f73e3233.0;i=304
```2024/09/18 02:16:24.639056 172.17.57.172:5071 -> 172.17.57.213:5071 INVITE sip:out_7777777777@kamailio.dns.name111 SIP/2.0 Record-Route: sip:7777777777@kamailio.dns.name222;transport=tls;sn=local_socket_tls;r2=on;lr=on;ftag=11f0476e-71e4-4289-86cb-ca492dbca126 Record-Route: sip:7777777777@kamailio.dns.name111;transport=tls;sn=external_socket_tls;r2=on;lr=on;ftag=11f0476e-71e4-4289-86cb-ca492dbca126 Via: SIP/2.0/TLS kamailio.dns.name222:5071;branch=z9hG4bK83fc.e394332204faf76799e7cb02f73e3233.0;i=304 Via: SIP/2.0/TLS 172.17.0.103:5061;received=172.17.0.103;rport=39519;branch=z9hG4bKPj9711ba02-84bb-4de4-9a2f-8b06c9e8cc22;alias From: sip:5555555555@172.17.0.103;tag=11f0476e-71e4-4289-86cb-ca492dbca126 To: sip:7777777777@kamailio.dns.name111 Contact: sip:itsp@172.17.0.103:5061;transport=TLS Call-ID: 6ec2392c-77a3-4353-b1e3-772b81330d8e CSeq: 30429 INVITE Allow: OPTIONS, REGISTER, SUBSCRIBE, NOTIFY, PUBLISH, INVITE, ACK, BYE, CANCEL, UPDATE, PRACK, MESSAGE, REFER Supported: 100rel, timer, replaces, norefersub, histinfo Session-Expires: 1800 Min-SE: 90 P-Asserted-Identity: sip:5555555555@172.17.0.103 Max-Forwards: 69 User-Agent: ITSP PBX Content-Type: application/sdp Content-Length: 312```
Thank you.
This issue is stale because it has been open 6 weeks with no activity. Remove stale label or comment or this will be closed in 2 weeks.
Adding comment to refresh issue.
This issue is stale because it has been open 6 weeks with no activity. Remove stale label or comment or this will be closed in 2 weeks.
Closed #3933 as completed.
There was a commit long time ago (abaf42a735b00af8cbfec90888d2ef3397e5040d) that should have fixed it for Via, just forgot to follow up here. If not, create a new issue, the code has been changed quite a lot since then.