Opensips relaying MESSAGE - source IP problem

Halys
2010-11-05
2013-05-09
  • Halys
    Halys
    2010-11-05

    Hi,

    I'm encountering some issue with my Opensips configuration.
    My Opensips server is configured to relay SIP MESSAGE requests to another server when the destination URI is not located on my server. Here is the part of opensips.cfg which is concerned :

            if (!lookup("location","m")) {
                    switch ($retcode) {
                            case -1:
                            case -3:

                                    rewritehost("10.254.230.148");
                                    if (is_method("MESSAGE")) {
                                            rewriteport("5062");
                                    }
                                    if (!t_relay()) {
                                            sl_reply_error();
                                    }
                                    exit;
                            case -2:
                                    sl_send_reply("405", "Method Not Allowed");
                                    exit;
                    }
            }

    My server receives SIP requests on eth0 interface (IP 10.254.31.45) but when it relays the requests to the server 10.254.230.148 it should use eth2 interface (IP 10.254.28.45) because there is a firewall between the two servers and port 5062 is only allowed for source IP 10.254.28.45. The problem is the following : when I open Wireshark on my Opensips server, I can see that the source IP for the relayed MESSAGE is still 10.254.31.45 so it never reaches the other server !

    I don't understand where is the issue, my Linux routing table is OK, when I'm trying to reach 10.254.230.148 from my Opensips server using telnet for example it uses the right interface and the right gateway. Here is my routing table :

    10.254.230.144  10.254.28.1     255.255.255.240 UG        0 0          0 eth2
    10.254.31.0     0.0.0.0         255.255.255.0   U         0 0          0 eth0
    10.254.28.0     0.0.0.0         255.255.255.0   U         0 0          0 eth2
    10.254.29.0     0.0.0.0         255.255.255.0   U         0 0          0 eth3
    192.168.0.0     10.254.28.1     255.255.255.0   UG        0 0          0 eth2
    10.254.225.0    10.254.28.1     255.255.255.0   UG        0 0          0 eth2
    0.0.0.0         10.254.31.1     0.0.0.0         UG        0 0          0 eth0

    Did I miss something in Opensips configuration file ?
    Thanks a lot for your help.

    Best Regards,

    Sebastien

     
  • does your opensips listen on both 10.254.31.45 and 10.254.28.45 IPs ?

    Regards,
    Bogdan

     
  • Halys
    Halys
    2010-11-23

    Hi Bogdan,

    Yes it does.
    Actually I posted a message on the Opensips-users mailing list and someone helped me find a solution : I used the force_send_socket() function and it worked.
    Thank you.

    Best Regards,
    Sebastien