<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    Hello,<br>
    <br>
    We are using opensips 1.5.3 on a multi-homed system. This system has
    three IP address"z<br>
    <br>
    1- one public IP address on the Internet<br>
    2- one private IP address provided by a client open vpn connection.<br>
    3- another private IP address as open vpn server.<br>
    <br>
    When using SIP over TCP to reach another SIP system on the Internet,
    fails to open new outbound TCP connections.<br>
    For instance, <br>
    <br>
    UAC ----&gt; opensips proxy ----&gt; other SIP system<br>
    <br>
    if we setup a static route (using t_relay('tcp:othersystem') to the
    other system, it fails to relay the INVITE packet from opensips
    proxy to the outside sysem<br>
    &nbsp;<br>
    A wireshark capture shows that the source address of the TCP packet
    SYN using is in fact a <u>private address</u>.<br>
    <br>
    I looked at the code of <br>
    <br>
    struct tcp_connection* tcpconn_connect(struct socket_info*
    send_sock, union sockaddr_union* server, int type) in tcp_main.c<br>
    <br>
    and I wonder why we bind the socket to the selected out_socket
    rather than let the operating system select the proper IP address?<br>
    <br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; my_name_len = sockaddru_len(send_sock-&gt;su);<br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; memcpy( &amp;my_name, &amp;send_sock-&gt;su, my_name_len);<br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; su_setport( &amp;my_name, 0);<br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (bind(s, &amp;my_name.s, my_name_len )!=0) {<br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; LM_ERR("bind failed (%d) %s\n",
    errno,strerror(errno));<br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; goto error;<br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>
    <br>
    I looked at the code of get_send_socket() in foward.c and in case of
    tcp, it seems that we select the "main IP address" which value is
    determined at startup in main.c<br>
    In case of multihomed system, the value of this "main Ip address"
    seems not to be deterministc.<br>
    <br>
    As a conclution:&nbsp; would it&nbsp; hurt if we would remove the bind() call
    from tcpconn_connect() ? <br>
    <br>
    Emmanuel BUU<br>
    IV&egrave;S<br>
    <a class="moz-txt-link-freetext" href="http://www.ives.fr/">http://www.ives.fr/</a><br>
    <br>
  </body>
</html>