### Description Setting the `advertise` parameter of the `listen` option in `kamailio.cfg` has no effect on the `Via` address sent by the UAC module. I expected the `Via` header to contain the public IP. Instead, the REGISTER requests sent by the UAC module continue to use the private ip:
``` listen=<private ip>:5060 advertise <public ip>:5060 ``` ``` Via: SIP/2.0/UDP <private ip>:5060;branch=z9hG4bK6c7b.fc053184000000000000000000000000.0 ```
This is confusing since the core cookbook recommends against using `advertised_address`.
### Possible Solutions With the `advertised_address` option, the IP in the Via header is set to the public IP address as expected:
``` advertised_address=<public ip>:5060 listen=<private ip>:5060 ``` ``` Via: SIP/2.0/UDP <public ip>:5060;branch=z9hG4bK45ba.c2851fa6000000000000000000000000.0 ``` ### Additional Information
* **Kamailio Version** - output of `kamailio -v`
``` version: kamailio 5.2.3 (x86_64/linux) c36229 flags: STATS: Off, USE_TCP, USE_TLS, TLS_HOOKS, USE_RAW_SOCKS, DISABLE_NAGLE, USE_MCAST, DNS_IP_HACK, SHM_MEM, 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_BLACKLIST, HAVE_RESOLV_RES 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: c36229 compiled on 13:25:11 Jun 2 2019 with gcc 8.3.0 ```
* **Operating System**:
<!-- Details about the operating system, the type: Linux (e.g.,: Debian 8.4, Ubuntu 16.04, CentOS 7.1, ...), MacOS, xBSD, Solaris, ...; Kernel details (output of `uname -a`) -->
``` Linux linux 5.1.5-gentoo #1 SMP PREEMPT Mon May 27 14:42:14 CEST 2019 x86_64 AMD A6-3670 APU with Radeon(tm) HD Graphics AuthenticAMD GNU/Linux ```
At the first check of the sources, the value for advertise of listen global param should be used.
Do you have a single listen?
Are you generating the request in config with uac_req_sent()? Or what module generates the local request?
In my setup, Kamailio is listening on two sockets: ``` advertised_address="<public hostname>:5060" listen=udp:10.0.0.100:5060 listen=udp:192.168.178.21:5060 ``` I should also mention that I advertise a hostname, not an IP address.
The REGISTER request is sent automatically on start-up based on the information from the database: ``` modparam("uac", "reg_db_url", DB_URL) modparam("uac", "reg_timer_interval", 59) modparam("uac", "reg_retry_interval", 300) modparam("uac", "reg_contact_addr", "<public hostname>:5060") ```
In the example you paste above none of the listen params have `advertise` attribute.
Sorry, I posted the working configuration. Here is the one that did not send the correct `Via` header: ``` listen=udp:10.0.0.100:5060 listen=udp:192.168.178.21:5060 advertise <public hostnam>:5060 ```
Is the Via address with 192.168.178.21 or 10.0.0.100?
Yes, it is. The setup is the following:
``` +----------+ +--------+ eth0 | Kamailio | eth1 <---> lan0 | Router | wan0 +----------+ +--------+
eth0 = 10.0.0.100 eth1 = 192.168.178.21 lan0 = 192.168.178.1 wan0 = public IP referenced by a DynDNS hostname in the advertise parameter ``` The via address is `192.168.178.21`.
Can you give the output of:
``` kamctl srv sockets ```
Then, try to add an event_route[tm:local-request] and force the send socket to 192.168.178.21 and then see if the advertise address is in Via.
Here is the output of `kamctl srv sockets`: ``` list listen sockets { "jsonrpc": "2.0", "result": [ { "PROTO": "udp", "NAME": "10.0.0.100", "ADDRLIST": { "ADDR": "10.0.0.100" }, "PORT": "5060", "MCAST": "no", "MHOMED": "no", "ADVERTISE": "-" }, { "PROTO": "udp", "NAME": "192.168.178.21", "ADDRLIST": { "ADDR": "192.168.178.21" }, "PORT": "5060", "MCAST": "no", "MHOMED": "no", "ADVERTISE": "<public hostname>" } ], "id": 12460 } ```
If I add the following event route, the Via address is still 192.168.178.21: ``` event_route[tm:local-request] { $fs = "192.168.178.21:5060"; } ```
I just tested with uac_req_send() and the Via is the advertised address. Internally, it uses the same function exposed by tm module to send requests like for uac remote registrations, respectively the tmb.t_request(). So it could be something specific for your config. Run kamailio with debug=3 in configuration file and grab all the log/debug messages printed from start till registrations are sent (do it for 1-2 uac registration records). Along with them, grab the pcap file of the sip traffic on the network. Attach the two files here for troubleshooting.
Any update on this one?
Closed #1973.
First of all, I appreciate it very much that you are helping me out with this. In the meantime, my network setup has changed, so the issue will be hard to reproduce.
I opened this ticket, because I thought it was a bug and wanted to prevent other users from running into it. If you say it is not a problem with the code, this issue can be closed from my side.
Once again, thank you for your help and the quick responses!