As I was involed in this conversation via other channel, some comments on this to the community.

1. Kamailio is acting according to these parts of 3261 - https://www.rfc-editor.org/rfc/rfc3261.html#section-18.2.1
If the host portion of the "sent-by" parameter
   contains a domain name, or if it contains an IP address that differs
   from the packet source address, the server MUST add a "received"
   parameter to that Via header field value.  This parameter MUST
   contain the source address from which the packet was received.  This
   is to assist the server transport layer in sending the response,
   since it must be sent to the source IP address from which the request
   came.

   Consider a request received by the server transport which looks like,
   in part:

      INVITE sip:bob@Biloxi.com SIP/2.0
      Via: SIP/2.0/UDP bobspc.biloxi.com:5060

   The request is received with a source IP address of 192.0.2.4.
   Before passing the request up, the transport adds a "received"
   parameter, so that the request would look like, in part:

      INVITE sip:bob@Biloxi.com SIP/2.0
      Via: SIP/2.0/UDP bobspc.biloxi.com:5060;received=192.0.2.4

2. And forming a responce without force_rport() according to this https://www.rfc-editor.org/rfc/rfc3261.html#section-18.2.2

Otherwise (for unreliable unicast transports), if the top Via
         has a "received" parameter, the response MUST be sent to the
         address in the "received" parameter, using the port indicated
         in the "sent-by" value, or using port 5060 if none is specified
         explicitly.

So, the question was mainly why responce is sent back to the source address, but to a different ("default") port.

Consider this as a reading RFC 3261 outloud once again )

Le lun. 11 mars 2024 à 00:24, Ben Kaufman via sr-users <sr-users@lists.kamailio.org> a écrit :

Kind of depends on which RFC you’re talking about.

 

As Fred asked – do you have `force_rport` set?  This is defined in RFC3581.  In an *ideal* world, your UAC would put the `rport` parameter (without value) in it’s Via header.   Kamailio can be told to “consider this request like there’s an `rport` in the top most via header” by setting `force_rport`.  This is what you want based on your description below.

 

Regards,

Kaufman

 

 

 

From: Antonio via sr-users <sr-users@lists.kamailio.org>
Sent: Sunday, March 10, 2024 11:08 AM
To: Fred Posner <fred@pgpx.io>
Cc: Kamailio (SER) - Users Mailing List <sr-users@lists.kamailio.org>; Antonio <satskiy.a@gmail.com>
Subject: [SR-Users] Re: SIP Redirect Server

 

CAUTION: This email originated from outside the organization. Do not click links or open attachments unless you recognize the sender and know the content is safe.

 

Please close request as I found out that this is required behaviour according to RFC 

 

 

 

On Sun, 10 Mar 2024 at 15:00, Fred Posner <fred@pgpx.io> wrote:

Do you have force_rport anywhere in the config?

 

-- Fred Posner

Sent from mobile

Phone: +1 (352) 664-3733

 

 



On Mar 10, 2024, at 8:37AM, Antonio via sr-users <sr-users@lists.kamailio.org> wrote:



Hi everyone

I have a small question:

i want to set up a basic SIP Redirect Server

so I install Kamailio v5.3

and  comment  default  request route and set simple

 

request_route {

rewritehostport("1.2.3.4");

sl_send_reply("302", "Moved Temporarily");

}

 

but for some reason, Kamailio does not care about the port and sends a reply to 5060

<image.png>

 

i also tried to delete   rewritehostport

but it only deletes Contact: from the reply

but reply  itself is still sent to  5060 port

<image.png>

 

__________________________________________________________
Kamailio - Users Mailing List - Non Commercial Discussions
To unsubscribe send an email to sr-users-leave@lists.kamailio.org
Important: keep the mailing list in the recipients, do not reply only to the sender!
Edit mailing list options or unsubscribe:

__________________________________________________________
Kamailio - Users Mailing List - Non Commercial Discussions
To unsubscribe send an email to sr-users-leave@lists.kamailio.org
Important: keep the mailing list in the recipients, do not reply only to the sender!
Edit mailing list options or unsubscribe:


--
Best regards,
Ihor (Igor)