You are right Alex, Linux kernel didn't support SO_REUSEPORT, which allows a socket to be used as source for a tcp connection while is already bound, until version 3.9.
Kamailio's parameter tcp_reuse_port, if enabled and your OS has support for SO_REUSEPORT (so not only Linux but FreeBSD, OSX and others), allows you to use force_send_socket (or $fs) to send messages from a TCP port kamailio is listening to.

Cheers,

Federico

On Fri, May 18, 2018 at 12:28 AM, Alex Balashov <abalashov@evaristesys.com> wrote:
When an outgoing TCP connection is opened, either a port can be
explicitly bound, or it is auto-assigned by the OS's networking stack. I
believe Kamailio does the latter and does not offer options to constrain
the range. If it does, I'm not aware of any apart from this one:

https://www.kamailio.org/wiki/cookbooks/5.1.x/core#tcp_reuse_port

Not sure if it would help in this case, you'd have to give it a try.

On Thu, May 17, 2018 at 10:21:34PM +0000, Wilkins, Steve wrote:

> It appears that the bottom line of my TCP transport not working is that Kamailio is randomly assigning large port numbers to send the TCP traffic out on.
> I am not able to randomly open high ports for this purpose.  Is there a way to tell Kamailio to only use specific ports for this.  I have tried using
> force_send_socket() with Kamailio' s IP, and the port I want to send out on, but this did not work either.  Does this sound like I am on the right track?
>
> Thank you,
> -

> _______________________________________________
> Kamailio (SER) - Users Mailing List
> sr-users@lists.kamailio.org
> https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users


--
Alex Balashov | Principal | Evariste Systems LLC

Tel: +1-706-510-6800 / +1-800-250-5920 (toll-free)
Web: http://www.evaristesys.com/, http://www.csrpswitch.com/

_______________________________________________
Kamailio (SER) - Users Mailing List
sr-users@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users