Change SIP desnation port

Hello all,
I have a problem. I want change destination port in SIP packet.


When Server 106.18 send an request OPTIONS to my server 0.218, then my server response status 200 OK with destination port = source port of request OPTIONS packet.
I want to change destination port when my server response request from server 106.18 in range 5060 - 5100.
Thanks all !!!

You will need to change that in the peer or the router, depending on which one is setting the current port number.

You haven’t provided enough information to say whether this is the case, but if the Via header does contain either the desired port number, or none, disabling the force_rport nat= sub-option may help. This assumes that whatever changed the port number is capable of routing a reply based on the untranslated number.

Even then, this will only work if the sender isn’t using rport. I think current versions may have an option to ingnore rport.

My partner only accept rule for my server connect to their server in range port 5060 - 5100.
My partner’s server send SIP messenger to my asterisk server with source port = random and dst port = 5060. Then my server response to partner server with source port = 5060 and dst port in range 5060 - 5100.
Sorry for my bad English.
Thanks !!!

Please provide the headers from its SIP request. Basically if it is sending the port number used in the Contact header, the requirement is unreasonable. Otherwise correct use of nat= should help.