Hello,

I try to setup a SIP infrastructure with Kamailio server in private network and 
a pass through Kamailio proxy in the DMZ for NAT handling. (-> TEST.jpg)
The pass through proxy uses a new routing algorithm and this works fine for 
external calls to internal calls. (->Kamailio.cfg.txt)
The logic behind is if a packet on external interface arrives, the proxy change 
the URI and forward the packet to the internal SIP server.
Otherwise, the proxy shall forward the packet to external interface if a packet 
arrives at the internal interface.
Because the SIP server has a fix IP, it's easy to route to this server, but the 
way back is more complicated and I think my algorithm is not working.
But the first problem is the routing behavior from the private server if I try 
to make a call from intern to extern. The server sends the request to the 
external IP address from the client and the IP address from the pass through 
Kamailio proxy is not considered.


8(2720) ERROR: <core> [udp_server.c:576]: udp_send(): 
sendto(sock,0x7f4724dd9238,1328,0,192.168.1.20:5060,16): Network is 
unreachable(101)
8(2720) ERROR: tm [../../forward.h:208]: msg_send(): udp_send failed
8(2720) WARNING: tm [t_fwd.c:1610]: t_send_branch(): ERROR: t_send_branch: 
sending request on branch 0 failed
8(2720) exec: *** cfgtrace:request_route=[RELAY] 
c=[/usr/local/etc/kamailio/kamailio.cfg] l=553 a=24 n=sl_reply_error
8(2720) ERROR: sl [sl_funcs.c:387]: sl_reply_error(): ERROR: sl_reply_error 
used: Unfortunately error on sending to next hop occurred (477/SL)
8(2720) exec: *** cfgtrace:request_route=[RELAY] 
c=[/usr/local/etc/kamailio/kamailio.cfg] l=555 a=2 n=exit
7(2718) exec: *** cfgtrace:request_route=[DEFAULT_ROUTE] 
c=[/usr/local/etc/kamailio/kamailio.cfg] l=474 a=5 n=route

To change the IP address which is used from the private server as the 
destination address,  I added the following lines to the Kamailio.cfg.

modparam("registrar", "use_path",1)
modparam("registrar", "path_mode", 2)
modparam("registrar", "path_use_received",1)
modparam("path", "use_received", 1)



But the routing behavior has not changed. (perhaps this configure was not the 
right)

Is there a way to configure the private server that the last IP address from 
the record-route header is used?



Cheers,

Kai







#!KAMAILIO

################################################################
#
#  SIP relay server for Bluepackets
#  Author: Stanislav Sinyagin <ssinay...@k-open.com>
#
################################################################

fork=yes
children=4


###  Site-specific configuration defines hosts and ports
include_file "/etc/kamailio/kamailio_siteconfig.cfg"

####### Global Parameters #########

#!ifdef WITH_DEBUG
debug=4
log_stderror=no
#!else
debug=2
log_stderror=no
#!endif

memdbg=5
memlog=5

log_facility=LOG_LOCAL0

# This is not part of siteconfig because the routing logic
# depends on these settings
disable_tcp=yes
auto_aliases=no
mhomed=1


####### Modules Section ########

mpath="/usr/lib/x86_64-linux-gnu/kamailio/modules"

loadmodule "mi_fifo.so"
loadmodule "kex.so"
loadmodule "sl.so"
loadmodule "rr.so"
loadmodule "pv.so"
loadmodule "maxfwd.so"
loadmodule "textops.so"
loadmodule "siputils.so"
loadmodule "xlog.so"
loadmodule "sanity.so"
loadmodule "ctl.so"
loadmodule "cfg_rpc.so"
loadmodule "mi_rpc.so"

loadmodule "rtpproxy.so"
loadmodule "nathelper.so"

#!ifdef WITH_DEBUG
loadmodule "debugger.so"
#!endif

# ----------------- setting module-specific parameters ---------------


modparam("mi_fifo", "fifo_name", "/tmp/kamailio_fifo")

modparam("nathelper", "received_avp", "$avp(RECEIVED)")
modparam("nathelper", "nortpproxy_str", "a=sdpmangled:yes\r\n")

modparam("rtpproxy", "rtpproxy_sock", "udp:127.0.0.1:9000")
modparam("rtpproxy", "nortpproxy_str", "")

#!ifdef WITH_DEBUG
# ----- debugger params -----
modparam("debugger", "cfgtrace", 1)
#!endif

####### Routing Logic ########


route {
    if (!sanity_check()) {
        exit;
    }

    if ( !mf_process_maxfwd_header("10") )
    {
        sl_send_reply("483","To Many Hops");
        xlog("L_NOTICE", "$si $rm $ru -- too many hops\n");
        exit;
    }

    if( !is_method("OPTIONS") )
    {
        xlog("L_INFO", "received SIP request: " +
            "$si:$sp -> $rm $ru From: $fu To: $tu\n");
    }
    
    if( !loose_route() )
    {
        $var(usr) = "";
        if( !strempty($rU) )
        {
            $var(usr) = $rU + "@";
        }
        
        if (dst_ip == 192.168.0.2 && dst_port == 5060)
        {
            $du = "sip:" + "192.168.1.1" + ":" + "5060";
            $ru = "sip:" + $var(usr) + "192.168.1.1" + ":" + "5060";
            loose_route();
            record_route();
            rtpproxy_manage("cwie");    
        }
        else if (dst_ip == 192.168.1.1 && dst_port == 5060)
        {
            $du = "sip:" + "192.168.0.1" + ":" + "5060";
            $ru = "sip:" + $var(usr) + "192.168.0.1" + ":" + "5060";
            rtpproxy_manage("cwei");
            record_route(); 
        }
        else
        {
            xlog("L_NOTICE", "Dropping request: $si:$sp $rm $ru\n");
            exit;
        }
    }


    forward();
    if( !is_method("OPTIONS") )
    {
        xlog("L_INFO", "forwarding SIP request: " +
            "$nh(u) <- $rm $ru From: $fu To: $tu\n");
    }
}


onreply_route {

    if( !is_method("OPTIONS") )
    {
        xlog("L_INFO", "received SIP reply: " +
            "$si:$sp -> $rs $rm From: $fu To: $tu\n");
    }
    
    if (dst_ip == 192.168.0.2 && dst_port == 5060)
    {
        rtpproxy_manage("cwei");
    }
    else if(dst_ip == 192.168.1.1 && dst_port == 5060)
    {
        rtpproxy_manage("cwie");
#        fix_nated_contact();
    }
    else
    {
        exit;
    }
    
    return(1);
}



# Local Variables:
# mode: sh
# sh-indent-after-if: 0
# indent-tabs-mode: nil
# tab-width: 4
# End:

_______________________________________________
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
sr-users@lists.sip-router.org
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users

Reply via email to